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>
63DECLARE_SOA_TABLE(Segments,
"TEST",
"SEGMENTS", test::N, test::PointAId, test::PointBId, test::InfoId);
78 auto pwriter =
b1.
cursor<o2::aod::Points3Ds>();
79 for (
auto i = 0;
i < 20; ++
i) {
80 pwriter(0, -1 *
i, (
int)(
i / 2), 2 *
i);
82 auto t1 =
b1.finalize();
84 auto pt = o2::aod::Points3Ds{
t1};
85 auto pt1 = o2::aod::Points3DMk1s{
t1};
86 auto pt2 = o2::aod::Points3DMk2s{
t1};
87 auto pt3 = o2::aod::Points3DMk3s{
t1};
88 REQUIRE(pt1.begin().mark() == (
size_t)1);
89 REQUIRE(pt2.begin().mark() == (
size_t)2);
90 REQUIRE(pt3.begin().mark() == (
size_t)3);
96 auto rowWriter = builder.
persist<int32_t, int32_t>({
"fX",
"fY"});
109 i.mCurrentPos = &
pos;
126 arrow::ChunkedArray* chunks[2] = {
127 table->column(0).get(),
128 table->column(1).get()};
129 o2::aod::Points::iterator tests(chunks, {table->num_rows(), 0});
130 REQUIRE(tests.x() == 0);
131 REQUIRE(tests.y() == 0);
133 REQUIRE(tests.x() == 0);
134 REQUIRE(tests.y() == 1);
139 auto e = tests2.end();
153 REQUIRE(((
b + 1) == (
b + 1)));
154 REQUIRE(((
b + 7) !=
b));
155 REQUIRE(((
b + 7) != e));
156 REQUIRE(((
b + 8) == e));
158 for (
auto& t : tests2) {
159 REQUIRE(t.x() ==
value / 4);
160 REQUIRE((
size_t)t.y() ==
value);
165 for (
auto t1 = tests2.begin();
t1 != tests2.end(); ++
t1) {
166 for (
auto t2 =
t1 + 1; t2 != tests2.end(); ++t2) {
174 auto rowWriter = builder.
persist<int32_t, int32_t>({
"fX",
"fY"});
185 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>>;
188 for (
auto&
test : tests1) {
192 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>>;
195 for (
auto&
test : tests2) {
203 auto rowWriter = builder.
persist<int32_t, int32_t>({
"fX",
"fY"});
217 foo.mCurrentPos = &index1;
219 bar.mCurrentPos = &index2;
220 REQUIRE(
foo.mCurrent == bar.mCurrent);
221 REQUIRE(
foo.mLast == bar.mLast);
222 REQUIRE(
foo.mColumn == bar.mColumn);
223 REQUIRE(
foo.mFirstIndex == bar.mFirstIndex);
224 REQUIRE(
foo.mCurrentChunk == bar.mCurrentChunk);
226 auto foobar = std::move(
foo);
227 REQUIRE(foobar.mCurrent == bar.mCurrent);
228 REQUIRE(foobar.mLast == bar.mLast);
229 REQUIRE(foobar.mColumn == bar.mColumn);
230 REQUIRE(foobar.mFirstIndex == bar.mFirstIndex);
231 REQUIRE(foobar.mCurrentChunk == bar.mCurrentChunk);
237 auto rowWriterX = builderX.
persist<int32_t>({
"fX"});
249 auto rowWriterY = builderY.
persist<int32_t>({
"fY"});
261 auto rowWriterZ = builderZ.
persist<int32_t>({
"fZ"});
273 auto rowWriterW = builderW.
persist<int32_t>({
"fW"});
285 REQUIRE(Test::contains<TestX>());
286 REQUIRE(Test::contains<TestY>());
287 REQUIRE(!Test::contains<TestZ>());
289 Test tests{{tableX, tableY}, 0};
291 REQUIRE(tests.contains<TestX>());
292 REQUIRE(tests.contains<TestY>());
293 REQUIRE(!tests.contains<TestZ>());
295 for (
auto&
test : tests) {
299 auto tests2 =
join(TestX{tableX}, TestY{tableY});
300 static_assert(std::same_as<Test::self_t,
decltype(tests2)>,
"Joined tables should have the same type, regardless how we construct them");
301 for (
auto&
test : tests2) {
305 auto tests3 =
join(TestX{tableX}, TestY{tableY}, TestZ{tableZ});
307 for (
auto&
test : tests3) {
311 TestMoreThanTwo tests4{{tableX, tableY, tableZ}, 0};
312 for (
auto&
test : tests4) {
317 auto testF =
join(TestZ{tableZ}, TestW{tableW});
319 REQUIRE(std::string{
error_from_ref(
ref).
what} ==
"Tables TEST and TEST have different sizes (8 vs 3) and cannot be joined!");
326 auto rowWriterA = builderA.
persist<int32_t, int32_t>({
"fX",
"fY"});
336 REQUIRE(tableA->num_rows() == 8);
339 auto rowWriterB = builderB.
persist<int32_t>({
"fX"});
351 auto rowWriterC = builderC.
persist<int32_t>({
"fZ"});
363 auto rowWriterD = builderD.
persist<int32_t, int32_t>({
"fX",
"fZ"});
364 rowWriterD(0, 16, 8);
365 rowWriterD(0, 17, 9);
366 rowWriterD(0, 18, 10);
367 rowWriterD(0, 19, 11);
368 rowWriterD(0, 20, 12);
369 rowWriterD(0, 21, 13);
370 rowWriterD(0, 22, 14);
371 rowWriterD(0, 23, 15);
383 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");
385 static_assert(std::same_as<ConcatTest::columns_t, o2::framework::pack<o2::soa::Index<>, o2::aod::test::X>>,
"Bad intersection of columns");
386 ConcatTest tests{tableA, tableB};
387 REQUIRE(16 == tests.size());
388 for (
auto&
test : tests) {
392 static_assert(std::same_as<NestedConcatTest::columns_t, o2::framework::pack<o2::aod::test::X>>,
"Bad nested concat");
399 auto status = gandiva::SelectionVector::MakeInt64(tests.size(), arrow::default_memory_pool(), &selection);
400 REQUIRE(status.ok());
402 auto fptr = tableA->schema()->GetFieldByName(
"fX");
403 REQUIRE(fptr !=
nullptr);
404 REQUIRE(fptr->name() ==
"fX");
405 REQUIRE(fptr->type()->id() == arrow::Type::INT32);
407 auto node_x = gandiva::TreeExprBuilder::MakeField(fptr);
408 auto literal_1 = gandiva::TreeExprBuilder::MakeLiteral(
static_cast<int32_t
>(1));
409 auto literal_3 = gandiva::TreeExprBuilder::MakeLiteral(
static_cast<int32_t
>(3));
410 auto equals_to_1 = gandiva::TreeExprBuilder::MakeFunction(
"equal", {node_x, literal_1}, arrow::boolean());
411 auto equals_to_3 = gandiva::TreeExprBuilder::MakeFunction(
"equal", {node_x, literal_3}, arrow::boolean());
412 auto node_or = gandiva::TreeExprBuilder::MakeOr({equals_to_1, equals_to_3});
413 auto condition = gandiva::TreeExprBuilder::MakeCondition(node_or);
414 REQUIRE(condition->ToString() ==
"bool equal((int32) fX, (const int32) 1) || bool equal((int32) fX, (const int32) 3)");
415 std::shared_ptr<gandiva::Filter>
filter;
416 status = gandiva::Filter::Make(tableA->schema(), condition, &
filter);
417 REQUIRE(status.ToString() ==
"OK");
419 arrow::TableBatchReader reader(*tableA);
420 std::shared_ptr<RecordBatch> batch;
421 auto s = reader.ReadNext(&batch);
423 REQUIRE(batch !=
nullptr);
424 REQUIRE(batch->num_rows() == 8);
425 auto st =
filter->Evaluate(*batch, selection);
426 REQUIRE(
st.ToString() ==
"OK");
431 FilteredTest filtered{{testA.asArrowTable()}, selection_f};
432 REQUIRE(2 == filtered.size());
435 REQUIRE(filtered.begin() != filtered.end());
436 for (
auto&
f : filtered) {
437 REQUIRE(
i * 2 + 1 ==
f.x());
438 REQUIRE(
i * 2 + 1 ==
f.index());
447 status = gandiva::SelectionVector::MakeInt64(tests.size(), arrow::default_memory_pool(), &selectionConcat);
448 REQUIRE(status.ok() ==
true);
449 selectionConcat->SetIndex(0, 0);
450 selectionConcat->SetIndex(1, 5);
451 selectionConcat->SetIndex(2, 10);
452 selectionConcat->SetNumSlots(3);
453 ConcatTest concatTest{tableA, tableB};
454 FilteredConcatTest concatTestTable{{concatTest.asArrowTable()}, selectionConcat};
455 REQUIRE(3 == concatTestTable.size());
458 auto b = concatTestTable.begin();
459 auto e = concatTestTable.end();
461 REQUIRE(
b.mRowIndex == 0);
462 REQUIRE(
b.getSelectionRow() == 0);
463 REQUIRE(e.index == 3);
465 REQUIRE(concatTestTable.begin() != concatTestTable.end());
466 for (
auto&
f : concatTestTable) {
467 REQUIRE(
i * 5 ==
f.x());
468 REQUIRE(
i * 5 ==
f.index());
469 REQUIRE(
i ==
f.filteredIndex());
477 status = gandiva::SelectionVector::MakeInt64(tests.size(), arrow::default_memory_pool(), &selectionJoin);
478 REQUIRE(status.ok() ==
true);
479 selectionJoin->SetIndex(0, 0);
480 selectionJoin->SetIndex(1, 2);
481 selectionJoin->SetIndex(2, 4);
482 selectionJoin->SetNumSlots(3);
483 JoinedTest testJoin{{tableA, tableC}, 0};
484 FilteredJoinTest filteredJoin{{testJoin.asArrowTable()}, selectionJoin};
487 REQUIRE(filteredJoin.begin() != filteredJoin.end());
488 for (
auto&
f : filteredJoin) {
489 REQUIRE(
i * 2 ==
f.x());
490 REQUIRE(
i * 2 ==
f.index());
499 auto pointsWriter = builderA.
cursor<o2::aod::Points>();
500 pointsWriter(0, 0, 0);
501 pointsWriter(0, 3, 4);
503 o2::aod::Points points{pointsT};
504 REQUIRE(pointsT->num_rows() == 2);
507 auto infoWriter = builderA2.
cursor<o2::aod::Infos>();
508 infoWriter(0, 0,
true);
509 infoWriter(0, 1,
false);
510 infoWriter(0, 4,
true);
512 o2::aod::Infos infos{infosT};
513 REQUIRE(infos.begin().someBool() ==
true);
514 REQUIRE((infos.begin() + 1).someBool() ==
false);
515 REQUIRE((infos.begin() + 2).someBool() ==
true);
516 REQUIRE((infos.begin() + 2).color() == 4);
517 REQUIRE(infosT->num_rows() == 3);
520 auto segmentsWriter = builderB.
cursor<o2::aod::Segments>();
521 segmentsWriter(0, 10, 0, 1, 2);
522 auto segmentsT = builderB.
finalize();
523 o2::aod::Segments
segments{segmentsT};
524 REQUIRE(segmentsT->num_rows() == 1);
527 auto segmentsExtraWriter = builderC.
cursor<o2::aod::SegmentsExtras>();
528 segmentsExtraWriter(0, 1);
529 auto segmentsExtraT = builderC.
finalize();
530 o2::aod::SegmentsExtras segmentsExtras{segmentsExtraT};
531 REQUIRE(segmentsExtraT->num_rows() == 1);
533 REQUIRE(
segments.begin().pointAId() == 0);
534 REQUIRE(
segments.begin().pointBId() == 1);
535 static_assert(std::same_as<
decltype(
segments.begin().pointA()), o2::aod::Points::iterator>);
538 i.bindExternalIndices(&points, &infos);
539 REQUIRE(
i.n() == 10);
540 REQUIRE(
i.info().color() == 4);
541 REQUIRE(
i.info().someBool() ==
true);
542 REQUIRE(
i.pointA().x() == 0);
543 REQUIRE(
i.pointA().y() == 0);
544 REQUIRE(
i.pointB().x() == 3);
545 REQUIRE(
i.pointB().y() == 4);
547 segments.bindExternalIndices(&points, &infos);
549 REQUIRE(
j.n() == 10);
550 REQUIRE(
j.info().color() == 4);
551 REQUIRE(
j.info().someBool() ==
true);
552 REQUIRE(
j.pointA().x() == 0);
553 REQUIRE(
j.pointA().y() == 0);
554 REQUIRE(
j.pointB().x() == 3);
555 REQUIRE(
j.pointB().y() == 4);
558 joined.bindExternalIndices(&points, &infos);
559 auto se = joined.begin();
560 REQUIRE(se.n() == 10);
561 REQUIRE(se.info().color() == 4);
562 REQUIRE(se.pointA().x() == 0);
563 REQUIRE(se.pointA().y() == 0);
564 REQUIRE(se.pointB().x() == 3);
565 REQUIRE(se.pointB().y() == 4);
566 REQUIRE(se.thickness() == 1);
571 auto schema = std::make_shared<arrow::Schema>(
createFieldsFromColumns(o2::aod::Points::persistent_columns_t{}));
572 REQUIRE(schema->num_fields() == 2);
573 REQUIRE(schema->field(0)->name() ==
"fX");
574 REQUIRE(schema->field(1)->name() ==
"fY");
580 auto rowWriterA = builderA.
persist<int32_t, int32_t>({
"fX",
"fY"});
583 rowWriterA(0, 2, 10);
584 rowWriterA(0, 3, 11);
585 rowWriterA(0, 4, 12);
586 rowWriterA(0, 5, 13);
587 rowWriterA(0, 6, 14);
588 rowWriterA(0, 7, 15);
590 REQUIRE(tableA->num_rows() == 8);
601 FilteredTest filtered1{{testA.asArrowTable()},
s1};
602 REQUIRE(4 == filtered1.size());
603 REQUIRE(filtered1.begin() != filtered1.end());
606 FilteredTest filtered2{{testA.asArrowTable()}, s2};
607 REQUIRE(2 == filtered2.size());
608 REQUIRE(filtered2.begin() != filtered2.end());
610 FilteredTest filteredUnion = filtered1 + filtered2;
611 REQUIRE(6 == filteredUnion.size());
613 std::vector<std::tuple<int32_t, int32_t>> expectedUnion{{0, 8}, {1, 9}, {2, 10}, {3, 11}, {6, 14}, {7, 15}};
615 for (
auto&
f : filteredUnion) {
616 REQUIRE(std::get<0>(expectedUnion[
i]) ==
f.x());
617 REQUIRE(std::get<1>(expectedUnion[
i]) ==
f.y());
618 REQUIRE(std::get<0>(expectedUnion[
i]) ==
f.index());
623 FilteredTest filteredIntersection = filtered1 * filtered2;
624 REQUIRE(0 == filteredIntersection.size());
627 for (
auto const& _ : filteredIntersection) {
634 FilteredTest filtered3{{testA.asArrowTable()}, s3};
635 REQUIRE(3 == filtered3.size());
636 REQUIRE(filtered3.begin() != filtered3.end());
638 FilteredTest unionIntersection = (filtered1 + filtered2) * filtered3;
639 REQUIRE(3 == unionIntersection.size());
642 for (
auto&
f : unionIntersection) {
644 REQUIRE(
i + 8 ==
f.y());
645 REQUIRE(
i ==
f.index());
654 auto rowWriterA = builderA.
persist<int32_t, int32_t>({
"fX",
"fY"});
657 rowWriterA(0, 2, 10);
658 rowWriterA(0, 3, 11);
659 rowWriterA(0, 4, 12);
660 rowWriterA(0, 5, 13);
661 rowWriterA(0, 6, 14);
662 rowWriterA(0, 7, 15);
664 REQUIRE(tableA->num_rows() == 8);
678 FilteredTest filtered{{testA.asArrowTable()},
s1};
679 REQUIRE(4 == filtered.size());
680 REQUIRE(filtered.begin() != filtered.end());
683 NestedFilteredTest nestedFiltered{{filtered}, s2};
684 REQUIRE(2 == nestedFiltered.size());
686 for (
auto&
f : nestedFiltered) {
687 REQUIRE(
i + 2 ==
f.x());
688 REQUIRE(
i + 10 ==
f.y());
689 REQUIRE(
i + 2 ==
f.index());
695 TripleNestedFilteredTest tripleFiltered{{nestedFiltered}, s3};
696 REQUIRE(1 == tripleFiltered.size());
698 for (
auto&
f : tripleFiltered) {
699 REQUIRE(
i + 2 ==
f.x());
700 REQUIRE(
i + 10 ==
f.y());
701 REQUIRE(
i + 2 ==
f.index());
710 [[maybe_unused]]
auto pwriter = bPoints.
cursor<o2::aod::Points>();
714 [[maybe_unused]]
auto iwriter = bInfos.
cursor<o2::aod::Infos>();
717 o2::aod::Points p{pempty};
718 o2::aod::Infos
i{iempty};
721 PI pi{{pempty, iempty}, 0};
722 REQUIRE(pi.size() == 0);
723 auto spawned = Extend<o2::aod::Points, o2::aod::test::ESum>(p);
724 REQUIRE(spawned.size() == 0);
745 auto writer =
b.
cursor<o2::aod::Origints>();
746 for (
auto i = 0;
i < 20; ++
i) {
747 writer(0,
i,
i % 3 == 0);
749 auto origins =
b.finalize();
750 o2::aod::Origints
o{origins};
753 auto writer_z =
z.
cursor<o2::aod::ManyReferences>();
754 std::vector<int>
ids;
755 for (
auto i = 0;
i < 5; ++
i) {
757 for (
auto j = 0;
j < 20; ++
j) {
762 auto mrefs =
z.finalize();
763 o2::aod::ManyReferences
m{mrefs};
766 auto writer_w =
w.
cursor<o2::aod::References>();
767 for (
auto i = 0;
i < 5 * 20; ++
i) {
770 auto refs =
w.finalize();
771 o2::aod::References
r{refs};
775 Flt
f{{
o.asArrowTable()}, selection};
776 r.bindExternalIndices(&
f);
779 REQUIRE(it.origint_as<Flt>().globalIndex() == 3);
781 REQUIRE(it.origint_as<Flt>().globalIndex() == 4);
783 REQUIRE(it.origint_as<Flt>().globalIndex() == 5);
785 m.bindExternalIndices(&
f);
786 for (
auto const&
row :
m) {
787 auto os =
row.origints_as<Flt>();
788 auto fos =
row.filtered_origints_as<Flt>();
789 REQUIRE(os.size() == 20);
790 REQUIRE(fos.size() == 6);
806DECLARE_SOA_TABLE(PointsRefF,
"TEST",
"PTSREFF", test::SinglePointId, test::Points3DIdSlice, test::Points3DIds);
808 test::PointSeqIdSlice, test::PointSetIds);
815 for (
auto i = 0;
i < 20; ++
i) {
816 pwriter(0, -1 *
i, (
int)(
i / 2), 2 *
i);
818 auto tpts1 =
b1.finalize();
821 auto prwriter = b2.
cursor<o2::aod::PointsRef>();
822 auto a = std::array{0, 1};
823 auto aa = std::vector{2, 3, 4};
824 prwriter(0, &
a[0], aa);
827 prwriter(0, &
a[0], aa);
830 auto pt = o2::aod::Points3Ds{tpts1};
831 auto prt = o2::aod::PointsRef{t2};
832 prt.bindExternalIndices(&pt);
834 auto it = prt.begin();
835 auto s1 = it.pointSlice();
836 auto g1 = it.pointGroup();
837 auto bb = std::same_as<
decltype(
s1), o2::aod::Points3Ds>;
839 REQUIRE(
s1.size() == 2);
841 for (
int i = 0;
i < 3; ++
i) {
842 REQUIRE(g1[
i].globalIndex() == aa[
i]);
847 for (
auto& p : it.pointGroup_as<o2::aod::Points3Ds>()) {
848 REQUIRE(p.x() == -1 * p.globalIndex());
852 auto s2 = it.pointSlice();
853 auto g2 = it.pointGroup();
854 REQUIRE(s2.size() == 7);
856 for (
int i = 0;
i < 3; ++
i) {
857 REQUIRE(g2[
i].globalIndex() == aa[
i]);
863 prt.bindExternalIndices(&
f);
865 auto it2 = prt.begin();
866 auto s1f = it2.pointSlice_as<Flt>();
867 auto g1f = it2.pointGroup_as<Flt>();
868 REQUIRE(s1f.size() == 2);
870 for (
int i = 0;
i < 3; ++
i) {
871 REQUIRE(g1f[
i].globalIndex() == aa[
i]);
875 auto s2f = it2.pointSlice_as<Flt>();
876 auto g2f = it2.pointGroup_as<Flt>();
877 REQUIRE(s2f.size() == 7);
879 for (
int i = 0;
i < 3; ++
i) {
880 REQUIRE(g2f[
i].globalIndex() == aa[
i]);
884 auto pswriter = b3.
cursor<o2::aod::PointsSelfIndex>();
885 int references[] = {19, 2, 0, 13, 4, 6, 5, 5, 11, 9, 3, 8, 16, 14, 1, 18, 12, 18, 2, 7};
886 int slice[2] = {-1, -1};
887 std::vector<int> pset;
888 std::array<int, 4> withSlices = {3, 6, 13, 19};
889 std::array<std::pair<int, int>, 4> bounds = {std::pair{1, 5}, std::pair{3, 3}, std::pair{11, 11}, std::pair{10, 18}};
890 std::array<int, 4> withSets = {0, 1, 13, 14};
891 unsigned int sizes[] = {3, 1, 5, 4};
894 for (
auto i = 0;
i < 20; ++
i) {
898 if (
c1 < withSlices.size() &&
i == withSlices[
c1]) {
899 slice[0] = bounds[
c1].first;
900 slice[1] = bounds[
c1].second;
903 if (
c2 < withSets.size() &&
i == withSets[
c2]) {
905 pset.push_back(
i + 1 +
z);
909 pswriter(0, -1 *
i, 0.5 *
i, 2 *
i, references[
i], slice, pset);
912 auto pst = o2::aod::PointsSelfIndex{t3};
913 pst.bindInternalIndicesTo(&pst);
917 for (
auto& p : pst) {
918 auto op = p.otherPoint_as<o2::aod::PointsSelfIndex>();
919 auto bbb = std::same_as<
decltype(
op), o2::aod::PointsSelfIndex::iterator>;
921 REQUIRE(
op.globalIndex() == references[
i]);
923 auto ops = p.pointSeq_as<o2::aod::PointsSelfIndex>();
924 auto bbbs = std::same_as<
decltype(ops), o2::aod::PointsSelfIndex>;
927 if (
i == withSlices[
c1]) {
928 auto it = ops.begin();
929 REQUIRE(ops.size() == bounds[
c1].second - bounds[
c1].first + 1);
930 REQUIRE(it.globalIndex() == bounds[
c1].first);
931 for (
auto j = 1;
j < ops.size(); ++
j) {
934 REQUIRE(it.globalIndex() == bounds[
c1].second);
937 REQUIRE(ops.size() == 0);
940 auto opss = p.pointSet_as<o2::aod::PointsSelfIndex>();
941 auto bbba = std::same_as<
decltype(opss), std::vector<o2::aod::PointsSelfIndex::iterator>>;
944 auto opss_ids = p.pointSetIds();
945 if (
c2 < withSets.size() &&
i == withSets[
c2]) {
946 REQUIRE(opss.size() ==
sizes[
c2]);
947 REQUIRE(opss.begin()->globalIndex() ==
i + 1);
948 REQUIRE(opss.back().globalIndex() ==
i +
sizes[
c2]);
950 for (
auto&
id : opss_ids) {
951 REQUIRE(
id ==
i + 1 + c3);
956 REQUIRE(opss.size() == 0);
964DECLARE_SOA_TABLE(PointsSelfRef,
"TEST",
"PTSSR", test::OtherPointId, test::PointSeqIdSlice, test::PointSetIds);
970 auto pswriter = b3.
cursor<o2::aod::PointsSelfIndex>();
971 int references[] = {19, 2, 0, 13, 4, 6, 5, 5, 11, 9, 3, 8, 16, 14, 1, 18, 12, 18, 2, 7};
972 int slice[2] = {-1, -1};
973 std::vector<int> pset;
974 std::array<int, 4> withSlices = {3, 6, 13, 19};
975 std::array<std::pair<int, int>, 4> bounds = {std::pair{1, 5}, std::pair{3, 3}, std::pair{11, 11}, std::pair{10, 18}};
976 std::array<int, 4> withSets = {0, 1, 13, 14};
977 unsigned int sizes[] = {3, 1, 5, 4};
980 for (
auto i = 0;
i < 20; ++
i) {
984 if (
c1 < withSlices.size() &&
i == withSlices[
c1]) {
985 slice[0] = bounds[
c1].first;
986 slice[1] = bounds[
c1].second;
989 if (
c2 < withSets.size() &&
i == withSets[
c2]) {
991 pset.push_back(
i + 1 +
z);
995 pswriter(0, -1 *
i, 0.5 *
i, 2 *
i, references[
i], slice, pset);
998 auto pst = o2::aod::PointsSelfIndex{t3};
999 pst.bindInternalIndicesTo(&pst);
1002 for (
auto& p : pst) {
1003 auto ops = p.pointSeq_as<o2::aod::PointsSelfIndex>();
1004 for (
auto& pp : ops) {
1005 auto bpp = std::same_as<std::decay_t<
decltype(pp)>, o2::aod::PointsSelfIndex::iterator>;
1007 auto opps = pp.pointSeq_as<o2::aod::PointsSelfIndex>();
1008 for (
auto& ppp : opps) {
1009 auto bppp = std::same_as<std::decay_t<
decltype(ppp)>, o2::aod::PointsSelfIndex::iterator>;
1011 auto oppps = ppp.pointSeq_as<o2::aod::PointsSelfIndex>();
1012 for (
auto& pppp : oppps) {
1013 auto bpppp = std::same_as<std::decay_t<
decltype(pppp)>, o2::aod::PointsSelfIndex::iterator>;
1015 auto opppps = pppp.pointSeq_as<o2::aod::PointsSelfIndex>();
1023 auto corewriter =
b.
cursor<o2::aod::Points3Ds>();
1024 for (
auto i = 0;
i < 20; ++
i) {
1025 corewriter(0, -1 *
i, 0.5 *
i, 2 *
i);
1027 auto t1 =
b.finalize();
1032 auto extwriter = be.
cursor<o2::aod::PointsSelfRef>();
1033 for (
auto i = 0;
i < 20; ++
i) {
1037 if (
c1 < withSlices.size() &&
i == withSlices[
c1]) {
1038 slice[0] = bounds[
c1].first;
1039 slice[1] = bounds[
c1].second;
1042 if (
c2 < withSets.size() &&
i == withSets[
c2]) {
1044 pset.push_back(
i + 1 +
z);
1048 extwriter(0, references[
i], slice, pset);
1052 FullPoints fp({
t1, t2});
1053 fp.bindInternalIndicesTo(&fp);
1057 for (
auto& p : fp) {
1058 REQUIRE(std::same_as<std::decay_t<
decltype(p)>, FullPoints::iterator>);
1059 auto ops = p.pointSeq_as<FullPoints>();
1060 for (
auto& pp : ops) {
1061 REQUIRE(std::same_as<std::decay_t<
decltype(pp)>, FullPoints::iterator>);
1062 auto opps = pp.pointSeq_as<FullPoints>();
1063 for (
auto& ppp : opps) {
1064 REQUIRE(std::same_as<std::decay_t<
decltype(ppp)>, FullPoints::iterator>);
1065 auto oppps = ppp.pointSeq_as<FullPoints>();
1066 for (
auto& pppp : oppps) {
1067 REQUIRE(std::same_as<std::decay_t<
decltype(pppp)>, FullPoints::iterator>);
1068 auto opppps = pppp.pointSeq_as<FullPoints>();
1074 auto const& fpa = fp;
1077 for (
auto& it1 : fpa) {
1078 [[maybe_unused]]
auto it2 = fpa.rawIteratorAt(0);
1079 [[maybe_unused]]
auto it3 = fpa.iteratorAt(0);
1080 auto bit1 = std::same_as<std::decay_t<
decltype(it1)>, std::decay_t<
decltype(it2)>>;
1082 auto bit2 = std::same_as<std::decay_t<
decltype(it1)>, std::decay_t<
decltype(it3)>>;
1087 FilteredPoints ffp({
t1, t2}, {1, 2, 3}, 0);
1091 for (
auto& p : ffp) {
1092 REQUIRE(std::same_as<std::decay_t<
decltype(p)>, FilteredPoints::iterator>);
1093 REQUIRE(std::same_as<std::decay_t<
decltype(p)>::parent_t, FilteredPoints>);
1094 auto ops = p.pointSeq_as<
typename std::decay_t<
decltype(p)>::parent_t>();
1095 for (
auto& pp : ops) {
1096 REQUIRE(std::same_as<std::decay_t<
decltype(pp)>::parent_t, FilteredPoints>);
1097 auto opps = pp.pointSeq_as<FilteredPoints>();
1098 for (
auto& ppp : opps) {
1099 REQUIRE(std::same_as<std::decay_t<
decltype(ppp)>, FilteredPoints::iterator>);
1100 auto oppps = ppp.pointSeq_as<FilteredPoints>();
1101 for (
auto& pppp : oppps) {
1102 REQUIRE(std::same_as<std::decay_t<
decltype(pppp)>, FilteredPoints::iterator>);
1103 auto opppps = pppp.pointSeq_as<FilteredPoints>();
1109 auto const& ffpa = ffp;
1112 for (
auto& it1 : ffpa) {
1113 [[maybe_unused]]
auto it2 = ffpa.rawIteratorAt(0);
1114 [[maybe_unused]]
auto it3 = ffpa.iteratorAt(0);
1115 using T1 = std::decay_t<
decltype(it1)>;
1116 using T2 = std::decay_t<
decltype(it2)>;
1117 using T3 = std::decay_t<
decltype(it3)>;
1118 auto bit1 = !std::same_as<T1, T2>;
1120 auto bit2 = !std::same_as<T1, T3>;
1122 auto bit3 = std::same_as<typename T1::policy_t, typename T3::policy_t>;
1124 auto bit4 = std::same_as<typename T1::policy_t, o2::soa::FilteredIndexPolicy>;
1126 auto bit5 = std::same_as<typename T2::policy_t, o2::soa::DefaultIndexPolicy>;
1134 auto writer =
b.
cursor<o2::aod::Lists>();
1135 std::vector<float> floats;
1136 std::vector<int> ints;
1137 for (
auto i = 1;
i < 11; ++
i) {
1140 for (
auto j = 0;
j <
i; ++
j) {
1141 floats.push_back(0.1231233f * (
float)
j + 0.1982798f);
1142 ints.push_back(
j + 10);
1145 writer(0, floats, ints);
1147 auto lt =
b.finalize();
1148 o2::aod::Lists tbl{lt};
1150 for (
auto&
row : tbl) {
1153 auto constexpr bf = std::same_as<
decltype(
f), gsl::span<
const float, (
size_t)-1>>;
1154 auto constexpr bi = std::same_as<
decltype(
i), gsl::span<
const int, (
size_t)-1>>;
1157 REQUIRE(
f.size() == s);
1158 REQUIRE(
i.size() == s);
1160 for (
auto j = 0u;
j <
f.size(); ++
j) {
1161 REQUIRE(
f[
j] == 0.1231233f * (
float)
j + 0.1982798f);
1162 REQUIRE(
i[
j] == (
int)
j + 10);
1171 auto writer =
b.
cursor<o2::aod::Origints>();
1172 for (
auto i = 0;
i < 20; ++
i) {
1173 writer(0,
i,
i % 3 == 0);
1175 auto origins =
b.finalize();
1176 o2::aod::Origints
o{origins};
1179 auto writer_w =
w.
cursor<o2::aod::References>();
1181 for (
auto i = 0;
i < 5 * 20; ++
i) {
1187 auto refs =
w.finalize();
1188 o2::aod::References
r{refs};
1191 auto s = atscache.updateCacheEntry(0, refs);
1194 for (
auto& oi :
o) {
1195 auto cachedSlice =
r.sliceByCached(o2::aod::test::origintId, oi.globalIndex(), cache);
1196 REQUIRE(cachedSlice.size() == 5);
1197 for (
auto& ri : cachedSlice) {
1198 REQUIRE(ri.origintId() == oi.globalIndex());
1206 auto writer =
b.
cursor<o2::aod::Origints>();
1207 for (
auto i = 0;
i < 20; ++
i) {
1208 writer(0,
i,
i % 3 == 0);
1210 auto origins =
b.finalize();
1211 o2::aod::Origints
o{origins};
1214 auto writer_w =
w.
cursor<o2::aod::References>();
1216 for (
auto i = 0;
i < 5 * 20; ++
i) {
1222 auto refs =
w.finalize();
1223 o2::aod::References
r{refs};
1226 auto writer_w2 = w2.
cursor<o2::aod::OtherReferences>();
1228 for (
auto i = 0;
i < 5 * 20; ++
i) {
1235 o2::aod::OtherReferences r2{refs2};
1238 J
rr{{refs, refs2}};
1242 auto s = atscache.updateCacheEntry(0, refs2);
1245 for (
auto& oi :
o) {
1246 auto cachedSlice =
rr.sliceByCached(o2::aod::test::altOrigintId, oi.globalIndex(), cache);
1247 REQUIRE(cachedSlice.size() == 3);
1248 for (
auto& ri : cachedSlice) {
1249 REQUIRE(ri.altOrigintId() == oi.globalIndex());
1257 auto prwriter =
b.
cursor<o2::aod::PointsRefF>();
1258 auto a = std::array{0, 1};
1259 auto aa = std::vector{2, 3, 4};
1260 prwriter(0, 0, &
a[0], aa);
1263 prwriter(0, 1, &
a[0], aa);
1264 auto t =
b.finalize();
1265 auto prt = o2::aod::PointsRefF{t};
1267 for (
auto&
row : prt) {
1269 [[maybe_unused]]
auto sp =
row.singlePoint();
1271 REQUIRE(std::string{
error_from_ref(
ref).
what} ==
"Index pointing to Points3Ds is not bound! Did you subscribe to the table?");
1274 auto ps =
row.pointSlice();
1276 REQUIRE(std::string{
error_from_ref(
ref).
what} ==
"Index pointing to Points3Ds is not bound! Did you subscribe to the table?");
1279 auto pg =
row.pointGroup();
1281 REQUIRE(std::string{
error_from_ref(
ref).
what} ==
"Index pointing to Points3Ds is not bound! Did you subscribe to the table?");
1300 auto writer =
b.
cursor<o2::aod::BILists>();
1303 for (
auto i = 0;
i < 20; ++
i) {
1305 for (
auto j = 0;
j < 32; ++
j) {
1313 auto t =
b.finalize();
1315 o2::aod::BILists li{t};
1316 for (
auto const&
row : li) {
1317 auto iir =
row.smallIntArray();
1318 [[maybe_unused]]
auto bbrr =
row.boolArray_raw();
1319 REQUIRE(std::same_as<std::decay_t<
decltype(iir)>, int8_t
const*>);
1320 for (
auto i = 0;
i < 32; ++
i) {
1321 REQUIRE(iir[
i] ==
i);
1322 REQUIRE(
row.boolArray_bit(
i) == (
i % 2 == 0));
1339 table::One, table::Two, table::Three, table::Four,
1340 table::Five<table::Four>);
1346 auto writer =
b.
cursor<o2::aod::MixTest>();
1348 for (
auto i = 0;
i < 20; ++
i) {
1353 auto t =
b.finalize();
1354 o2::aod::MixTest mt{t};
1356 for (
auto const&
row : mt) {
1357 auto features1 =
row.getValues<float, o2::aod::table::One, o2::aod::table::Three>();
1358 auto features2 =
row.getValues<double, o2::aod::table::One, o2::aod::table::Two, o2::aod::table::Three>();
1359 auto features3 =
row.getValues<float, o2::aod::table::Two, o2::aod::table::Five<o2::aod::table::Four>>();
1360 auto b1 = std::same_as<std::array<float, 2>,
decltype(features1)>;
1362 auto b2 = std::same_as<std::array<double, 3>,
decltype(features2)>;
1364 auto b3 = std::same_as<std::array<float, 2>,
decltype(features3)>;
1366 REQUIRE(features1[0] == (
float)
count);
1369 REQUIRE(features2[0] == (
double)
count);
1374 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.