Skip to content

Commit

Permalink
Caching bugs in the test.
Browse files Browse the repository at this point in the history
Signed-off-by: Johannes Kalmbach <[email protected]>
  • Loading branch information
joka921 committed Dec 18, 2024
1 parent ee271f6 commit d4ea706
Showing 1 changed file with 27 additions and 11 deletions.
38 changes: 27 additions & 11 deletions test/engine/IndexScanTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ using LazyResult = Result::LazyResult;

using IndexPair = std::pair<size_t, size_t>;

// TODO<joka921> Comment
Permutation::IdTableGenerator convertGenerator(Result::LazyResult gen) {
for (auto& [idTable, localVocab] : gen) {
co_yield idTable;
}
}

// NOTE: All the following helper functions always use the `PSO` permutation to
// set up index scans unless explicitly stated otherwise.

Expand Down Expand Up @@ -104,20 +111,29 @@ void testLazyScanForJoinOfTwoScans(
std::vector<LimitOffsetClause> limits{{}, {12, 3}, {2, 3}};
for (const auto& limit : limits) {
auto qec = getQec(kgTurtle, true, true, true, blocksizePermutations);
qec->getQueryTreeCache().clearAll();
IndexScan s1{qec, Permutation::PSO, tripleLeft};
IndexScan s1Copy{qec, Permutation::PSO, tripleLeft};
s1.setLimit(limit);
IndexScan s2{qec, Permutation::PSO, tripleRight};
auto implForSwitch = [](IndexScan& l, IndexScan& r, const auto& expectedL,
const auto& expectedR,
const LimitOffsetClause& limitL,
const LimitOffsetClause& limitR) {
auto [scan1, scan2] = (IndexScan::lazyScanForJoinOfTwoScans(l, r));

testLazyScan(std::move(scan1), l, expectedL, limitL);
testLazyScan(std::move(scan2), r, expectedR, limitR);
};
implForSwitch(s1, s2, leftRows, rightRows, limit, {});
implForSwitch(s2, s1, rightRows, leftRows, {}, limit);
IndexScan s2Copy{qec, Permutation::PSO, tripleLeft};

IndexScan::setBlocksForJoinOfIndexScans(&s1, &s2);

// TODO<joka921> also switch the left and right inputs for the test
auto implForSwitch =
[](IndexScan& l, IndexScan& l2, IndexScan& r, IndexScan& r2,
const auto& expectedL, const auto& expectedR,
const LimitOffsetClause& limitL, const LimitOffsetClause& limitR) {
auto res1 = l.computeResultOnlyForTesting(true);
auto res2 = r.computeResultOnlyForTesting(true);
testLazyScan(convertGenerator(std::move(res1.idTables())), l2,
expectedL, limitL);
testLazyScan(convertGenerator(std::move(res2.idTables())), r2,
expectedR, limitR);
};
implForSwitch(s1, s1Copy, s2, s2Copy, leftRows, rightRows, limit, {});
implForSwitch(s2, s2Copy, s1, s1Copy, rightRows, leftRows, {}, limit);
}
}

Expand Down

0 comments on commit d4ea706

Please sign in to comment.