use of com.apple.foundationdb.record.query.plan.temp.LinkedIdentitySet in project fdb-record-layer by FoundationDB.
the class RelationalExpressionWithChildren method computeMappedQuantifiers.
@Nonnull
default Set<Quantifier> computeMappedQuantifiers(@Nonnull final PartialMatch partialMatch) {
final var matchInfo = partialMatch.getMatchInfo();
final var mappedForEachQuantifiers = new LinkedIdentitySet<Quantifier>();
for (final Quantifier quantifier : getQuantifiers()) {
if (matchInfo.getChildPartialMatch(quantifier.getAlias()).isPresent()) {
mappedForEachQuantifiers.add(quantifier);
}
}
return mappedForEachQuantifiers;
}
use of com.apple.foundationdb.record.query.plan.temp.LinkedIdentitySet in project fdb-record-layer by FoundationDB.
the class RelationalExpressionWithChildren method computeUnmatchedForEachQuantifiers.
@Nonnull
@Override
default Set<Quantifier.ForEach> computeUnmatchedForEachQuantifiers(@Nonnull final PartialMatch partialMatch) {
final MatchInfo matchInfo = partialMatch.getMatchInfo();
final Set<Quantifier.ForEach> unmappedForEachQuantifiers = new LinkedIdentitySet<>();
for (final Quantifier quantifier : getQuantifiers()) {
if (quantifier instanceof Quantifier.ForEach && !matchInfo.getChildPartialMatch(quantifier.getAlias()).isPresent()) {
unmappedForEachQuantifiers.add((Quantifier.ForEach) quantifier);
}
}
return unmappedForEachQuantifiers;
}
use of com.apple.foundationdb.record.query.plan.temp.LinkedIdentitySet in project fdb-record-layer by FoundationDB.
the class MatchIntermediateRule method onMatch.
@Override
public void onMatch(@Nonnull PlannerRuleCall call) {
final PlannerBindings bindings = call.getBindings();
final RelationalExpression expression = bindings.get(root);
final List<? extends Quantifier> quantifiers = bindings.getAll(quantifierMatcher);
final ImmutableList<? extends ExpressionRef<? extends RelationalExpression>> rangesOverRefs = quantifiers.stream().map(Quantifier::getRangesOver).collect(ImmutableList.toImmutableList());
// form union of all possible match candidates that this rule application should look at
final Set<MatchCandidate> childMatchCandidates = new LinkedIdentitySet<>();
for (int i = 0; i < rangesOverRefs.size(); i++) {
final ExpressionRef<? extends RelationalExpression> rangesOverGroup = rangesOverRefs.get(i);
childMatchCandidates.addAll(rangesOverGroup.getMatchCandidates());
}
// go through all match candidates
for (final MatchCandidate matchCandidate : childMatchCandidates) {
final SetMultimap<ExpressionRef<? extends RelationalExpression>, RelationalExpression> refToExpressionMap = matchCandidate.findReferencingExpressions(rangesOverRefs);
// go through all reference paths, i.e., (ref, expression) pairs
for (final Map.Entry<ExpressionRef<? extends RelationalExpression>, RelationalExpression> entry : refToExpressionMap.entries()) {
final ExpressionRef<? extends RelationalExpression> candidateReference = entry.getKey();
final RelationalExpression candidateExpression = entry.getValue();
// match this expression with the candidate expression and yield zero to n new partial matches
final Iterable<BoundMatch<MatchInfo>> boundMatchInfos = matchWithCandidate(expression, matchCandidate, candidateExpression);
boundMatchInfos.forEach(boundMatchInfo -> call.yieldPartialMatch(boundMatchInfo.getAliasMap(), matchCandidate, expression, candidateReference, boundMatchInfo.getMatchResult()));
}
}
}
Aggregations