Skip to content

Commit

Permalink
Fix the compilation of the tests again.
Browse files Browse the repository at this point in the history
Signed-off-by: Johannes Kalmbach <[email protected]>
  • Loading branch information
joka921 committed Jan 30, 2025
1 parent 7f30e17 commit 65caf94
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
23 changes: 12 additions & 11 deletions src/engine/ValuesForTesting.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
// unit testing purposes when we need to specify the subtrees of another
// operation.
class ValuesForTesting : public Operation {
public:
using VarVector = std::vector<std::optional<Variable>>;

private:
std::vector<IdTable> tables_;
VariableToColumnMap variables_;
Expand All @@ -27,13 +30,13 @@ class ValuesForTesting : public Operation {
// Create an operation that has as its result the given `table` and the given
// `variables`. The number of variables must be equal to the number
// of columns in the table.
explicit ValuesForTesting(
QueryExecutionContext* ctx, IdTable table,
const std::vector<std::optional<Variable>>& variables,
bool supportsLimit = false, std::vector<ColumnIndex> sortedColumns = {},
LocalVocab localVocab = LocalVocab{},
std::optional<float> multiplicity = std::nullopt,
bool forceFullyMaterialized = false)
explicit ValuesForTesting(QueryExecutionContext* ctx, IdTable table,
const VarVector& variables,
bool supportsLimit = false,
std::vector<ColumnIndex> sortedColumns = {},
LocalVocab localVocab = LocalVocab{},
std::optional<float> multiplicity = std::nullopt,
bool forceFullyMaterialized = false)
: Operation{ctx},
supportsLimit_{supportsLimit},
sizeEstimate_{table.numRows()},
Expand Down Expand Up @@ -63,8 +66,7 @@ class ValuesForTesting : public Operation {
tables_.push_back(std::move(table));
}
explicit ValuesForTesting(QueryExecutionContext* ctx,
std::vector<IdTable> tables,
std::vector<std::optional<Variable>> variables,
std::vector<IdTable> tables, VarVector variables,
bool unlikelyToFitInCache = false,
std::vector<ColumnIndex> sortedColumns = {},
LocalVocab localVocab = LocalVocab{})
Expand Down Expand Up @@ -199,8 +201,7 @@ class ValuesForTesting : public Operation {
}

private:
VariableToColumnMap computeVarMapFromVector(
const std::vector<std::optional<Variable>>& vars) const {
VariableToColumnMap computeVarMapFromVector(const VarVector& vars) const {
VariableToColumnMap m;
for (auto i = ColumnIndex{0}; i < vars.size(); ++i) {
if (!vars.at(i).has_value()) {
Expand Down
5 changes: 3 additions & 2 deletions test/OperationTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class OperationTestFixture : public testing::Test {
&namedCache,
[&](std::string json) { jsonHistory.emplace_back(std::move(json)); }};
IdTable table = makeIdTableFromVector({{}, {}, {}});
ValuesForTesting operation{&qec, std::move(table), {}};
ValuesForTesting operation{&qec, std::move(table), VariableToColumnMap{}};
};

// _____________________________________________________________________________
Expand Down Expand Up @@ -288,7 +288,8 @@ TEST(Operation, updateRuntimeStatsWorksCorrectly) {
auto qec = getQec();
auto idTable = makeIdTableFromVector({{3, 4}, {7, 8}, {9, 123}});
ValuesForTesting valuesForTesting{
qec, std::move(idTable), {Variable{"?x"}, Variable{"?y"}}};
qec, std::move(idTable),
ValuesForTesting::VarVector{Variable{"?x"}, Variable{"?y"}}};

auto& rti = valuesForTesting.runtimeInfo();

Expand Down
7 changes: 4 additions & 3 deletions test/ValuesForTestingTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ TEST(ValuesForTesting, valuesForTesting) {
(ValuesForTesting{getQec(), table.clone(), {Variable{"?x"}}}));

ValuesForTesting v{
getQec(), table.clone(), {Variable{"?x"}, {Variable{"?y"}}}};
getQec(), table.clone(),
ValuesForTesting::VarVector{Variable{"?x"}, {Variable{"?y"}}}};
// The following line has no effect. TODO<joka921> provide default
// implementations for such boilerplate methods in the `Operation` base class.
ASSERT_EQ(v.getResultWidth(), 2u);
Expand All @@ -42,7 +43,7 @@ TEST(ValuesForTesting, cornerCasesCacheKey) {
auto empty = makeIdTableFromVector({});
auto neutral = makeIdTableFromVector({{}});

ValuesForTesting vEmpty{getQec(), empty.clone(), {}};
ValuesForTesting vNeutral{getQec(), neutral.clone(), {}};
ValuesForTesting vEmpty{getQec(), empty.clone(), VariableToColumnMap{}};
ValuesForTesting vNeutral{getQec(), neutral.clone(), VariableToColumnMap{}};
EXPECT_NE(vEmpty.getCacheKey(), vNeutral.getCacheKey());
}

0 comments on commit 65caf94

Please sign in to comment.