Skip to content

Commit

Permalink
better conditions for different subtreeplans
Browse files Browse the repository at this point in the history
  • Loading branch information
ullingerc committed Nov 19, 2024
1 parent fc72071 commit d0f7d82
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/engine/QueryPlanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2479,7 +2479,13 @@ void QueryPlanner::GraphPatternPlanner::visitSpatialSearch(
auto config = spatialQuery.toSpatialJoinConfiguration();

for (auto& sub : candidatesIn) {
auto add = [this, &sub, &config, &candidatesOut](bool rightVarOutside) {
// This helper function adds a subtree plan to the output candidates, which
// either has the child graph pattern as a right child or no child at all.
// If it has no child at all, the query planner may look for the right child
// of the SpatialJoin outside of the SERVICE. This is only allowed for max
// distance joins.
auto addCandidateSpatialJoin = [this, &sub, &config,
&candidatesOut](bool rightVarOutside) {
std::optional<std::shared_ptr<QueryExecutionTree>> right = std::nullopt;
if (!rightVarOutside) {
right = std::move(sub._qet);
Expand All @@ -2490,9 +2496,15 @@ void QueryPlanner::GraphPatternPlanner::visitSpatialSearch(
auto plan = makeSubtreePlan<SpatialJoin>(std::move(spatialJoin));
candidatesOut.push_back(std::move(plan));
};
add(false);
if (std::holds_alternative<MaxDistanceConfig>(config.task_)) {
add(true);

if (!spatialQuery.childGraphPattern_._graphPatterns.empty()) {
// The version using the child graph pattern
addCandidateSpatialJoin(false);
} else {
// The version without using the child graph pattern
if (std::holds_alternative<MaxDistanceConfig>(config.task_)) {
addCandidateSpatialJoin(true);
}
}
}
visitGroupOptionalOrMinus(std::move(candidatesOut));
Expand Down

0 comments on commit d0f7d82

Please sign in to comment.