Search in sources :

Example 1 with RecordQueryUnorderedPrimaryKeyDistinctPlan

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

the class PushDistinctBelowFilterRule method onMatch.

@Override
public void onMatch(@Nonnull PlannerRuleCall call) {
    final ExpressionRef<? extends RelationalExpression> inner = call.get(innerRefMatcher);
    final Quantifier.Physical qun = call.get(innerQuantifierMatcher);
    final RecordQueryPredicatesFilterPlan filterPlan = call.get(filterPlanMatcher);
    final RecordQueryUnorderedPrimaryKeyDistinctPlan newDistinctPlan = new RecordQueryUnorderedPrimaryKeyDistinctPlan(Quantifier.physical(inner));
    final Quantifier.Physical newQun = Quantifier.physical(call.ref(newDistinctPlan));
    final List<QueryPredicate> rebasedPredicates = filterPlan.getPredicates().stream().map(queryPredicate -> queryPredicate.rebase(Quantifiers.translate(qun, newQun))).collect(ImmutableList.toImmutableList());
    call.yield(call.ref(new RecordQueryPredicatesFilterPlan(newQun, rebasedPredicates)));
}
Also used : PlannerRuleCall(com.apple.foundationdb.record.query.plan.temp.PlannerRuleCall) PlannerRule(com.apple.foundationdb.record.query.plan.temp.PlannerRule) QuantifierMatchers.physicalQuantifier(com.apple.foundationdb.record.query.plan.temp.matchers.QuantifierMatchers.physicalQuantifier) Quantifier(com.apple.foundationdb.record.query.plan.temp.Quantifier) QueryPredicate(com.apple.foundationdb.record.query.predicates.QueryPredicate) Quantifiers(com.apple.foundationdb.record.query.plan.temp.Quantifiers) RecordQueryPredicatesFilterPlan(com.apple.foundationdb.record.query.plan.plans.RecordQueryPredicatesFilterPlan) QuantifierMatchers.physicalQuantifierOverRef(com.apple.foundationdb.record.query.plan.temp.matchers.QuantifierMatchers.physicalQuantifierOverRef) RelationalExpression(com.apple.foundationdb.record.query.plan.temp.RelationalExpression) List(java.util.List) BindingMatcher(com.apple.foundationdb.record.query.plan.temp.matchers.BindingMatcher) ImmutableList(com.google.common.collect.ImmutableList) RecordQueryUnorderedPrimaryKeyDistinctPlan(com.apple.foundationdb.record.query.plan.plans.RecordQueryUnorderedPrimaryKeyDistinctPlan) ReferenceMatchers.anyRefOverOnlyPlans(com.apple.foundationdb.record.query.plan.temp.matchers.ReferenceMatchers.anyRefOverOnlyPlans) ExpressionRef(com.apple.foundationdb.record.query.plan.temp.ExpressionRef) ListMatcher.exactly(com.apple.foundationdb.record.query.plan.temp.matchers.ListMatcher.exactly) RecordQueryPlanMatchers(com.apple.foundationdb.record.query.plan.temp.matchers.RecordQueryPlanMatchers) Nonnull(javax.annotation.Nonnull) QueryPredicate(com.apple.foundationdb.record.query.predicates.QueryPredicate) RecordQueryPredicatesFilterPlan(com.apple.foundationdb.record.query.plan.plans.RecordQueryPredicatesFilterPlan) QuantifierMatchers.physicalQuantifier(com.apple.foundationdb.record.query.plan.temp.matchers.QuantifierMatchers.physicalQuantifier) Quantifier(com.apple.foundationdb.record.query.plan.temp.Quantifier) RecordQueryUnorderedPrimaryKeyDistinctPlan(com.apple.foundationdb.record.query.plan.plans.RecordQueryUnorderedPrimaryKeyDistinctPlan)

Example 2 with RecordQueryUnorderedPrimaryKeyDistinctPlan

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

the class UnorderedPrimaryKeyDistinctVisitor method postVisit.

@Nonnull
@Override
public RecordQueryPlan postVisit(@Nonnull final RecordQueryPlan recordQueryPlan) {
    if (recordQueryPlan instanceof RecordQueryUnorderedPrimaryKeyDistinctPlan) {
        RecordQueryUnorderedPrimaryKeyDistinctPlan distinctPlan = (RecordQueryUnorderedPrimaryKeyDistinctPlan) recordQueryPlan;
        @Nullable RecordQueryPlan newPlan = removeIndexFetch(distinctPlan.getChild(), Collections.emptySet());
        if (newPlan != null) {
            return new RecordQueryFetchFromPartialRecordPlan(new RecordQueryUnorderedPrimaryKeyDistinctPlan(newPlan), TranslateValueFunction.unableToTranslate());
        }
    }
    return recordQueryPlan;
}
Also used : RecordQueryPlan(com.apple.foundationdb.record.query.plan.plans.RecordQueryPlan) RecordQueryFetchFromPartialRecordPlan(com.apple.foundationdb.record.query.plan.plans.RecordQueryFetchFromPartialRecordPlan) Nullable(javax.annotation.Nullable) RecordQueryUnorderedPrimaryKeyDistinctPlan(com.apple.foundationdb.record.query.plan.plans.RecordQueryUnorderedPrimaryKeyDistinctPlan) Nonnull(javax.annotation.Nonnull)

