Skip to content

Commit

Permalink
We are passing end to end tests again.
Browse files Browse the repository at this point in the history
TODO: clean up
- split PRs
- evaluate peerformance on galera.
  • Loading branch information
joka921 committed Apr 17, 2020
1 parent c096ac8 commit 68b5b84
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
4 changes: 2 additions & 2 deletions e2e/scientists_queries.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,8 @@ queries:
sparql: |
SELECT ?x ?y WHERE {
?x <is-a> <Scientist> .
FILTER (?x < <Ada_Lovelace>) .
OPTIONAL { ?x <Spouse_(or_domestic_partner)> ?y } .
FILTER (?x < <Ada_Lovelace>)
}
checks:
- num_rows: 126
Expand All @@ -286,9 +286,9 @@ queries:
type: no-text
sparql: |
SELECT ?x (GROUP_CONCAT(?y; separator=";") AS ?partners) WHERE {
FILTER (?x < <Ada_Lovelace>)
?x <is-a> <Scientist> .
OPTIONAL {?x <Spouse_(or_domestic_partner)> ?y .}
FILTER (?x < <Ada_Lovelace>)
}
GROUP BY ?x
checks:
Expand Down
18 changes: 15 additions & 3 deletions src/engine/QueryPlanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,15 @@ std::vector<QueryPlanner::SubtreePlan> QueryPlanner::optimize(
auto optimizeSingle = [this](auto pattern) {
auto v = optimize(pattern);
if (v.empty()) {
throw std::runtime_error("failed in optimizing a graph pattern");
throw std::runtime_error("grandchildren or lower of a Plan to be optimized may never be empty");
}
auto idx = findCheapestExecutionTree(v);
return std::move(v[idx]);
};

size_t numEmptyChildren = 0; // the number of children for which no tree was found because they are empty
// only happens when a triple is removed for a pattern trick

for (auto& child : rootPattern->_children) {
child.visit([&](auto&& arg) {
using T = std::decay_t<decltype(arg)>;
Expand Down Expand Up @@ -244,14 +247,23 @@ std::vector<QueryPlanner::SubtreePlan> QueryPlanner::optimize(
std::vector<SubtreePlan> lastRow =
fillDpTab(tg, arg._filters, std::vector<const SubtreePlan*>{}, arg._inlineValues)
.back();

if (!lastRow.empty()) {
auto minInd = findCheapestExecutionTree(lastRow);
childPlans.emplace_back(lastRow[minInd]);
} else {
numEmptyChildren++;
}
}
});
}

AD_CHECK(childPlans.size() == rootPattern->_children.size());
AD_CHECK(!childPlans.empty());
AD_CHECK(childPlans.size() + numEmptyChildren == rootPattern->_children.size());
AD_CHECK(numEmptyChildren <= 1);
if (childPlans.empty()) {
// happens if our only triple was snatched away by pattern trick magic
return std::vector<SubtreePlan>{};
}
SubtreePlan res = std::move(childPlans[0]);
for (size_t i = 1; i < childPlans.size(); ++i) {
try {
Expand Down

0 comments on commit 68b5b84

Please sign in to comment.