From d4ea7063fefab758e823020fb568bbfa3fc1e5b7 Mon Sep 17 00:00:00 2001 From: Johannes Kalmbach Date: Wed, 18 Dec 2024 17:52:15 +0100 Subject: [PATCH] Caching bugs in the test. Signed-off-by: Johannes Kalmbach --- test/engine/IndexScanTest.cpp | 38 +++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/test/engine/IndexScanTest.cpp b/test/engine/IndexScanTest.cpp index 62f01647a0..b067e1b512 100644 --- a/test/engine/IndexScanTest.cpp +++ b/test/engine/IndexScanTest.cpp @@ -25,6 +25,13 @@ using LazyResult = Result::LazyResult; using IndexPair = std::pair; +// TODO 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. @@ -104,20 +111,29 @@ void testLazyScanForJoinOfTwoScans( std::vector 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 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); } }