Example 3 with RecordQueryUnorderedPrimaryKeyDistinctPlan

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

the class PushDistinctThroughFetchRule method onMatch.

@Override
public void onMatch(@Nonnull PlannerRuleCall call) {
    final PlannerBindings bindings = call.getBindings();
    final RecordQueryFetchFromPartialRecordPlan fetchPlan = bindings.get(fetchPlanMatcher);
    final RecordQueryPlan innerPlan = bindings.get(innerPlanMatcher);
    final CorrelationIdentifier newInnerAlias = CorrelationIdentifier.uniqueID();
    final Quantifier.Physical newInnerQuantifier = Quantifier.physical(GroupExpressionRef.of(innerPlan), newInnerAlias);
    final RecordQueryUnorderedPrimaryKeyDistinctPlan pushedDistinctPlan = new RecordQueryUnorderedPrimaryKeyDistinctPlan(newInnerQuantifier);
    final RecordQueryFetchFromPartialRecordPlan newFetchPlan = new RecordQueryFetchFromPartialRecordPlan(pushedDistinctPlan, fetchPlan.getPushValueFunction());
    // case 2
    call.yield(call.ref(newFetchPlan));
}
Also used : RecordQueryPlan(com.apple.foundationdb.record.query.plan.plans.RecordQueryPlan) RecordQueryFetchFromPartialRecordPlan(com.apple.foundationdb.record.query.plan.plans.RecordQueryFetchFromPartialRecordPlan) CorrelationIdentifier(com.apple.foundationdb.record.query.plan.temp.CorrelationIdentifier) PlannerBindings(com.apple.foundationdb.record.query.plan.temp.matchers.PlannerBindings) Quantifier(com.apple.foundationdb.record.query.plan.temp.Quantifier) RecordQueryUnorderedPrimaryKeyDistinctPlan(com.apple.foundationdb.record.query.plan.plans.RecordQueryUnorderedPrimaryKeyDistinctPlan)

Aggregations

RecordQueryUnorderedPrimaryKeyDistinctPlan (com.apple.foundationdb.record.query.plan.plans.RecordQueryUnorderedPrimaryKeyDistinctPlan)3 RecordQueryFetchFromPartialRecordPlan (com.apple.foundationdb.record.query.plan.plans.RecordQueryFetchFromPartialRecordPlan)2 RecordQueryPlan (com.apple.foundationdb.record.query.plan.plans.RecordQueryPlan)2 Quantifier (com.apple.foundationdb.record.query.plan.temp.Quantifier)2 Nonnull (javax.annotation.Nonnull)2 RecordQueryPredicatesFilterPlan (com.apple.foundationdb.record.query.plan.plans.RecordQueryPredicatesFilterPlan)1 CorrelationIdentifier (com.apple.foundationdb.record.query.plan.temp.CorrelationIdentifier)1 ExpressionRef (com.apple.foundationdb.record.query.plan.temp.ExpressionRef)1 PlannerRule (com.apple.foundationdb.record.query.plan.temp.PlannerRule)1 PlannerRuleCall (com.apple.foundationdb.record.query.plan.temp.PlannerRuleCall)1 Quantifiers (com.apple.foundationdb.record.query.plan.temp.Quantifiers)1 RelationalExpression (com.apple.foundationdb.record.query.plan.temp.RelationalExpression)1 BindingMatcher (com.apple.foundationdb.record.query.plan.temp.matchers.BindingMatcher)1 ListMatcher.exactly (com.apple.foundationdb.record.query.plan.temp.matchers.ListMatcher.exactly)1 PlannerBindings (com.apple.foundationdb.record.query.plan.temp.matchers.PlannerBindings)1 QuantifierMatchers.physicalQuantifier (com.apple.foundationdb.record.query.plan.temp.matchers.QuantifierMatchers.physicalQuantifier)1 QuantifierMatchers.physicalQuantifierOverRef (com.apple.foundationdb.record.query.plan.temp.matchers.QuantifierMatchers.physicalQuantifierOverRef)1 RecordQueryPlanMatchers (com.apple.foundationdb.record.query.plan.temp.matchers.RecordQueryPlanMatchers)1 ReferenceMatchers.anyRefOverOnlyPlans (com.apple.foundationdb.record.query.plan.temp.matchers.ReferenceMatchers.anyRefOverOnlyPlans)1 QueryPredicate (com.apple.foundationdb.record.query.predicates.QueryPredicate)1