Skip to content

Commit

Permalink
Add tests for ExportQueryExecutionTrees
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinTF committed Jun 30, 2024
1 parent 55b4fec commit e5ceacc
Show file tree
Hide file tree
Showing 4 changed files with 306 additions and 25 deletions.
16 changes: 6 additions & 10 deletions src/engine/ExportQueryExecutionTrees.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,9 @@
#include "util/http/MediaTypes.h"

// __________________________________________________________________________
namespace {

struct IndexWithTable {
size_t index_;
const IdTable& idTable_;
};

cppcoro::generator<const IdTable&> getIdTables(const Result& result) {
cppcoro::generator<const IdTable&> ExportQueryExecutionTrees::getIdTables(
const Result& result) {
if (result.isDataEvaluated()) {
co_yield result.idTable();
} else {
Expand All @@ -29,11 +24,13 @@ cppcoro::generator<const IdTable&> getIdTables(const Result& result) {
}
}
}

// Return a range that contains the indices of the rows that have to be exported
// from the `idTable` given the `LimitOffsetClause`. It takes into account the
// LIMIT, the OFFSET, and the actual size of the `idTable`
cppcoro::generator<IndexWithTable> getRowIndices(LimitOffsetClause limitOffset,
const Result& result) {
cppcoro::generator<ExportQueryExecutionTrees::IndexWithTable>
ExportQueryExecutionTrees::getRowIndices(LimitOffsetClause limitOffset,
const Result& result) {
for (const IdTable& idTable : getIdTables(result)) {
uint64_t currentOffset = limitOffset.actualOffset(idTable.numRows());
uint64_t upperBound = limitOffset.upperBound(idTable.numRows());
Expand All @@ -47,7 +44,6 @@ cppcoro::generator<IndexWithTable> getRowIndices(LimitOffsetClause limitOffset,
}
}
}
} // namespace

// _____________________________________________________________________________
cppcoro::generator<QueryExecutionTree::StringTriple>
Expand Down
24 changes: 24 additions & 0 deletions src/engine/ExportQueryExecutionTrees.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,4 +177,28 @@ class ExportQueryExecutionTrees {
const QueryExecutionTree& qet,
const parsedQuery::SelectClause& selectClause,
LimitOffsetClause limitAndOffset, CancellationHandle cancellationHandle);

struct IndexWithTable {
size_t index_;
const IdTable& idTable_;
};

static cppcoro::generator<const IdTable&> getIdTables(const Result& result);
// Return a range that contains the indices of the rows that have to be
// exported from the `idTable` given the `LimitOffsetClause`. It takes into
// account the LIMIT, the OFFSET, and the actual size of the `idTable`
static cppcoro::generator<IndexWithTable> getRowIndices(
LimitOffsetClause limitOffset, const Result& result);

FRIEND_TEST(ExportQueryExecutionTrees, getIdTablesReturnsSingletonIterator);
FRIEND_TEST(ExportQueryExecutionTrees, getIdTablesMirrorsGenerator);
FRIEND_TEST(ExportQueryExecutionTrees, ensureCorrectSlicingOfSingleIdTable);
FRIEND_TEST(ExportQueryExecutionTrees,
ensureCorrectSlicingOfIdTablesWhenFirstIsSkipped);
FRIEND_TEST(ExportQueryExecutionTrees,
ensureCorrectSlicingOfIdTablesWhenLastIsSkipped);
FRIEND_TEST(ExportQueryExecutionTrees,
ensureCorrectSlicingOfIdTablesWhenFirstAndSecondArePartial);
FRIEND_TEST(ExportQueryExecutionTrees,
ensureCorrectSlicingOfIdTablesWhenFirstAndLastArePartial);
};
2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ addLinkAndDiscoverTestSerial(OrderByTest engine)

addLinkAndDiscoverTestSerial(ValuesForTestingTest index)

addLinkAndDiscoverTestSerial(ExportQueryExecutionTreeTest index engine parser)
addLinkAndDiscoverTestSerial(ExportQueryExecutionTreesTest index engine parser)

addLinkAndDiscoverTestSerial(AggregateExpressionTest parser sparqlExpressions index engine)

Expand Down
Loading

0 comments on commit e5ceacc

Please sign in to comment.