Search in sources :

Example 6 with MatchCandidate

use of com.apple.foundationdb.record.query.plan.temp.MatchCandidate in project fdb-record-layer by FoundationDB.

the class MatchLeafRule method onMatch.

@Override
public void onMatch(@Nonnull PlannerRuleCall call) {
    final PlanContext context = call.getContext();
    final RelationalExpression expression = call.get(root);
    // iterate through all candidates known to the context
    for (final MatchCandidate matchCandidate : context.getMatchCandidates()) {
        final ExpressionRefTraversal traversal = matchCandidate.getTraversal();
        final Set<ExpressionRef<? extends RelationalExpression>> leafRefs = traversal.getLeafReferences();
        // iterate through all leaf references in all
        for (final ExpressionRef<? extends RelationalExpression> leafRef : leafRefs) {
            for (final RelationalExpression leafMember : leafRef.getMembers()) {
                // expressions.
                if (leafMember.getQuantifiers().isEmpty()) {
                    final Iterable<BoundMatch<MatchInfo>> boundMatchInfos = matchWithCandidate(expression, leafMember);
                    // yield any match to the planner
                    boundMatchInfos.forEach(boundMatchInfo -> call.yieldPartialMatch(boundMatchInfo.getAliasMap(), matchCandidate, expression, leafRef, boundMatchInfo.getMatchResult()));
                }
            }
        }
    }
}
Also used : RelationalExpression(com.apple.foundationdb.record.query.plan.temp.RelationalExpression) ExpressionRefTraversal(com.apple.foundationdb.record.query.plan.temp.ExpressionRefTraversal) ExpressionRef(com.apple.foundationdb.record.query.plan.temp.ExpressionRef) PlanContext(com.apple.foundationdb.record.query.plan.temp.PlanContext) BoundMatch(com.apple.foundationdb.record.query.plan.temp.matching.BoundMatch) MatchCandidate(com.apple.foundationdb.record.query.plan.temp.MatchCandidate)

Aggregations

MatchCandidate (com.apple.foundationdb.record.query.plan.temp.MatchCandidate)6 RelationalExpression (com.apple.foundationdb.record.query.plan.temp.RelationalExpression)6 ExpressionRef (com.apple.foundationdb.record.query.plan.temp.ExpressionRef)5 Map (java.util.Map)5 PartialMatch (com.apple.foundationdb.record.query.plan.temp.PartialMatch)4 GroupExpressionRef (com.apple.foundationdb.record.query.plan.temp.GroupExpressionRef)3 PlannerBindings (com.apple.foundationdb.record.query.plan.temp.matchers.PlannerBindings)3 ImmutableList (com.google.common.collect.ImmutableList)3 ImmutableMap (com.google.common.collect.ImmutableMap)3 ImmutableSet (com.google.common.collect.ImmutableSet)3 Iterables (com.google.common.collect.Iterables)3 List (java.util.List)3 Objects (java.util.Objects)3 API (com.apple.foundationdb.annotation.API)2 RecordCoreException (com.apple.foundationdb.record.RecordCoreException)2 KeyExpression (com.apple.foundationdb.record.metadata.expressions.KeyExpression)2 AliasMap (com.apple.foundationdb.record.query.plan.temp.AliasMap)2 BoundKeyPart (com.apple.foundationdb.record.query.plan.temp.BoundKeyPart)2 ComparisonRange (com.apple.foundationdb.record.query.plan.temp.ComparisonRange)2 CorrelationIdentifier (com.apple.foundationdb.record.query.plan.temp.CorrelationIdentifier)2