Skip to content

Commit 8f6bef5

Browse files
committed
add uint8/16/32/64 gandiva test
1 parent 61350cd commit 8f6bef5

1 file changed

Lines changed: 108 additions & 18 deletions

File tree

Framework/Core/test/test_ASoA.cxx

Lines changed: 108 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include <cstdio>
1313
#include "Framework/ASoA.h"
14+
#include "Framework/ExpressionHelpers.h"
1415
#include "Framework/Expressions.h"
1516
#include "Framework/AnalysisHelpers.h"
1617
#include "CommonConstants/MathConstants.h"
@@ -625,11 +626,7 @@ TEST_CASE("TestFilteredOperators")
625626
FilteredTest filteredIntersection = filtered1 * filtered2;
626627
REQUIRE(0 == filteredIntersection.size());
627628

628-
i = 0;
629-
for (auto const& _ : filteredIntersection) {
630-
i++;
631-
}
632-
REQUIRE(i == 0);
629+
REQUIRE(filteredIntersection.size() == 0);
633630

634631
expressions::Filter f3 = o2::aod::test::x < 3;
635632
auto s3 = expressions::createSelection(testA.asArrowTable(), f3);
@@ -890,7 +887,7 @@ TEST_CASE("TestAdvancedIndices")
890887
std::array<int, 4> withSlices = {3, 6, 13, 19};
891888
std::array<std::pair<int, int>, 4> bounds = {std::pair{1, 5}, std::pair{3, 3}, std::pair{11, 11}, std::pair{10, 18}};
892889
std::array<int, 4> withSets = {0, 1, 13, 14};
893-
unsigned int sizes[] = {3, 1, 5, 4};
890+
unsigned const int sizes[] = {3, 1, 5, 4};
894891
unsigned int c1 = 0;
895892
unsigned int c2 = 0;
896893
for (auto i = 0; i < 20; ++i) {
@@ -927,13 +924,11 @@ TEST_CASE("TestAdvancedIndices")
927924
REQUIRE(bbbs);
928925

929926
if (i == withSlices[c1]) {
930-
auto it = ops.begin();
927+
auto lit = ops.begin();
931928
REQUIRE(ops.size() == bounds[c1].second - bounds[c1].first + 1);
932-
REQUIRE(it.globalIndex() == bounds[c1].first);
933-
for (auto j = 1; j < ops.size(); ++j) {
934-
++it;
935-
}
936-
REQUIRE(it.globalIndex() == bounds[c1].second);
929+
REQUIRE(lit.globalIndex() == bounds[c1].first);
930+
lit.moveByIndex(ops.size() - 1);
931+
REQUIRE(lit.globalIndex() == bounds[c1].second);
937932
++c1;
938933
} else {
939934
REQUIRE(ops.size() == 0);
@@ -949,7 +944,7 @@ TEST_CASE("TestAdvancedIndices")
949944
REQUIRE(opss.begin()->globalIndex() == i + 1);
950945
REQUIRE(opss.back().globalIndex() == i + sizes[c2]);
951946
int c3 = 0;
952-
for (auto& id : opss_ids) {
947+
for (auto const& id : opss_ids) {
953948
REQUIRE(id == i + 1 + c3);
954949
++c3;
955950
}
@@ -976,7 +971,7 @@ TEST_CASE("TestSelfIndexRecursion")
976971
std::array<int, 4> withSlices = {3, 6, 13, 19};
977972
std::array<std::pair<int, int>, 4> bounds = {std::pair{1, 5}, std::pair{3, 3}, std::pair{11, 11}, std::pair{10, 18}};
978973
std::array<int, 4> withSets = {0, 1, 13, 14};
979-
unsigned int sizes[] = {3, 1, 5, 4};
974+
unsigned const int sizes[] = {3, 1, 5, 4};
980975
unsigned int c1 = 0;
981976
unsigned int c2 = 0;
982977
for (auto i = 0; i < 20; ++i) {
@@ -1076,7 +1071,7 @@ TEST_CASE("TestSelfIndexRecursion")
10761071
auto const& fpa = fp;
10771072

10781073
// iterators acquired through different means should have consistent types
1079-
for (auto& it1 : fpa) {
1074+
for (auto const& it1 : fpa) {
10801075
[[maybe_unused]] auto it2 = fpa.rawIteratorAt(0);
10811076
[[maybe_unused]] auto it3 = fpa.iteratorAt(0);
10821077
auto bit1 = std::same_as<std::decay_t<decltype(it1)>, std::decay_t<decltype(it2)>>;
@@ -1111,7 +1106,7 @@ TEST_CASE("TestSelfIndexRecursion")
11111106
auto const& ffpa = ffp;
11121107

11131108
// rawIteratorAt() should create an unfiltered iterator, unlike begin() and iteratorAt()
1114-
for (auto& it1 : ffpa) {
1109+
for (auto const& it1 : ffpa) {
11151110
[[maybe_unused]] auto it2 = ffpa.rawIteratorAt(0);
11161111
[[maybe_unused]] auto it3 = ffpa.iteratorAt(0);
11171112
using T1 = std::decay_t<decltype(it1)>;
@@ -1359,9 +1354,8 @@ TEST_CASE("TestArrayColumns")
13591354
TableBuilder b;
13601355
auto writer = b.cursor<o2::aod::BILists>();
13611356
int8_t ii[32];
1362-
uint32_t bb;
13631357
for (auto i = 0; i < 20; ++i) {
1364-
bb = 0;
1358+
uint32_t bb = 0;
13651359
for (auto j = 0; j < 32; ++j) {
13661360
ii[j] = j;
13671361
if (j % 2 == 0) {
@@ -1481,3 +1475,99 @@ TEST_CASE("TestWritingCursorLastIndexAndReserve")
14811475
REQUIRE(table->num_columns() == 2);
14821476
cursor.release();
14831477
}
1478+
1479+
namespace o2::aod
1480+
{
1481+
namespace test
1482+
{
1483+
DECLARE_SOA_COLUMN(UInt8, guint8, uint8_t);
1484+
DECLARE_SOA_COLUMN(UInt16, guint16, uint16_t);
1485+
DECLARE_SOA_COLUMN(UInt32, guint32, uint32_t);
1486+
DECLARE_SOA_COLUMN(UInt64, guint64, uint64_t);
1487+
}
1488+
1489+
DECLARE_SOA_TABLE(UnsignedIntTest8, "TEST", "TSHI8", test::UInt8);
1490+
DECLARE_SOA_TABLE(UnsignedIntTest16, "TEST", "TSHI16", test::UInt16);
1491+
DECLARE_SOA_TABLE(UnsignedIntTest32, "TEST", "TSHI32", test::UInt32);
1492+
DECLARE_SOA_TABLE(UnsignedIntTest64, "TEST", "TSHI64", test::UInt64);
1493+
}
1494+
1495+
TEST_CASE("TestUnsignedIntExpressions")
1496+
{
1497+
auto max8 = std::numeric_limits<uint8_t>::max();
1498+
auto max16 = std::numeric_limits<uint8_t>::max();
1499+
auto max32 = std::numeric_limits<uint8_t>::max();
1500+
auto max64 = std::numeric_limits<uint8_t>::max();
1501+
1502+
TableBuilder b8;
1503+
auto writer8 = b8.cursor<o2::aod::UnsignedIntTest8>();
1504+
for (uint64_t i = 0; i < max8; i += (max8 / 100))
1505+
{
1506+
writer8(0, i);
1507+
}
1508+
auto t8 = b8.finalize();
1509+
o2::aod::UnsignedIntTest8 at8{{t8}};
1510+
1511+
uint8_t limit8 = max8 / 2 + 1;
1512+
o2::framework::expressions::Filter test8 = o2::aod::test::guint8 < limit8;
1513+
auto s8 = o2::framework::expressions::createSelection(t8, test8);
1514+
1515+
o2::soa::Filtered<o2::aod::UnsignedIntTest8> fat8{{t8}, s8};
1516+
1517+
REQUIRE(at8.size() == 128);
1518+
REQUIRE(fat8.size() == 64);
1519+
1520+
TableBuilder b16;
1521+
auto writer16 = b16.cursor<o2::aod::UnsignedIntTest16>();
1522+
for (uint64_t i = 0; i < max16; i += (max16 / 100))
1523+
{
1524+
writer16(0, i);
1525+
}
1526+
auto t16 = b16.finalize();
1527+
o2::aod::UnsignedIntTest16 at16{{t16}};
1528+
1529+
uint16_t limit16 = max16 / 2 + 1;
1530+
o2::framework::expressions::Filter test16 = o2::aod::test::guint16 < limit16;
1531+
auto s16 = o2::framework::expressions::createSelection(t16, test16);
1532+
1533+
o2::soa::Filtered<o2::aod::UnsignedIntTest16> fat16{{t16}, s16};
1534+
1535+
REQUIRE(at16.size() == 128);
1536+
REQUIRE(fat16.size() == 64);
1537+
1538+
TableBuilder b32;
1539+
auto writer32 = b32.cursor<o2::aod::UnsignedIntTest32>();
1540+
for (uint64_t i = 0; i < max32; i += (max32 / 100))
1541+
{
1542+
writer32(0, i);
1543+
}
1544+
auto t32 = b32.finalize();
1545+
o2::aod::UnsignedIntTest32 at32{{t32}};
1546+
1547+
uint32_t limit32 = max32 / 2 + 1;
1548+
o2::framework::expressions::Filter test32 = o2::aod::test::guint32 < limit32;
1549+
auto s32 = o2::framework::expressions::createSelection(t32, test32);
1550+
1551+
o2::soa::Filtered<o2::aod::UnsignedIntTest32> fat32{{t32}, s32};
1552+
1553+
REQUIRE(at32.size() == 128);
1554+
REQUIRE(fat32.size() == 64);
1555+
1556+
TableBuilder b64;
1557+
auto writer64 = b64.cursor<o2::aod::UnsignedIntTest64>();
1558+
for (uint64_t i = 0; i < max64; i += (max64 / 100))
1559+
{
1560+
writer64(0, i);
1561+
}
1562+
auto t64 = b64.finalize();
1563+
o2::aod::UnsignedIntTest64 at64{{t64}};
1564+
1565+
uint64_t limit64 = max64 / 2 + 1;
1566+
o2::framework::expressions::Filter test64 = o2::aod::test::guint64 < limit64;
1567+
auto s64 = o2::framework::expressions::createSelection(t64, test64);
1568+
1569+
o2::soa::Filtered<o2::aod::UnsignedIntTest64> fat64{{t64}, s64};
1570+
1571+
REQUIRE(at64.size() == 128);
1572+
REQUIRE(fat64.size() == 64);
1573+
}

0 commit comments

Comments
 (0)