Search in sources :

Example 26 with FDBStoreTimer

use of com.apple.foundationdb.record.provider.foundationdb.FDBStoreTimer in project fdb-record-layer by FoundationDB.

the class QueryPlanStructuralInstrumentationTest method indexPlan.

@Test
public void indexPlan() {
    final String indexName = "an_index";
    StoreTimer timer = new FDBStoreTimer();
    RecordQueryPlan plan = indexPlanEquals(indexName, VALUE);
    plan.logPlanStructure(timer);
    assertUsesIndexes(plan, Lists.newArrayList(indexName));
    assertEquals(timer.getCount(FDBStoreTimer.Counts.PLAN_INDEX), 1);
}
Also used : RecordQueryPlan(com.apple.foundationdb.record.query.plan.plans.RecordQueryPlan) StoreTimer(com.apple.foundationdb.record.provider.common.StoreTimer) FDBStoreTimer(com.apple.foundationdb.record.provider.foundationdb.FDBStoreTimer) FDBStoreTimer(com.apple.foundationdb.record.provider.foundationdb.FDBStoreTimer) Test(org.junit.jupiter.api.Test)

Example 27 with FDBStoreTimer

use of com.apple.foundationdb.record.provider.foundationdb.FDBStoreTimer in project fdb-record-layer by FoundationDB.

the class QueryPlanStructuralInstrumentationTest method fullScan.

@Test
public void fullScan() {
    StoreTimer timer = new FDBStoreTimer();
    RecordQueryPlan plan = new RecordQueryScanPlan(ScanComparisons.EMPTY, false);
    plan.logPlanStructure(timer);
    assertNoIndexes(plan);
    assertEquals(timer.getCount(FDBStoreTimer.Counts.PLAN_SCAN), 1);
}
Also used : RecordQueryPlan(com.apple.foundationdb.record.query.plan.plans.RecordQueryPlan) StoreTimer(com.apple.foundationdb.record.provider.common.StoreTimer) FDBStoreTimer(com.apple.foundationdb.record.provider.foundationdb.FDBStoreTimer) RecordQueryScanPlan(com.apple.foundationdb.record.query.plan.plans.RecordQueryScanPlan) FDBStoreTimer(com.apple.foundationdb.record.provider.foundationdb.FDBStoreTimer) Test(org.junit.jupiter.api.Test)

Example 28 with FDBStoreTimer

use of com.apple.foundationdb.record.provider.foundationdb.FDBStoreTimer in project fdb-record-layer by FoundationDB.

the class QueryPlanStructuralInstrumentationTest method unionSameIndex.

@Test
public void unionSameIndex() {
    final RecordQueryPlan plan = RecordQueryUnionPlan.from(indexPlanEquals("index_1", 2), indexPlanEquals("index_1", 4), EmptyKeyExpression.EMPTY, false);
    assertUsesIndexes(plan, Lists.newArrayList("index_1"));
    final StoreTimer timer = new FDBStoreTimer();
    plan.logPlanStructure(timer);
    assertEquals(timer.getCount(FDBStoreTimer.Counts.PLAN_UNION), 1);
    assertEquals(timer.getCount(FDBStoreTimer.Counts.PLAN_INDEX), 2);
}
Also used : RecordQueryPlan(com.apple.foundationdb.record.query.plan.plans.RecordQueryPlan) StoreTimer(com.apple.foundationdb.record.provider.common.StoreTimer) FDBStoreTimer(com.apple.foundationdb.record.provider.foundationdb.FDBStoreTimer) FDBStoreTimer(com.apple.foundationdb.record.provider.foundationdb.FDBStoreTimer) Test(org.junit.jupiter.api.Test)

Example 29 with FDBStoreTimer

use of com.apple.foundationdb.record.provider.foundationdb.FDBStoreTimer in project fdb-record-layer by FoundationDB.

the class RecordQuerySortPlan method executePlan.

