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