Search in sources :

Example 11 with FDBStoreTimer

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

the class ExtendedDirectoryLayerTest method testSetMappingDoesNotScanDirectoryKeySpace.

@Test
public void testSetMappingDoesNotScanDirectoryKeySpace() {
    FDBStoreTimer timer = new FDBStoreTimer();
    try (FDBRecordContext context = database.openContext()) {
        context.setTimer(timer);
        for (long i = 0; i < 10; i++) {
            globalScope.setMapping(context, "some-key-" + i, i).join();
        }
    }
    assertThat("there are no scans of the directory layer", timer.getCount(FDBStoreTimer.DetailEvents.RD_CACHE_DIRECTORY_SCAN), is(0));
}
Also used : FDBRecordContext(com.apple.foundationdb.record.provider.foundationdb.FDBRecordContext) FDBStoreTimer(com.apple.foundationdb.record.provider.foundationdb.FDBStoreTimer) Test(org.junit.jupiter.api.Test)

Example 12 with FDBStoreTimer

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

the class SyntheticRecordPlannerTest method initBuilders.

@BeforeEach
public void initBuilders() throws Exception {
    metaDataBuilder = RecordMetaData.newBuilder().setRecords(TestRecordsJoinIndexProto.getDescriptor());
    recordStoreBuilder = FDBRecordStore.newBuilder().setMetaDataProvider(metaDataBuilder);
    fdb = FDBDatabaseFactory.instance().getDatabase();
    timer = new FDBStoreTimer();
    fdb.run(timer, null, context -> {
        path = TestKeySpace.getKeyspacePath(PATH_OBJECTS);
        FDBRecordStore.deleteStore(context, path);
        recordStoreBuilder.setContext(context).setKeySpacePath(path);
        return null;
    });
}
Also used : FDBStoreTimer(com.apple.foundationdb.record.provider.foundationdb.FDBStoreTimer) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 13 with FDBStoreTimer

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

the class QueryPlanStructuralInstrumentationTest method unionDifferentIndex.

