Skip to content

Commit c845be7

Browse files
committed
add test
1 parent d8f5fa0 commit c845be7

1 file changed

Lines changed: 57 additions & 0 deletions

File tree

Framework/Core/test/test_ASoA.cxx

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,6 +1254,63 @@ TEST_CASE("TestSliceByCachedMismatched")
12541254
}
12551255
}
12561256

1257+
TEST_CASE("TestSliceByCachedFiltered")
1258+
{
1259+
TableBuilder b;
1260+
auto writer = b.cursor<o2::aod::Origints>();
1261+
for (auto i = 0; i < 20; ++i) {
1262+
writer(0, i, i % 3 == 0);
1263+
}
1264+
auto origins = b.finalize();
1265+
o2::aod::Origints o{origins};
1266+
1267+
TableBuilder w;
1268+
auto writer_w = w.cursor<o2::aod::References>();
1269+
auto step = -1;
1270+
for (auto i = 0; i < 5 * 20; ++i) {
1271+
if (i % 5 == 0) {
1272+
++step;
1273+
}
1274+
writer_w(0, step);
1275+
}
1276+
auto refs = w.finalize();
1277+
o2::aod::References r{refs};
1278+
1279+
TableBuilder w2;
1280+
auto writer_w2 = w2.cursor<o2::aod::OtherReferences>();
1281+
step = -1;
1282+
for (auto i = 0; i < 5 * 20; ++i) {
1283+
if (i % 3 == 0) {
1284+
++step;
1285+
}
1286+
writer_w2(0, step);
1287+
}
1288+
auto refs2 = w2.finalize();
1289+
o2::aod::OtherReferences r2{refs2};
1290+
1291+
using J = o2::soa::Join<o2::aod::References, o2::aod::OtherReferences>;
1292+
J rr{{refs, refs2}};
1293+
1294+
auto rrf = rr.select(o2::aod::test::altOrigintId > 2 && o2::aod::test::altOrigintId < 15);
1295+
1296+
auto key = "fIndex" + o2::framework::cutString(o2::soa::getLabelFromType<o2::aod::Origints>()) + "_alt";
1297+
ArrowTableSlicingCache atscache({{o2::soa::getLabelFromTypeForKey<J>(key), o2::soa::getMatcherFromTypeForKey<J>(key), key}});
1298+
auto s = atscache.updateCacheEntry(0, refs2);
1299+
SliceCache cache{&atscache};
1300+
1301+
for (auto& oi : o) {
1302+
auto cachedSlice = rrf.sliceByCached(o2::aod::test::altOrigintId, oi.globalIndex(), cache);
1303+
if (oi.globalIndex() <= 2 || oi.globalIndex() >= 15) {
1304+
CHECK(cachedSlice.size() == 0);
1305+
} else {
1306+
CHECK(cachedSlice.size() == 3);
1307+
}
1308+
for (auto& ri : cachedSlice) {
1309+
REQUIRE(ri.altOrigintId() == oi.globalIndex());
1310+
}
1311+
}
1312+
}
1313+
12571314
TEST_CASE("TestIndexUnboundExceptions")
12581315
{
12591316
TableBuilder b;

0 commit comments

Comments
 (0)