Search in sources :

Example 11 with RecordQueryScanPlan

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

the class UnmatchedFieldsCountProperty method evaluateAtExpression.

@Nonnull
@Override
public Integer evaluateAtExpression(@Nonnull RelationalExpression expression, @Nonnull List<Integer> childResults) {
    int total = 0;
    for (Integer result : childResults) {
        if (result != null) {
            total += result;
        }
    }
    if (expression instanceof RecordQueryCoveringIndexPlan) {
        expression = ((RecordQueryCoveringIndexPlan) expression).getIndexPlan();
    }
    final int columnSize;
    if (expression instanceof RecordQueryPlanWithComparisons) {
        final ScanComparisons comparisons = ((RecordQueryPlanWithComparisons) expression).getComparisons();
        if (expression instanceof RecordQueryPlanWithIndex) {
            final String indexName = ((RecordQueryPlanWithIndex) expression).getIndexName();
            columnSize = planContext.getIndexByName(indexName).getRootExpression().getColumnSize();
        } else if (expression instanceof RecordQueryScanPlan) {
            columnSize = planContext.getGreatestPrimaryKeyWidth();
        } else {
            throw new RecordCoreException("unhandled plan with comparisons: can't find key expression");
        }
        return total + columnSize - (comparisons.getEqualitySize() + (comparisons.isEquality() ? 0 : 1));
    } else {
        return total;
    }
}
Also used : RecordCoreException(com.apple.foundationdb.record.RecordCoreException) ScanComparisons(com.apple.foundationdb.record.query.plan.ScanComparisons) RecordQueryPlanWithComparisons(com.apple.foundationdb.record.query.plan.plans.RecordQueryPlanWithComparisons) RecordQueryScanPlan(com.apple.foundationdb.record.query.plan.plans.RecordQueryScanPlan) RecordQueryCoveringIndexPlan(com.apple.foundationdb.record.query.plan.plans.RecordQueryCoveringIndexPlan) RecordQueryPlanWithIndex(com.apple.foundationdb.record.query.plan.plans.RecordQueryPlanWithIndex) Nonnull(javax.annotation.Nonnull)

Example 12 with RecordQueryScanPlan

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

the class ImplementPhysicalScanRule method onMatch.

@Override
public void onMatch(@Nonnull PlannerRuleCall call) {
    final PrimaryScanExpression logical = call.get(root);
    call.yield(call.ref(new RecordQueryScanPlan(logical.getRecordTypes(), logical.scanComparisons(), logical.isReverse())));
}
Also used : RecordQueryScanPlan(com.apple.foundationdb.record.query.plan.plans.RecordQueryScanPlan) PrimaryScanExpression(com.apple.foundationdb.record.query.plan.temp.expressions.PrimaryScanExpression)

Aggregations

RecordQueryScanPlan (com.apple.foundationdb.record.query.plan.plans.RecordQueryScanPlan)12 RecordQueryIndexPlan (com.apple.foundationdb.record.query.plan.plans.RecordQueryIndexPlan)7 Test (org.junit.jupiter.api.Test)6 IndexScanParameters (com.apple.foundationdb.record.provider.foundationdb.IndexScanParameters)5 RelationalExpression (com.apple.foundationdb.record.query.plan.temp.RelationalExpression)5 RecordQueryUnionPlan (com.apple.foundationdb.record.query.plan.plans.RecordQueryUnionPlan)4 RecordQueryPlan (com.apple.foundationdb.record.query.plan.plans.RecordQueryPlan)3 QueryComponent (com.apple.foundationdb.record.query.expressions.QueryComponent)2 RecordQueryFilterPlan (com.apple.foundationdb.record.query.plan.plans.RecordQueryFilterPlan)2 RecordQueryPlanWithIndex (com.apple.foundationdb.record.query.plan.plans.RecordQueryPlanWithIndex)2 Quantifier (com.apple.foundationdb.record.query.plan.temp.Quantifier)2 LogicalFilterExpression (com.apple.foundationdb.record.query.plan.temp.expressions.LogicalFilterExpression)2 Nonnull (javax.annotation.Nonnull)2 RecordCoreException (com.apple.foundationdb.record.RecordCoreException)1 Index (com.apple.foundationdb.record.metadata.Index)1 KeyExpression (com.apple.foundationdb.record.metadata.expressions.KeyExpression)1 ThenKeyExpression (com.apple.foundationdb.record.metadata.expressions.ThenKeyExpression)1 StoreTimer (com.apple.foundationdb.record.provider.common.StoreTimer)1 FDBStoreTimer (com.apple.foundationdb.record.provider.foundationdb.FDBStoreTimer)1 IndexScanComparisons (com.apple.foundationdb.record.provider.foundationdb.IndexScanComparisons)1