Search in sources :

Example 1 with UnorderedPrimaryKeyDistinctVisitor

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

the class RecordQueryPlanner method tryToConvertToCoveringPlan.

@Nonnull
@SuppressWarnings("PMD.CompareObjectsWithEquals")
private RecordQueryPlan tryToConvertToCoveringPlan(@Nonnull PlanContext planContext, @Nonnull RecordQueryPlan chosenPlan) {
    if (planContext.query.getRequiredResults() == null) {
        // This should already be true when calling, but as a safety precaution, check here anyway.
        return chosenPlan;
    }
    final Set<KeyExpression> resultFields = new HashSet<>(planContext.query.getRequiredResults().size());
    for (KeyExpression resultField : planContext.query.getRequiredResults()) {
        resultFields.addAll(resultField.normalizeKeyForPositions());
    }
    chosenPlan = chosenPlan.accept(new UnorderedPrimaryKeyDistinctVisitor(metaData, indexTypes, planContext.commonPrimaryKey));
    @Nullable RecordQueryPlan withoutFetch = RecordQueryPlannerSubstitutionVisitor.removeIndexFetch(metaData, indexTypes, planContext.commonPrimaryKey, chosenPlan, resultFields);
    return withoutFetch == null ? chosenPlan : withoutFetch;
}
Also used : RecordQueryPlan(com.apple.foundationdb.record.query.plan.plans.RecordQueryPlan) UnorderedPrimaryKeyDistinctVisitor(com.apple.foundationdb.record.query.plan.visitor.UnorderedPrimaryKeyDistinctVisitor) RecordTypeKeyExpression(com.apple.foundationdb.record.metadata.expressions.RecordTypeKeyExpression) VersionKeyExpression(com.apple.foundationdb.record.metadata.expressions.VersionKeyExpression) GroupingKeyExpression(com.apple.foundationdb.record.metadata.expressions.GroupingKeyExpression) KeyExpression(com.apple.foundationdb.record.metadata.expressions.KeyExpression) FieldKeyExpression(com.apple.foundationdb.record.metadata.expressions.FieldKeyExpression) NestingKeyExpression(com.apple.foundationdb.record.metadata.expressions.NestingKeyExpression) EmptyKeyExpression(com.apple.foundationdb.record.metadata.expressions.EmptyKeyExpression) ThenKeyExpression(com.apple.foundationdb.record.metadata.expressions.ThenKeyExpression) Nullable(javax.annotation.Nullable) HashSet(java.util.HashSet) Nonnull(javax.annotation.Nonnull) SpotBugsSuppressWarnings(com.apple.foundationdb.annotation.SpotBugsSuppressWarnings)

Aggregations

SpotBugsSuppressWarnings (com.apple.foundationdb.annotation.SpotBugsSuppressWarnings)1 EmptyKeyExpression (com.apple.foundationdb.record.metadata.expressions.EmptyKeyExpression)1 FieldKeyExpression (com.apple.foundationdb.record.metadata.expressions.FieldKeyExpression)1 GroupingKeyExpression (com.apple.foundationdb.record.metadata.expressions.GroupingKeyExpression)1 KeyExpression (com.apple.foundationdb.record.metadata.expressions.KeyExpression)1 NestingKeyExpression (com.apple.foundationdb.record.metadata.expressions.NestingKeyExpression)1 RecordTypeKeyExpression (com.apple.foundationdb.record.metadata.expressions.RecordTypeKeyExpression)1 ThenKeyExpression (com.apple.foundationdb.record.metadata.expressions.ThenKeyExpression)1 VersionKeyExpression (com.apple.foundationdb.record.metadata.expressions.VersionKeyExpression)1 RecordQueryPlan (com.apple.foundationdb.record.query.plan.plans.RecordQueryPlan)1 UnorderedPrimaryKeyDistinctVisitor (com.apple.foundationdb.record.query.plan.visitor.UnorderedPrimaryKeyDistinctVisitor)1 HashSet (java.util.HashSet)1 Nonnull (javax.annotation.Nonnull)1 Nullable (javax.annotation.Nullable)1