@Nonnull
@Override
public <M extends Message> RecordCursor<QueryResult> executePlan(@Nonnull FDBRecordStoreBase<M> store, @Nonnull EvaluationContext context, @Nullable byte[] continuation, @Nonnull ExecuteProperties executeProperties) {
    // Since we are sorting, we need to feed through everything from the inner plan,
    // even just to get the top few.
    final ExecuteProperties executeInner = executeProperties.clearSkipAndLimit();
    final Function<byte[], RecordCursor<FDBQueriedRecord<M>>> innerCursor = innerContinuation -> getChild().executePlan(store, context, innerContinuation, executeInner).map(result -> result.<M>getQueriedRecord(0));
    final int skip = executeProperties.getSkip();
    final int limit = executeProperties.getReturnedRowLimitOrMax();
    final int maxRecordsToRead = limit == Integer.MAX_VALUE ? limit : skip + limit;
    final RecordQuerySortAdapter<M> adapter = key.getAdapter(store, maxRecordsToRead);
    final FDBStoreTimer timer = store.getTimer();
    final RecordCursor<FDBQueriedRecord<M>> sorted;
    if (adapter.isMemoryOnly()) {
        sorted = MemorySortCursor.create(adapter, innerCursor, timer, continuation).skipThenLimit(skip, limit);
    } else {
        sorted = FileSortCursor.create(adapter, innerCursor, timer, continuation, skip, limit);
    }
    return sorted.map(QueryResult::of);
}
Also used : Iterables(com.google.common.collect.Iterables) QueryResult(com.apple.foundationdb.record.query.plan.plans.QueryResult) StoreTimer(com.apple.foundationdb.record.provider.common.StoreTimer) Quantifier(com.apple.foundationdb.record.query.plan.temp.Quantifier) GroupExpressionRef(com.apple.foundationdb.record.query.plan.temp.GroupExpressionRef) RecordQueryPlan(com.apple.foundationdb.record.query.plan.plans.RecordQueryPlan) Function(java.util.function.Function) PlanHashable(com.apple.foundationdb.record.PlanHashable) RecordQueryPlanWithChild(com.apple.foundationdb.record.query.plan.plans.RecordQueryPlanWithChild) ExecuteProperties(com.apple.foundationdb.record.ExecuteProperties) FileSortCursor(com.apple.foundationdb.record.sorting.FileSortCursor) ImmutableList(com.google.common.collect.ImmutableList) AliasMap(com.apple.foundationdb.record.query.plan.temp.AliasMap) Nonnull(javax.annotation.Nonnull) Nullable(javax.annotation.Nullable) FDBRecordStoreBase(com.apple.foundationdb.record.provider.foundationdb.FDBRecordStoreBase) ImmutableSet(com.google.common.collect.ImmutableSet) MemorySortCursor(com.apple.foundationdb.record.sorting.MemorySortCursor) FDBStoreTimer(com.apple.foundationdb.record.provider.foundationdb.FDBStoreTimer) Set(java.util.Set) QueriedValue(com.apple.foundationdb.record.query.predicates.QueriedValue) RelationalExpression(com.apple.foundationdb.record.query.plan.temp.RelationalExpression) Objects(java.util.Objects) Value(com.apple.foundationdb.record.query.predicates.Value) List(java.util.List) CorrelationIdentifier(com.apple.foundationdb.record.query.plan.temp.CorrelationIdentifier) EvaluationContext(com.apple.foundationdb.record.EvaluationContext) ObjectPlanHash(com.apple.foundationdb.record.ObjectPlanHash) FDBQueriedRecord(com.apple.foundationdb.record.provider.foundationdb.FDBQueriedRecord) Message(com.google.protobuf.Message) RecordCursor(com.apple.foundationdb.record.RecordCursor) API(com.apple.foundationdb.annotation.API) PlannerGraph(com.apple.foundationdb.record.query.plan.temp.explain.PlannerGraph) NodeInfo(com.apple.foundationdb.record.query.plan.temp.explain.NodeInfo) AvailableFields(com.apple.foundationdb.record.query.plan.AvailableFields) ExecuteProperties(com.apple.foundationdb.record.ExecuteProperties) QueryResult(com.apple.foundationdb.record.query.plan.plans.QueryResult) RecordCursor(com.apple.foundationdb.record.RecordCursor) FDBQueriedRecord(com.apple.foundationdb.record.provider.foundationdb.FDBQueriedRecord) FDBStoreTimer(com.apple.foundationdb.record.provider.foundationdb.FDBStoreTimer) Nonnull(javax.annotation.Nonnull)

Aggregations

FDBStoreTimer (com.apple.foundationdb.record.provider.foundationdb.FDBStoreTimer)29 Test (org.junit.jupiter.api.Test)21 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)15 FDBRecordContext (com.apple.foundationdb.record.provider.foundationdb.FDBRecordContext)14 FDBDatabase (com.apple.foundationdb.record.provider.foundationdb.FDBDatabase)9 Nonnull (javax.annotation.Nonnull)9 Arrays (java.util.Arrays)8 List (java.util.List)8 Function (java.util.function.Function)8 Collections (java.util.Collections)7 CompletableFuture (java.util.concurrent.CompletableFuture)7 Collectors (java.util.stream.Collectors)7 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)7 Assertions.assertFalse (org.junit.jupiter.api.Assertions.assertFalse)7 RecordCursor (com.apple.foundationdb.record.RecordCursor)6 FirableCursor (com.apple.foundationdb.record.cursors.FirableCursor)6 StoreTimer (com.apple.foundationdb.record.provider.common.StoreTimer)6 RecordQueryPlan (com.apple.foundationdb.record.query.plan.plans.RecordQueryPlan)6 Iterator (java.util.Iterator)6 ExecutionException (java.util.concurrent.ExecutionException)6