use of org.neo4j.kernel.api.index.IndexSample in project neo4j by neo4j.
the class FusionIndexIT method verifyContent.
private void verifyContent() {
try (Transaction tx = db.beginTx()) {
tx.schema().awaitIndexesOnline(30, TimeUnit.SECONDS);
assertEquals(1L, Iterators.stream(tx.schema().getIndexes(label).iterator()).count());
assertNotNull(tx.findNode(label, propKey, numberValue));
assertNotNull(tx.findNode(label, propKey, stringValue));
assertNotNull(tx.findNode(label, propKey, spatialValue));
assertNotNull(tx.findNode(label, propKey, temporalValue));
assertThat(indexSample()).isEqualTo(new IndexSample(4, 4, 4, 0));
tx.commit();
}
}
use of org.neo4j.kernel.api.index.IndexSample in project neo4j by neo4j.
the class IndexStatisticsStoreTest method tracePageCacheAccessOnCheckpoint.
@Test
void tracePageCacheAccessOnCheckpoint() throws IOException {
var cacheTracer = new DefaultPageCacheTracer();
var store = openStore(cacheTracer, "checkpoint");
try (var cursorContext = new CursorContext(cacheTracer.createPageCursorTracer("tracePageCacheAccessOnCheckpoint"))) {
for (int i = 0; i < 100; i++) {
store.replaceStats(i, new IndexSample());
}
store.checkpoint(cursorContext);
PageCursorTracer cursorTracer = cursorContext.getCursorTracer();
assertThat(cursorTracer.pins()).isEqualTo(43);
assertThat(cursorTracer.unpins()).isEqualTo(43);
assertThat(cursorTracer.hits()).isEqualTo(35);
assertThat(cursorTracer.faults()).isEqualTo(8);
}
}
use of org.neo4j.kernel.api.index.IndexSample in project neo4j by neo4j.
the class IndexStatisticsStoreTest method shouldHandleConcurrentUpdatesWithCheckpointing.
@Test
void shouldHandleConcurrentUpdatesWithCheckpointing() throws Throwable {
// given
Race race = new Race();
AtomicBoolean checkpointDone = new AtomicBoolean();
int contestantsPerIndex = 5;
int indexes = 3;
int delta = 5;
AtomicIntegerArray expected = new AtomicIntegerArray(indexes);
race.addContestant(throwing(() -> {
for (int i = 0; i < 20; i++) {
Thread.sleep(5);
store.checkpoint(CursorContext.NULL);
}
checkpointDone.set(true);
}));
for (int i = 0; i < indexes; i++) {
int indexId = i;
store.replaceStats(indexId, new IndexSample(0, 0, 0));
race.addContestants(contestantsPerIndex, () -> {
while (!checkpointDone.get()) {
store.incrementIndexUpdates(indexId, delta);
expected.addAndGet(indexId, delta);
}
});
}
// when
race.go();
// then
for (int i = 0; i < indexes; i++) {
assertEquals(new IndexSample(0, 0, 0, expected.get(i)), store.indexSample(i));
}
restartStore();
for (int i = 0; i < indexes; i++) {
assertEquals(new IndexSample(0, 0, 0, expected.get(i)), store.indexSample(i));
}
}
use of org.neo4j.kernel.api.index.IndexSample in project neo4j by neo4j.
the class IndexStatisticsStoreTest method tracePageCacheAccessOnConsistencyCheck.
@Test
void tracePageCacheAccessOnConsistencyCheck() throws IOException {
var cacheTracer = new DefaultPageCacheTracer();
var store = openStore(cacheTracer, "consistencyCheck");
try (var cursorContext = new CursorContext(cacheTracer.createPageCursorTracer("tracePageCacheAccessOnConsistencyCheck"))) {
for (int i = 0; i < 100; i++) {
store.replaceStats(i, new IndexSample());
}
store.checkpoint(CursorContext.NULL);
store.consistencyCheck(noopReporterFactory(), cursorContext);
PageCursorTracer cursorTracer = cursorContext.getCursorTracer();
assertThat(cursorTracer.pins()).isEqualTo(16);
assertThat(cursorTracer.unpins()).isEqualTo(16);
assertThat(cursorTracer.hits()).isEqualTo(16);
}
}
use of org.neo4j.kernel.api.index.IndexSample in project neo4j by neo4j.
the class BlockEntryStreamMergerTest method shouldMergePartsIntoOneWithSampling.
@Test
void shouldMergePartsIntoOneWithSampling() throws Exception {
// given
List<BlockEntryCursor<RawBytes, RawBytes>> parts = buildParts(random, layout, allData);
// when
try (BlockEntryStreamMerger<RawBytes, RawBytes> merger = new BlockEntryStreamMerger<>(parts, layout, layout, NOT_CANCELLABLE, BATCH_SIZE, QUEUE_SIZE)) {
Future<Void> t2Future = t2.execute(merger);
// then
assertMergedPartStream(allData, merger);
t2Future.get();
IndexSample sample = merger.buildIndexSample();
assertThat(sample.sampleSize()).isEqualTo(allData.size());
assertThat(sample.indexSize()).isEqualTo(allData.size());
assertThat(sample.uniqueValues()).isEqualTo(countUniqueKeys(allData));
}
}
Aggregations