Skip to content

Commit

Permalink
Fix execution planning of MATCH statement with optional nodes on empt…
Browse files Browse the repository at this point in the history
…y classes
  • Loading branch information
luigidellaquila committed Oct 10, 2018
1 parent f619737 commit f26edd7
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@ public OInternalExecutionPlan createExecutionPlan(OCommandContext context, boole
Map<String, Long> estimatedRootEntries = estimateRootEntries(aliasClasses, aliasClusters, aliasRids, aliasFilters, context);
Set<String> aliasesToPrefetch = estimatedRootEntries.entrySet().stream().filter(x -> x.getValue() < this.threshold).
map(x -> x.getKey()).collect(Collectors.toSet());
if (estimatedRootEntries.values().contains(0l)) {
result.chain(new EmptyStep(context, enableProfiling));
return result;
for (Map.Entry<String, Long> entry : estimatedRootEntries.entrySet()) {
if (entry.getValue() == 0L && !isOptional(entry.getKey())) {
result.chain(new EmptyStep(context, enableProfiling));
return result;
}
}

addPrefetchSteps(result, aliasesToPrefetch, context, enableProfiling);
Expand Down Expand Up @@ -156,6 +158,11 @@ public OInternalExecutionPlan createExecutionPlan(OCommandContext context, boole

}

private boolean isOptional(String key) {
PatternNode node = this.pattern.aliasToNode.get(key);
return node != null && node.isOptionalNode();
}

private void manageNotPatterns(OSelectExecutionPlan result, Pattern pattern, List<OMatchExpression> notMatchExpressions,
OCommandContext context, boolean enableProfiling) {
for (OMatchExpression exp : notMatchExpressions) {
Expand Down

0 comments on commit f26edd7

Please sign in to comment.