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