@Test
public void unionDifferentIndex() {
    final RecordQueryPlan plan = RecordQueryUnionPlan.from(indexPlanEquals("index_1", 2), indexPlanEquals("index_2", 4), EmptyKeyExpression.EMPTY, false);
    assertUsesIndexes(plan, Lists.newArrayList("index_1", "index_2"));
    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 14 with FDBStoreTimer

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

the class QueryPlanStructuralInstrumentationTest method in.

@Test
public void in() {
    final String indexName = "a_field";
    final IndexScanParameters scan = IndexScanComparisons.byValue(new ScanComparisons(Arrays.asList(new Comparisons.ParameterComparison(Comparisons.Type.EQUALS, "another_field")), Collections.emptySet()));
    final RecordQueryPlan plan = new RecordQueryInValuesJoinPlan(new RecordQueryIndexPlan(indexName, scan, false), "another_field", Bindings.Internal.IN, Arrays.asList(2, 4), false, false);
    assertUsesIndexes(plan, Lists.newArrayList(indexName));
    final StoreTimer timer = new FDBStoreTimer();
    plan.logPlanStructure(timer);
    assertEquals(timer.getCount(FDBStoreTimer.Counts.PLAN_IN_VALUES), 1);
    assertEquals(timer.getCount(FDBStoreTimer.Counts.PLAN_INDEX), 1);
}
Also used : RecordQueryPlan(com.apple.foundationdb.record.query.plan.plans.RecordQueryPlan) IndexScanParameters(com.apple.foundationdb.record.provider.foundationdb.IndexScanParameters) StoreTimer(com.apple.foundationdb.record.provider.common.StoreTimer) FDBStoreTimer(com.apple.foundationdb.record.provider.foundationdb.FDBStoreTimer) IndexScanComparisons(com.apple.foundationdb.record.provider.foundationdb.IndexScanComparisons) Comparisons(com.apple.foundationdb.record.query.expressions.Comparisons) IndexScanComparisons(com.apple.foundationdb.record.provider.foundationdb.IndexScanComparisons) FDBStoreTimer(com.apple.foundationdb.record.provider.foundationdb.FDBStoreTimer) RecordQueryIndexPlan(com.apple.foundationdb.record.query.plan.plans.RecordQueryIndexPlan) RecordQueryInValuesJoinPlan(com.apple.foundationdb.record.query.plan.plans.RecordQueryInValuesJoinPlan) Test(org.junit.jupiter.api.Test)

Example 15 with FDBStoreTimer

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

the class RecordCursorTest method pipelineWithInnerLimits.

@ParameterizedTest(name = "pipelineWithInnerLimits [outOfBand = {0}]")
@BooleanSource
public void pipelineWithInnerLimits(boolean outOfBand) {
    final RecordCursor.NoNextReason[] possibleNoNextReasons = new RecordCursor.NoNextReason[] { RecordCursor.NoNextReason.SOURCE_EXHAUSTED, outOfBand ? RecordCursor.NoNextReason.TIME_LIMIT_REACHED : RecordCursor.NoNextReason.RETURN_LIMIT_REACHED };
    final List<Integer> ints = IntStream.range(0, 10).boxed().collect(Collectors.toList());
    final FDBStoreTimer timer = new FDBStoreTimer();
    final BiFunction<Integer, byte[], RecordCursor<Pair<Integer, Integer>>> innerFunc = (x, continuation) -> {
        final RecordCursor<Integer> intCursor = RecordCursor.fromList(ints, continuation);
        final RecordCursor<Integer> limitedCursor;
        if (outOfBand) {
            limitedCursor = new FakeOutOfBandCursor<>(intCursor, 3);
        } else {
            limitedCursor = intCursor.limitRowsTo(3);
        }
        return limitedCursor.filterInstrumented(y -> y < x, timer, FDBStoreTimer.Counts.QUERY_FILTER_GIVEN, FDBStoreTimer.Events.QUERY_FILTER, FDBStoreTimer.Counts.QUERY_FILTER_PASSED, FDBStoreTimer.Counts.QUERY_DISCARDED).map(y -> Pair.of(x, y));
    };
    final Function<byte[], RecordCursor<Integer>> outerFunc = continuation -> RecordCursor.fromList(ints, continuation);
    int results = iterateGrid(continuation -> RecordCursor.flatMapPipelined(outerFunc, innerFunc, continuation, 5), possibleNoNextReasons);
    int expectedResults = ints.size() * (ints.size() - 1) / 2;
    assertEquals(expectedResults, results);
    assertEquals(ints.size() * ints.size(), timer.getCount(FDBStoreTimer.Counts.QUERY_FILTER_GIVEN));
    assertEquals(expectedResults, timer.getCount(FDBStoreTimer.Counts.QUERY_FILTER_PASSED));
    assertEquals(ints.size() * ints.size() - expectedResults, timer.getCount(FDBStoreTimer.Counts.QUERY_DISCARDED));
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) BeforeEach(org.junit.jupiter.api.BeforeEach) Arrays(java.util.Arrays) BiFunction(java.util.function.BiFunction) Timer(java.util.Timer) ByteBuffer(java.nio.ByteBuffer) Pair(org.apache.commons.lang3.tuple.Pair) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) FirableCursor(com.apple.foundationdb.record.cursors.FirableCursor) SkipCursor(com.apple.foundationdb.record.cursors.SkipCursor) TimerTask(java.util.TimerTask) FDBStoreTimer(com.apple.foundationdb.record.provider.foundationdb.FDBStoreTimer) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) Collectors(java.util.stream.Collectors) Test(org.junit.jupiter.api.Test) Matchers.instanceOf(org.hamcrest.Matchers.instanceOf) ByteOrder(java.nio.ByteOrder) List(java.util.List) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Optional(java.util.Optional) Matchers.greaterThan(org.hamcrest.Matchers.greaterThan) Matchers.is(org.hamcrest.Matchers.is) IntStream(java.util.stream.IntStream) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) Assertions.fail(org.junit.jupiter.api.Assertions.fail) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) MapCursor(com.apple.foundationdb.record.cursors.MapCursor) LazyCursor(com.apple.foundationdb.record.cursors.LazyCursor) RowLimitedCursor(com.apple.foundationdb.record.cursors.RowLimitedCursor) FilterCursor(com.apple.foundationdb.record.cursors.FilterCursor) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) CompletableFuture(java.util.concurrent.CompletableFuture) AsyncUtil(com.apple.foundationdb.async.AsyncUtil) AtomicReference(java.util.concurrent.atomic.AtomicReference) Function(java.util.function.Function) Iterators(com.google.common.collect.Iterators) ArrayList(java.util.ArrayList) Lists(com.google.common.collect.Lists) ImmutableList(com.google.common.collect.ImmutableList) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) BooleanSource(com.apple.test.BooleanSource) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Nonnull(javax.annotation.Nonnull) Nullable(javax.annotation.Nullable) MoreAsyncUtil(com.apple.foundationdb.async.MoreAsyncUtil) Matchers.oneOf(org.hamcrest.Matchers.oneOf) Matchers.greaterThanOrEqualTo(org.hamcrest.Matchers.greaterThanOrEqualTo) Iterator(java.util.Iterator) Executor(java.util.concurrent.Executor) Matchers(org.hamcrest.Matchers) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) ForkJoinPool(java.util.concurrent.ForkJoinPool) Collections(java.util.Collections) FDBStoreTimer(com.apple.foundationdb.record.provider.foundationdb.FDBStoreTimer) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) BooleanSource(com.apple.test.BooleanSource)

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