@Override public SubstitutionResults<InnerJoinNode> applyAscendingSubstitution( ImmutableSubstitution<? extends ImmutableTerm> substitution, QueryNode childNode, IntermediateQuery query) { if (substitution.isEmpty()) { return DefaultSubstitutionResults.noChange(); } ImmutableSet<Variable> nullVariables = substitution.getImmutableMap().entrySet().stream() .filter(e -> e.getValue().equals(TermConstants.NULL)) .map(Map.Entry::getKey) .collect(ImmutableCollectors.toSet()); ImmutableSet<Variable > otherNodesProjectedVariables = query.getOtherChildrenStream(this, childNode) .flatMap(c -> query.getVariables(c).stream()) .collect(ImmutableCollectors.toSet()); /* * If there is an implicit equality involving one null variables, the join is empty. */ if (otherNodesProjectedVariables.stream() .anyMatch(nullVariables::contains)) { // Reject return DefaultSubstitutionResults.declareAsEmpty(); } return computeAndEvaluateNewCondition(substitution, Optional.empty()) .map(ev -> applyEvaluation(ev, substitution)) .orElseGet(() -> DefaultSubstitutionResults.noChange(substitution)); }
otherChildren = query.getOtherChildrenStream(currentAncestor, childOfAncestor); break; case NEW_NODE: optionalAncestryTracker.ifPresent(tr -> tr.recordReplacement(currentAncestor, newAncestor)); otherChildren = query.getOtherChildrenStream(newAncestor, childOfAncestor); childOfNextAncestor = newAncestor; break; case INSERT_CONSTRUCTION_NODE: QueryNode downgradedChildNode = substitutionResults.getOptionalDowngradedChildNode().get(); otherChildren = query.getOtherChildrenStream(currentAncestor, downgradedChildNode);