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)));
}
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;
}
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));
}
Aggregations