Search in sources :

Example 26 with RelationalExpression

use of com.apple.foundationdb.record.query.plan.temp.RelationalExpression 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

RelationalExpression (com.apple.foundationdb.record.query.plan.temp.RelationalExpression)26 ExpressionRef (com.apple.foundationdb.record.query.plan.temp.ExpressionRef)12 Quantifier (com.apple.foundationdb.record.query.plan.temp.Quantifier)11 Nonnull (javax.annotation.Nonnull)10 ImmutableList (com.google.common.collect.ImmutableList)9 List (java.util.List)9 Test (org.junit.jupiter.api.Test)9 PartialMatch (com.apple.foundationdb.record.query.plan.temp.PartialMatch)8 API (com.apple.foundationdb.annotation.API)7 GroupExpressionRef (com.apple.foundationdb.record.query.plan.temp.GroupExpressionRef)7 MatchCandidate (com.apple.foundationdb.record.query.plan.temp.MatchCandidate)7 Collection (java.util.Collection)7 Map (java.util.Map)7 Nullable (javax.annotation.Nullable)7 RecordQueryScanPlan (com.apple.foundationdb.record.query.plan.plans.RecordQueryScanPlan)6 PlannerBindings (com.apple.foundationdb.record.query.plan.temp.matchers.PlannerBindings)6 QueryPredicate (com.apple.foundationdb.record.query.predicates.QueryPredicate)6 ImmutableSet (com.google.common.collect.ImmutableSet)6 Optional (java.util.Optional)6 Set (java.util.Set)6