17#include "gandiva/tree_expr_builder.h"
18#include "arrow/status.h"
19#include "gandiva/filter.h"
20#include <catch_amalgamated.hpp>
21#include <arrow/util/key_value_metadata.h>
62DECLARE_SOA_TABLE(Segments,
"TEST",
"SEGMENTS", test::N, test::PointAId, test::PointBId, test::InfoId);
77 auto pwriter =
b1.
cursor<o2::aod::Points3Ds>();
78 for (
auto i = 0;
i < 20; ++
i) {
79 pwriter(0, -1 *
i, (
int)(
i / 2), 2 *
i);
81 auto t1 =
b1.finalize();
83 auto pt = o2::aod::Points3Ds{
t1};
84 auto pt1 = o2::aod::Points3DMk1s{
t1};
85 auto pt2 = o2::aod::Points3DMk2s{
t1};
86 auto pt3 = o2::aod::Points3DMk3s{
t1};
87 REQUIRE(pt1.begin().mark() == (
size_t)1);
88 REQUIRE(pt2.begin().mark() == (
size_t)2);
89 REQUIRE(pt3.begin().mark() == (
size_t)3);
95 auto rowWriter = builder.
persist<int32_t, int32_t>({
"fX",
"fY"});
108 i.mCurrentPos = &
pos;
125 arrow::ChunkedArray* chunks[2] = {
126 table->column(0).get(),
127 table->column(1).get()};
128 o2::aod::Points::iterator tests(chunks, {table->num_rows(), 0});
129 REQUIRE(tests.x() == 0);
130 REQUIRE(tests.y() == 0);
132 REQUIRE(tests.x() == 0);
133 REQUIRE(tests.y() == 1);
138 auto e = tests2.end();
152 REQUIRE(((
b + 1) == (
b + 1)));
153 REQUIRE(((
b + 7) !=
b));
154 REQUIRE(((
b + 7) != e));
155 REQUIRE(((
b + 8) == e));
157 for (
auto& t : tests2) {
158 REQUIRE(t.x() ==
value / 4);
159 REQUIRE((
size_t)t.y() ==
value);
164 for (
auto t1 = tests2.begin();
t1 != tests2.end(); ++
t1) {
165 for (
auto t2 =
t1 + 1; t2 != tests2.end(); ++t2) {
173 auto rowWriter = builder.
persist<int32_t, int32_t>({
"fX",
"fY"});
184 using Test1 =
InPlaceTable<
"A"_h, o2::aod::test::X, o2::aod::test::Y, o2::aod::test::Sum<o2::aod::test::X, o2::aod::test::Y>>;
187 for (
auto&
test : tests1) {
191 using Test2 =
InPlaceTable<
"B"_h, o2::aod::test::X, o2::aod::test::Y, o2::aod::test::Sum<o2::aod::test::Y, o2::aod::test::Y>>;
194 for (
auto&
test : tests2) {
202 auto rowWriter = builder.
persist<int32_t, int32_t>({
"fX",
"fY"});
216 foo.mCurrentPos = &index1;
218 bar.mCurrentPos = &index2;
219 REQUIRE(
foo.mCurrent == bar.mCurrent);
220 REQUIRE(
foo.mLast == bar.mLast);
221 REQUIRE(
foo.mColumn == bar.mColumn);
222 REQUIRE(
foo.mFirstIndex == bar.mFirstIndex);
223 REQUIRE(
foo.mCurrentChunk == bar.mCurrentChunk);
225 auto foobar = std::move(
foo);
226 REQUIRE(foobar.mCurrent == bar.mCurrent);
227 REQUIRE(foobar.mLast == bar.mLast);
228 REQUIRE(foobar.mColumn == bar.mColumn);
229 REQUIRE(foobar.mFirstIndex == bar.mFirstIndex);
230 REQUIRE(foobar.mCurrentChunk == bar.mCurrentChunk);
236 auto rowWriterX = builderX.
persist<int32_t>({
"fX"});
248 auto rowWriterY = builderY.
persist<int32_t>({
"fY"});
260 auto rowWriterZ = builderZ.
persist<int32_t>({
"fZ"});
276 REQUIRE(Test::contains<TestX>());
277 REQUIRE(Test::contains<TestY>());
278 REQUIRE(!Test::contains<TestZ>());
280 Test tests{{tableX, tableY}, 0};
282 REQUIRE(tests.contains<TestX>());
283 REQUIRE(tests.contains<TestY>());
284 REQUIRE(!tests.contains<TestZ>());
286 for (
auto&
test : tests) {
290 auto tests2 =
join(TestX{tableX}, TestY{tableY});
291 static_assert(std::same_as<Test::self_t,
decltype(tests2)>,
"Joined tables should have the same type, regardless how we construct them");
292 for (
auto&
test : tests2) {
296 auto tests3 =
join(TestX{tableX}, TestY{tableY}, TestZ{tableZ});
298 for (
auto&
test : tests3) {
302 TestMoreThanTwo tests4{{tableX, tableY, tableZ}, 0};
303 for (
auto&
test : tests4) {
311 auto rowWriterA = builderA.
persist<int32_t, int32_t>({
"fX",
"fY"});
321 REQUIRE(tableA->num_rows() == 8);
324 auto rowWriterB = builderB.
persist<int32_t>({
"fX"});
336 auto rowWriterC = builderC.
persist<int32_t>({
"fZ"});
348 auto rowWriterD = builderD.
persist<int32_t, int32_t>({
"fX",
"fZ"});
349 rowWriterD(0, 16, 8);
350 rowWriterD(0, 17, 9);
351 rowWriterD(0, 18, 10);
352 rowWriterD(0, 19, 11);
353 rowWriterD(0, 20, 12);
354 rowWriterD(0, 21, 13);
355 rowWriterD(0, 22, 14);
356 rowWriterD(0, 23, 15);
368 static_assert(std::same_as<NestedJoinTest::columns_t, o2::framework::pack<o2::soa::Index<>, o2::aod::test::Y, o2::aod::test::X, o2::aod::test::Z>>,
"Bad nested join");
370 static_assert(std::same_as<ConcatTest::columns_t, o2::framework::pack<o2::soa::Index<>, o2::aod::test::X>>,
"Bad intersection of columns");
371 ConcatTest tests{tableA, tableB};
372 REQUIRE(16 == tests.size());
373 for (
auto&
test : tests) {
377 static_assert(std::same_as<NestedConcatTest::columns_t, o2::framework::pack<o2::aod::test::X>>,
"Bad nested concat");
384 auto status = gandiva::SelectionVector::MakeInt64(tests.size(), arrow::default_memory_pool(), &selection);
385 REQUIRE(status.ok());
387 auto fptr = tableA->schema()->GetFieldByName(
"fX");
388 REQUIRE(fptr !=
nullptr);
389 REQUIRE(fptr->name() ==
"fX");
390 REQUIRE(fptr->type()->id() == arrow::Type::INT32);
392 auto node_x = gandiva::TreeExprBuilder::MakeField(fptr);
393 auto literal_1 = gandiva::TreeExprBuilder::MakeLiteral(
static_cast<int32_t
>(1));
394 auto literal_3 = gandiva::TreeExprBuilder::MakeLiteral(
static_cast<int32_t
>(3));
395 auto equals_to_1 = gandiva::TreeExprBuilder::MakeFunction(
"equal", {node_x, literal_1}, arrow::boolean());
396 auto equals_to_3 = gandiva::TreeExprBuilder::MakeFunction(
"equal", {node_x, literal_3}, arrow::boolean());
397 auto node_or = gandiva::TreeExprBuilder::MakeOr({equals_to_1, equals_to_3});
398 auto condition = gandiva::TreeExprBuilder::MakeCondition(node_or);
399 REQUIRE(condition->ToString() ==
"bool equal((int32) fX, (const int32) 1) || bool equal((int32) fX, (const int32) 3)");
400 std::shared_ptr<gandiva::Filter>
filter;
401 status = gandiva::Filter::Make(tableA->schema(), condition, &
filter);
402 REQUIRE(status.ToString() ==
"OK");
404 arrow::TableBatchReader reader(*tableA);
405 std::shared_ptr<RecordBatch> batch;
406 auto s = reader.ReadNext(&batch);
408 REQUIRE(batch !=
nullptr);
409 REQUIRE(batch->num_rows() == 8);
410 auto st =
filter->Evaluate(*batch, selection);
411 REQUIRE(
st.ToString() ==
"OK");
416 FilteredTest filtered{{testA.asArrowTable()}, selection_f};
417 REQUIRE(2 == filtered.size());
420 REQUIRE(filtered.begin() != filtered.end());
421 for (
auto&
f : filtered) {
422 REQUIRE(
i * 2 + 1 ==
f.x());
423 REQUIRE(
i * 2 + 1 ==
f.index());
432 status = gandiva::SelectionVector::MakeInt64(tests.size(), arrow::default_memory_pool(), &selectionConcat);
433 REQUIRE(status.ok() ==
true);
434 selectionConcat->SetIndex(0, 0);
435 selectionConcat->SetIndex(1, 5);
436 selectionConcat->SetIndex(2, 10);
437 selectionConcat->SetNumSlots(3);
438 ConcatTest concatTest{tableA, tableB};
439 FilteredConcatTest concatTestTable{{concatTest.asArrowTable()}, selectionConcat};
440 REQUIRE(3 == concatTestTable.size());
443 auto b = concatTestTable.begin();
444 auto e = concatTestTable.end();
446 REQUIRE(
b.mRowIndex == 0);
447 REQUIRE(
b.getSelectionRow() == 0);
448 REQUIRE(e.index == 3);
450 REQUIRE(concatTestTable.begin() != concatTestTable.end());
451 for (
auto&
f : concatTestTable) {
452 REQUIRE(
i * 5 ==
f.x());
453 REQUIRE(
i * 5 ==
f.index());
454 REQUIRE(
i ==
f.filteredIndex());
462 status = gandiva::SelectionVector::MakeInt64(tests.size(), arrow::default_memory_pool(), &selectionJoin);
463 REQUIRE(status.ok() ==
true);
464 selectionJoin->SetIndex(0, 0);
465 selectionJoin->SetIndex(1, 2);
466 selectionJoin->SetIndex(2, 4);
467 selectionJoin->SetNumSlots(3);
468 JoinedTest testJoin{{tableA, tableC}, 0};
469 FilteredJoinTest filteredJoin{{testJoin.asArrowTable()}, selectionJoin};
472 REQUIRE(filteredJoin.begin() != filteredJoin.end());
473 for (
auto&
f : filteredJoin) {
474 REQUIRE(
i * 2 ==
f.x());
475 REQUIRE(
i * 2 ==
f.index());
484 auto pointsWriter = builderA.
cursor<o2::aod::Points>();
485 pointsWriter(0, 0, 0);
486 pointsWriter(0, 3, 4);
488 o2::aod::Points points{pointsT};
489 REQUIRE(pointsT->num_rows() == 2);
492 auto infoWriter = builderA2.
cursor<o2::aod::Infos>();
493 infoWriter(0, 0,
true);
494 infoWriter(0, 1,
false);
495 infoWriter(0, 4,
true);
497 o2::aod::Infos infos{infosT};
498 REQUIRE(infos.begin().someBool() ==
true);
499 REQUIRE((infos.begin() + 1).someBool() ==
false);
500 REQUIRE((infos.begin() + 2).someBool() ==
true);
501 REQUIRE((infos.begin() + 2).color() == 4);
502 REQUIRE(infosT->num_rows() == 3);
505 auto segmentsWriter = builderB.
cursor<o2::aod::Segments>();
506 segmentsWriter(0, 10, 0, 1, 2);
507 auto segmentsT = builderB.
finalize();
508 o2::aod::Segments
segments{segmentsT};
509 REQUIRE(segmentsT->num_rows() == 1);
512 auto segmentsExtraWriter = builderC.
cursor<o2::aod::SegmentsExtras>();
513 segmentsExtraWriter(0, 1);
514 auto segmentsExtraT = builderC.
finalize();
515 o2::aod::SegmentsExtras segmentsExtras{segmentsExtraT};
516 REQUIRE(segmentsExtraT->num_rows() == 1);
518 REQUIRE(
segments.begin().pointAId() == 0);
519 REQUIRE(
segments.begin().pointBId() == 1);
520 static_assert(std::same_as<
decltype(
segments.begin().pointA()), o2::aod::Points::iterator>);
523 i.bindExternalIndices(&points, &infos);
524 REQUIRE(
i.n() == 10);
525 REQUIRE(
i.info().color() == 4);
526 REQUIRE(
i.info().someBool() ==
true);
527 REQUIRE(
i.pointA().x() == 0);
528 REQUIRE(
i.pointA().y() == 0);
529 REQUIRE(
i.pointB().x() == 3);
530 REQUIRE(
i.pointB().y() == 4);
532 segments.bindExternalIndices(&points, &infos);
534 REQUIRE(
j.n() == 10);
535 REQUIRE(
j.info().color() == 4);
536 REQUIRE(
j.info().someBool() ==
true);
537 REQUIRE(
j.pointA().x() == 0);
538 REQUIRE(
j.pointA().y() == 0);
539 REQUIRE(
j.pointB().x() == 3);
540 REQUIRE(
j.pointB().y() == 4);
543 joined.bindExternalIndices(&points, &infos);
544 auto se = joined.begin();
545 REQUIRE(se.n() == 10);
546 REQUIRE(se.info().color() == 4);
547 REQUIRE(se.pointA().x() == 0);
548 REQUIRE(se.pointA().y() == 0);
549 REQUIRE(se.pointB().x() == 3);
550 REQUIRE(se.pointB().y() == 4);
551 REQUIRE(se.thickness() == 1);
556 auto schema = std::make_shared<arrow::Schema>(
createFieldsFromColumns(o2::aod::Points::persistent_columns_t{}));
557 REQUIRE(schema->num_fields() == 2);
558 REQUIRE(schema->field(0)->name() ==
"fX");
559 REQUIRE(schema->field(1)->name() ==
"fY");
565 auto rowWriterA = builderA.
persist<int32_t, int32_t>({
"fX",
"fY"});
568 rowWriterA(0, 2, 10);
569 rowWriterA(0, 3, 11);
570 rowWriterA(0, 4, 12);
571 rowWriterA(0, 5, 13);
572 rowWriterA(0, 6, 14);
573 rowWriterA(0, 7, 15);
575 REQUIRE(tableA->num_rows() == 8);
586 FilteredTest filtered1{{testA.asArrowTable()},
s1};
587 REQUIRE(4 == filtered1.size());
588 REQUIRE(filtered1.begin() != filtered1.end());
591 FilteredTest filtered2{{testA.asArrowTable()}, s2};
592 REQUIRE(2 == filtered2.size());
593 REQUIRE(filtered2.begin() != filtered2.end());
595 FilteredTest filteredUnion = filtered1 + filtered2;
596 REQUIRE(6 == filteredUnion.size());
598 std::vector<std::tuple<int32_t, int32_t>> expectedUnion{{0, 8}, {1, 9}, {2, 10}, {3, 11}, {6, 14}, {7, 15}};
600 for (
auto&
f : filteredUnion) {
601 REQUIRE(std::get<0>(expectedUnion[
i]) ==
f.x());
602 REQUIRE(std::get<1>(expectedUnion[
i]) ==
f.y());
603 REQUIRE(std::get<0>(expectedUnion[
i]) ==
f.index());
608 FilteredTest filteredIntersection = filtered1 * filtered2;
609 REQUIRE(0 == filteredIntersection.size());
612 for (
auto const& _ : filteredIntersection) {
619 FilteredTest filtered3{{testA.asArrowTable()}, s3};
620 REQUIRE(3 == filtered3.size());
621 REQUIRE(filtered3.begin() != filtered3.end());
623 FilteredTest unionIntersection = (filtered1 + filtered2) * filtered3;
624 REQUIRE(3 == unionIntersection.size());
627 for (
auto&
f : unionIntersection) {
629 REQUIRE(
i + 8 ==
f.y());
630 REQUIRE(
i ==
f.index());
639 auto rowWriterA = builderA.
persist<int32_t, int32_t>({
"fX",
"fY"});
642 rowWriterA(0, 2, 10);
643 rowWriterA(0, 3, 11);
644 rowWriterA(0, 4, 12);
645 rowWriterA(0, 5, 13);
646 rowWriterA(0, 6, 14);
647 rowWriterA(0, 7, 15);
649 REQUIRE(tableA->num_rows() == 8);
663 FilteredTest filtered{{testA.asArrowTable()},
s1};
664 REQUIRE(4 == filtered.size());
665 REQUIRE(filtered.begin() != filtered.end());
668 NestedFilteredTest nestedFiltered{{filtered}, s2};
669 REQUIRE(2 == nestedFiltered.size());
671 for (
auto&
f : nestedFiltered) {
672 REQUIRE(
i + 2 ==
f.x());
673 REQUIRE(
i + 10 ==
f.y());
674 REQUIRE(
i + 2 ==
f.index());
680 TripleNestedFilteredTest tripleFiltered{{nestedFiltered}, s3};
681 REQUIRE(1 == tripleFiltered.size());
683 for (
auto&
f : tripleFiltered) {
684 REQUIRE(
i + 2 ==
f.x());
685 REQUIRE(
i + 10 ==
f.y());
686 REQUIRE(
i + 2 ==
f.index());
695 [[maybe_unused]]
auto pwriter = bPoints.
cursor<o2::aod::Points>();
699 [[maybe_unused]]
auto iwriter = bInfos.
cursor<o2::aod::Infos>();
702 o2::aod::Points p{pempty};
703 o2::aod::Infos
i{iempty};
706 PI pi{{pempty, iempty}, 0};
707 REQUIRE(pi.size() == 0);
708 auto spawned = Extend<o2::aod::Points, o2::aod::test::ESum>(p);
709 REQUIRE(spawned.size() == 0);
730 auto writer =
b.
cursor<o2::aod::Origints>();
731 for (
auto i = 0;
i < 20; ++
i) {
732 writer(0,
i,
i % 3 == 0);
734 auto origins =
b.finalize();
735 o2::aod::Origints
o{origins};
738 auto writer_z =
z.
cursor<o2::aod::ManyReferences>();
739 std::vector<int>
ids;
740 for (
auto i = 0;
i < 5; ++
i) {
742 for (
auto j = 0;
j < 20; ++
j) {
747 auto mrefs =
z.finalize();
748 o2::aod::ManyReferences
m{mrefs};
751 auto writer_w =
w.
cursor<o2::aod::References>();
752 for (
auto i = 0;
i < 5 * 20; ++
i) {
755 auto refs =
w.finalize();
756 o2::aod::References
r{refs};
760 Flt
f{{
o.asArrowTable()}, selection};
761 r.bindExternalIndices(&
f);
764 REQUIRE(it.origint_as<Flt>().globalIndex() == 3);
766 REQUIRE(it.origint_as<Flt>().globalIndex() == 4);
768 REQUIRE(it.origint_as<Flt>().globalIndex() == 5);
770 m.bindExternalIndices(&
f);
771 for (
auto const&
row :
m) {
772 auto os =
row.origints_as<Flt>();
773 auto fos =
row.filtered_origints_as<Flt>();
774 REQUIRE(os.size() == 20);
775 REQUIRE(fos.size() == 6);
791DECLARE_SOA_TABLE(PointsRefF,
"TEST",
"PTSREFF", test::SinglePointId, test::Points3DIdSlice, test::Points3DIds);
793 test::PointSeqIdSlice, test::PointSetIds);
800 for (
auto i = 0;
i < 20; ++
i) {
801 pwriter(0, -1 *
i, (
int)(
i / 2), 2 *
i);
803 auto tpts1 =
b1.finalize();
806 auto prwriter = b2.
cursor<o2::aod::PointsRef>();
807 auto a = std::array{0, 1};
808 auto aa = std::vector{2, 3, 4};
809 prwriter(0, &
a[0], aa);
812 prwriter(0, &
a[0], aa);
815 auto pt = o2::aod::Points3Ds{tpts1};
816 auto prt = o2::aod::PointsRef{t2};
817 prt.bindExternalIndices(&pt);
819 auto it = prt.begin();
820 auto s1 = it.pointSlice();
821 auto g1 = it.pointGroup();
822 auto bb = std::same_as<
decltype(
s1), o2::aod::Points3Ds>;
824 REQUIRE(
s1.size() == 2);
826 for (
int i = 0;
i < 3; ++
i) {
827 REQUIRE(g1[
i].globalIndex() == aa[
i]);
832 for (
auto& p : it.pointGroup_as<o2::aod::Points3Ds>()) {
833 REQUIRE(p.x() == -1 * p.globalIndex());
837 auto s2 = it.pointSlice();
838 auto g2 = it.pointGroup();
839 REQUIRE(s2.size() == 7);
841 for (
int i = 0;
i < 3; ++
i) {
842 REQUIRE(g2[
i].globalIndex() == aa[
i]);
848 prt.bindExternalIndices(&
f);
850 auto it2 = prt.begin();
851 auto s1f = it2.pointSlice_as<Flt>();
852 auto g1f = it2.pointGroup_as<Flt>();
853 REQUIRE(s1f.size() == 2);
855 for (
int i = 0;
i < 3; ++
i) {
856 REQUIRE(g1f[
i].globalIndex() == aa[
i]);
860 auto s2f = it2.pointSlice_as<Flt>();
861 auto g2f = it2.pointGroup_as<Flt>();
862 REQUIRE(s2f.size() == 7);
864 for (
int i = 0;
i < 3; ++
i) {
865 REQUIRE(g2f[
i].globalIndex() == aa[
i]);
869 auto pswriter = b3.
cursor<o2::aod::PointsSelfIndex>();
870 int references[] = {19, 2, 0, 13, 4, 6, 5, 5, 11, 9, 3, 8, 16, 14, 1, 18, 12, 18, 2, 7};
871 int slice[2] = {-1, -1};
872 std::vector<int> pset;
873 std::array<int, 4> withSlices = {3, 6, 13, 19};
874 std::array<std::pair<int, int>, 4> bounds = {std::pair{1, 5}, std::pair{3, 3}, std::pair{11, 11}, std::pair{10, 18}};
875 std::array<int, 4> withSets = {0, 1, 13, 14};
876 unsigned int sizes[] = {3, 1, 5, 4};
879 for (
auto i = 0;
i < 20; ++
i) {
883 if (
c1 < withSlices.size() &&
i == withSlices[
c1]) {
884 slice[0] = bounds[
c1].first;
885 slice[1] = bounds[
c1].second;
888 if (
c2 < withSets.size() &&
i == withSets[
c2]) {
890 pset.push_back(
i + 1 +
z);
894 pswriter(0, -1 *
i, 0.5 *
i, 2 *
i, references[
i], slice, pset);
897 auto pst = o2::aod::PointsSelfIndex{t3};
898 pst.bindInternalIndicesTo(&pst);
902 for (
auto& p : pst) {
903 auto op = p.otherPoint_as<o2::aod::PointsSelfIndex>();
904 auto bbb = std::same_as<
decltype(
op), o2::aod::PointsSelfIndex::iterator>;
906 REQUIRE(
op.globalIndex() == references[
i]);
908 auto ops = p.pointSeq_as<o2::aod::PointsSelfIndex>();
909 auto bbbs = std::same_as<
decltype(ops), o2::aod::PointsSelfIndex>;
912 if (
i == withSlices[
c1]) {
913 auto it = ops.begin();
914 REQUIRE(ops.size() == bounds[
c1].second - bounds[
c1].first + 1);
915 REQUIRE(it.globalIndex() == bounds[
c1].first);
916 for (
auto j = 1;
j < ops.size(); ++
j) {
919 REQUIRE(it.globalIndex() == bounds[
c1].second);
922 REQUIRE(ops.size() == 0);
925 auto opss = p.pointSet_as<o2::aod::PointsSelfIndex>();
926 auto bbba = std::same_as<
decltype(opss), std::vector<o2::aod::PointsSelfIndex::iterator>>;
929 auto opss_ids = p.pointSetIds();
930 if (
c2 < withSets.size() &&
i == withSets[
c2]) {
931 REQUIRE(opss.size() ==
sizes[
c2]);
932 REQUIRE(opss.begin()->globalIndex() ==
i + 1);
933 REQUIRE(opss.back().globalIndex() ==
i +
sizes[
c2]);
935 for (
auto&
id : opss_ids) {
936 REQUIRE(
id ==
i + 1 + c3);
941 REQUIRE(opss.size() == 0);
949DECLARE_SOA_TABLE(PointsSelfRef,
"TEST",
"PTSSR", test::OtherPointId, test::PointSeqIdSlice, test::PointSetIds);
955 auto pswriter = b3.
cursor<o2::aod::PointsSelfIndex>();
956 int references[] = {19, 2, 0, 13, 4, 6, 5, 5, 11, 9, 3, 8, 16, 14, 1, 18, 12, 18, 2, 7};
957 int slice[2] = {-1, -1};
958 std::vector<int> pset;
959 std::array<int, 4> withSlices = {3, 6, 13, 19};
960 std::array<std::pair<int, int>, 4> bounds = {std::pair{1, 5}, std::pair{3, 3}, std::pair{11, 11}, std::pair{10, 18}};
961 std::array<int, 4> withSets = {0, 1, 13, 14};
962 unsigned int sizes[] = {3, 1, 5, 4};
965 for (
auto i = 0;
i < 20; ++
i) {
969 if (
c1 < withSlices.size() &&
i == withSlices[
c1]) {
970 slice[0] = bounds[
c1].first;
971 slice[1] = bounds[
c1].second;
974 if (
c2 < withSets.size() &&
i == withSets[
c2]) {
976 pset.push_back(
i + 1 +
z);
980 pswriter(0, -1 *
i, 0.5 *
i, 2 *
i, references[
i], slice, pset);
983 auto pst = o2::aod::PointsSelfIndex{t3};
984 pst.bindInternalIndicesTo(&pst);
987 for (
auto& p : pst) {
988 auto ops = p.pointSeq_as<o2::aod::PointsSelfIndex>();
989 for (
auto& pp : ops) {
990 auto bpp = std::same_as<std::decay_t<
decltype(pp)>, o2::aod::PointsSelfIndex::iterator>;
992 auto opps = pp.pointSeq_as<o2::aod::PointsSelfIndex>();
993 for (
auto& ppp : opps) {
994 auto bppp = std::same_as<std::decay_t<
decltype(ppp)>, o2::aod::PointsSelfIndex::iterator>;
996 auto oppps = ppp.pointSeq_as<o2::aod::PointsSelfIndex>();
997 for (
auto& pppp : oppps) {
998 auto bpppp = std::same_as<std::decay_t<
decltype(pppp)>, o2::aod::PointsSelfIndex::iterator>;
1000 auto opppps = pppp.pointSeq_as<o2::aod::PointsSelfIndex>();
1008 auto corewriter =
b.
cursor<o2::aod::Points3Ds>();
1009 for (
auto i = 0;
i < 20; ++
i) {
1010 corewriter(0, -1 *
i, 0.5 *
i, 2 *
i);
1012 auto t1 =
b.finalize();
1017 auto extwriter = be.
cursor<o2::aod::PointsSelfRef>();
1018 for (
auto i = 0;
i < 20; ++
i) {
1022 if (
c1 < withSlices.size() &&
i == withSlices[
c1]) {
1023 slice[0] = bounds[
c1].first;
1024 slice[1] = bounds[
c1].second;
1027 if (
c2 < withSets.size() &&
i == withSets[
c2]) {
1029 pset.push_back(
i + 1 +
z);
1033 extwriter(0, references[
i], slice, pset);
1037 FullPoints fp({
t1, t2});
1038 fp.bindInternalIndicesTo(&fp);
1042 for (
auto& p : fp) {
1043 REQUIRE(std::same_as<std::decay_t<
decltype(p)>, FullPoints::iterator>);
1044 auto ops = p.pointSeq_as<FullPoints>();
1045 for (
auto& pp : ops) {
1046 REQUIRE(std::same_as<std::decay_t<
decltype(pp)>, FullPoints::iterator>);
1047 auto opps = pp.pointSeq_as<FullPoints>();
1048 for (
auto& ppp : opps) {
1049 REQUIRE(std::same_as<std::decay_t<
decltype(ppp)>, FullPoints::iterator>);
1050 auto oppps = ppp.pointSeq_as<FullPoints>();
1051 for (
auto& pppp : oppps) {
1052 REQUIRE(std::same_as<std::decay_t<
decltype(pppp)>, FullPoints::iterator>);
1053 auto opppps = pppp.pointSeq_as<FullPoints>();
1059 auto const& fpa = fp;
1062 for (
auto& it1 : fpa) {
1063 [[maybe_unused]]
auto it2 = fpa.rawIteratorAt(0);
1064 [[maybe_unused]]
auto it3 = fpa.iteratorAt(0);
1065 auto bit1 = std::same_as<std::decay_t<
decltype(it1)>, std::decay_t<
decltype(it2)>>;
1067 auto bit2 = std::same_as<std::decay_t<
decltype(it1)>, std::decay_t<
decltype(it3)>>;
1072 FilteredPoints ffp({
t1, t2}, {1, 2, 3}, 0);
1076 for (
auto& p : ffp) {
1077 REQUIRE(std::same_as<std::decay_t<
decltype(p)>, FilteredPoints::iterator>);
1078 REQUIRE(std::same_as<std::decay_t<
decltype(p)>::parent_t, FilteredPoints>);
1079 auto ops = p.pointSeq_as<
typename std::decay_t<
decltype(p)>::parent_t>();
1080 for (
auto& pp : ops) {
1081 REQUIRE(std::same_as<std::decay_t<
decltype(pp)>::parent_t, FilteredPoints>);
1082 auto opps = pp.pointSeq_as<FilteredPoints>();
1083 for (
auto& ppp : opps) {
1084 REQUIRE(std::same_as<std::decay_t<
decltype(ppp)>, FilteredPoints::iterator>);
1085 auto oppps = ppp.pointSeq_as<FilteredPoints>();
1086 for (
auto& pppp : oppps) {
1087 REQUIRE(std::same_as<std::decay_t<
decltype(pppp)>, FilteredPoints::iterator>);
1088 auto opppps = pppp.pointSeq_as<FilteredPoints>();
1094 auto const& ffpa = ffp;
1097 for (
auto& it1 : ffpa) {
1098 [[maybe_unused]]
auto it2 = ffpa.rawIteratorAt(0);
1099 [[maybe_unused]]
auto it3 = ffpa.iteratorAt(0);
1100 using T1 = std::decay_t<
decltype(it1)>;
1101 using T2 = std::decay_t<
decltype(it2)>;
1102 using T3 = std::decay_t<
decltype(it3)>;
1103 auto bit1 = !std::same_as<T1, T2>;
1105 auto bit2 = !std::same_as<T1, T3>;
1107 auto bit3 = std::same_as<typename T1::policy_t, typename T3::policy_t>;
1109 auto bit4 = std::same_as<typename T1::policy_t, o2::soa::FilteredIndexPolicy>;
1111 auto bit5 = std::same_as<typename T2::policy_t, o2::soa::DefaultIndexPolicy>;
1119 auto writer =
b.
cursor<o2::aod::Lists>();
1120 std::vector<float> floats;
1121 std::vector<int> ints;
1122 for (
auto i = 1;
i < 11; ++
i) {
1125 for (
auto j = 0;
j <
i; ++
j) {
1126 floats.push_back(0.1231233f * (
float)
j + 0.1982798f);
1127 ints.push_back(
j + 10);
1130 writer(0, floats, ints);
1132 auto lt =
b.finalize();
1133 o2::aod::Lists tbl{lt};
1135 for (
auto&
row : tbl) {
1138 auto constexpr bf = std::same_as<
decltype(
f), gsl::span<
const float, (
size_t)-1>>;
1139 auto constexpr bi = std::same_as<
decltype(
i), gsl::span<
const int, (
size_t)-1>>;
1142 REQUIRE(
f.size() == s);
1143 REQUIRE(
i.size() == s);
1145 for (
auto j = 0u;
j <
f.size(); ++
j) {
1146 REQUIRE(
f[
j] == 0.1231233f * (
float)
j + 0.1982798f);
1147 REQUIRE(
i[
j] == (
int)
j + 10);
1156 auto writer =
b.
cursor<o2::aod::Origints>();
1157 for (
auto i = 0;
i < 20; ++
i) {
1158 writer(0,
i,
i % 3 == 0);
1160 auto origins =
b.finalize();
1161 o2::aod::Origints
o{origins};
1164 auto writer_w =
w.
cursor<o2::aod::References>();
1166 for (
auto i = 0;
i < 5 * 20; ++
i) {
1172 auto refs =
w.finalize();
1173 o2::aod::References
r{refs};
1176 auto s = atscache.updateCacheEntry(0, refs);
1179 for (
auto& oi :
o) {
1180 auto cachedSlice =
r.sliceByCached(o2::aod::test::origintId, oi.globalIndex(), cache);
1181 REQUIRE(cachedSlice.size() == 5);
1182 for (
auto& ri : cachedSlice) {
1183 REQUIRE(ri.origintId() == oi.globalIndex());
1191 auto writer =
b.
cursor<o2::aod::Origints>();
1192 for (
auto i = 0;
i < 20; ++
i) {
1193 writer(0,
i,
i % 3 == 0);
1195 auto origins =
b.finalize();
1196 o2::aod::Origints
o{origins};
1199 auto writer_w =
w.
cursor<o2::aod::References>();
1201 for (
auto i = 0;
i < 5 * 20; ++
i) {
1207 auto refs =
w.finalize();
1208 o2::aod::References
r{refs};
1211 auto writer_w2 = w2.
cursor<o2::aod::OtherReferences>();
1213 for (
auto i = 0;
i < 5 * 20; ++
i) {
1220 o2::aod::OtherReferences r2{refs2};
1223 J
rr{{refs, refs2}};
1227 auto s = atscache.updateCacheEntry(0, refs2);
1230 for (
auto& oi :
o) {
1231 auto cachedSlice =
rr.sliceByCached(o2::aod::test::altOrigintId, oi.globalIndex(), cache);
1232 REQUIRE(cachedSlice.size() == 3);
1233 for (
auto& ri : cachedSlice) {
1234 REQUIRE(ri.altOrigintId() == oi.globalIndex());
1242 auto prwriter =
b.
cursor<o2::aod::PointsRefF>();
1243 auto a = std::array{0, 1};
1244 auto aa = std::vector{2, 3, 4};
1245 prwriter(0, 0, &
a[0], aa);
1248 prwriter(0, 1, &
a[0], aa);
1249 auto t =
b.finalize();
1250 auto prt = o2::aod::PointsRefF{t};
1252 for (
auto&
row : prt) {
1254 [[maybe_unused]]
auto sp =
row.singlePoint();
1256 REQUIRE(std::string{
error_from_ref(
ref).
what} ==
"Index pointing to Points3Ds is not bound! Did you subscribe to the table?");
1259 auto ps =
row.pointSlice();
1261 REQUIRE(std::string{
error_from_ref(
ref).
what} ==
"Index pointing to Points3Ds is not bound! Did you subscribe to the table?");
1264 auto pg =
row.pointGroup();
1266 REQUIRE(std::string{
error_from_ref(
ref).
what} ==
"Index pointing to Points3Ds is not bound! Did you subscribe to the table?");
1285 auto writer =
b.
cursor<o2::aod::BILists>();
1288 for (
auto i = 0;
i < 20; ++
i) {
1290 for (
auto j = 0;
j < 32; ++
j) {
1298 auto t =
b.finalize();
1300 o2::aod::BILists li{t};
1301 for (
auto const&
row : li) {
1302 auto iir =
row.smallIntArray();
1303 [[maybe_unused]]
auto bbrr =
row.boolArray_raw();
1304 REQUIRE(std::same_as<std::decay_t<
decltype(iir)>, int8_t
const*>);
1305 for (
auto i = 0;
i < 32; ++
i) {
1306 REQUIRE(iir[
i] ==
i);
1307 REQUIRE(
row.boolArray_bit(
i) == (
i % 2 == 0));
1324 table::One, table::Two, table::Three, table::Four,
1325 table::Five<table::Four>);
1331 auto writer =
b.
cursor<o2::aod::MixTest>();
1333 for (
auto i = 0;
i < 20; ++
i) {
1338 auto t =
b.finalize();
1339 o2::aod::MixTest mt{t};
1341 for (
auto const&
row : mt) {
1342 auto features1 =
row.getValues<float, o2::aod::table::One, o2::aod::table::Three>();
1343 auto features2 =
row.getValues<double, o2::aod::table::One, o2::aod::table::Two, o2::aod::table::Three>();
1344 auto features3 =
row.getValues<float, o2::aod::table::Two, o2::aod::table::Five<o2::aod::table::Four>>();
1345 auto b1 = std::same_as<std::array<float, 2>,
decltype(features1)>;
1347 auto b2 = std::same_as<std::array<double, 3>,
decltype(features2)>;
1349 auto b3 = std::same_as<std::array<float, 2>,
decltype(features3)>;
1351 REQUIRE(features1[0] == (
float)
count);
1354 REQUIRE(features2[0] == (
double)
count);
1359 REQUIRE(features3[1] == (
float)((
float)
count / (
float)(
count + 1)));
#define DECLARE_SOA_ARRAY_INDEX_COLUMN(_Name_, _Getter_)
#define DECLARE_SOA_SLICE_INDEX_COLUMN(_Name_, _Getter_)
#define DECLARE_SOA_DYNAMIC_COLUMN(_Name_, _Getter_,...)
#define DECLARE_SOA_SELF_INDEX_COLUMN(_Name_, _Getter_)
#define DECLARE_SOA_TABLE(_Name_, _Origin_, _Desc_,...)
#define DECLARE_SOA_EXPRESSION_COLUMN(_Name_, _Getter_, _Type_, _Expression_)
#define DECLARE_SOA_COLUMN(_Name_, _Getter_, _Type_)
#define DECLARE_SOA_INDEX_COLUMN_FULL(_Name_, _Getter_, _Type_, _Table_, _Suffix_)
#define DECLARE_SOA_SELF_SLICE_INDEX_COLUMN(_Name_, _Getter_)
#define DECLARE_SOA_COLUMN_FULL(_Name_, _Getter_, _Type_, _Label_)
#define DECLARE_SOA_TABLE_VERSIONED(_Name_, _Origin_, _Desc_, _Version_,...)
#define DECLARE_SOA_INDEX_COLUMN(_Name_, _Getter_)
#define DECLARE_SOA_BITMAP_COLUMN(_Name_, _Getter_, _Size_)
#define DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN(_Name_, _Getter_)
const GPUTPCGMMerger::trackCluster & b1
bool const GPUTPCGMMerger::trackCluster * c1
bool const GPUTPCGMMerger::trackCluster const clcomparestruct * c2
std::shared_ptr< T > get(const HistName &histName)
auto persist(std::array< char const *, sizeof...(ARGS)+1 > const &columnNames)
std::shared_ptr< arrow::Table > finalize()
void bindInternalIndicesTo(I const *ptr)
unfiltered_iterator begin()
float sum(float s, o2::dcs::DataPointValue v)
GLuint GLsizei const GLuint const GLintptr const GLsizeiptr * sizes
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat s1
GLboolean GLboolean GLboolean b
GLsizei const GLfloat * value
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
GLboolean GLboolean GLboolean GLboolean a
GLubyte GLubyte GLubyte GLubyte w
GLdouble GLdouble GLdouble z
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t1
std::shared_ptr< gandiva::SelectionVector > Selection
gandiva::Selection createSelection(std::shared_ptr< arrow::Table > const &table, Filter const &expression)
Function for creating gandiva selection from our internal filter tree.
Defining PrimaryVertex explicitly as messageable.
RuntimeError & error_from_ref(RuntimeErrorRef)
std::string cutString(std::string &&str)
auto createFieldsFromColumns(framework::pack< C... >)
constexpr auto join(Ts const &... t)
FIXME: do not use data model tables.
char what[MAX_RUNTIME_ERROR_SIZE]
A struct, containing the root of the expression tree.