use of org.neo4j.internal.counts.CountsBuilder in project neo4j by neo4j.
the class BatchInsertTest method shouldBuildCorrectCountsStoreOnIncrementalImport.
@Test
void shouldBuildCorrectCountsStoreOnIncrementalImport() throws Exception {
// given
Label label = Label.label("Person");
int denseNodeThreshold = dense_node_threshold.defaultValue();
for (int r = 0; r < 3; r++) {
// when
BatchInserter inserter = newBatchInserter(denseNodeThreshold);
try {
for (int i = 0; i < 100; i++) {
inserter.createNode(null, label);
}
} finally {
inserter.shutdown();
}
// then
try (GBPTreeCountsStore countsStore = new GBPTreeCountsStore(pageCache, databaseLayout.countStore(), fs, RecoveryCleanupWorkCollector.immediate(), new CountsBuilder() {
@Override
public void initialize(CountsAccessor.Updater updater, CursorContext cursorContext, MemoryTracker memoryTracker) {
throw new UnsupportedOperationException("Should not be required");
}
@Override
public long lastCommittedTxId() {
return TransactionIdStore.BASE_TX_ID;
}
}, readOnly(), PageCacheTracer.NULL, GBPTreeCountsStore.NO_MONITOR, databaseLayout.getDatabaseName(), 1000)) {
countsStore.start(NULL, INSTANCE);
assertEquals((r + 1) * 100, countsStore.nodeCount(0, NULL));
}
}
}
use of org.neo4j.internal.counts.CountsBuilder in project neo4j by neo4j.
the class BatchingNeoStoresTest method shouldRebuildCountsStoreEvenIfExistsInEmptyDb.
@Test
void shouldRebuildCountsStoreEvenIfExistsInEmptyDb() throws IOException {
// given
try (GBPTreeCountsStore countsStore = new GBPTreeCountsStore(pageCache, databaseLayout.countStore(), fileSystem, RecoveryCleanupWorkCollector.immediate(), CountsBuilder.EMPTY, writable(), PageCacheTracer.NULL, GBPTreeCountsStore.NO_MONITOR, DEFAULT_DATABASE_NAME, 1_000)) {
countsStore.start(NULL, INSTANCE);
countsStore.checkpoint(NULL);
}
// when
try (BatchingNeoStores stores = BatchingNeoStores.batchingNeoStoresWithExternalPageCache(fileSystem, pageCache, PageCacheTracer.NULL, databaseLayout, LATEST_RECORD_FORMATS, Configuration.DEFAULT, NullLogService.getInstance(), EMPTY, Config.defaults(), INSTANCE)) {
stores.createNew();
stores.buildCountsStore(new CountsBuilder() {
@Override
public void initialize(CountsAccessor.Updater updater, CursorContext cursorContext, MemoryTracker memoryTracker) {
updater.incrementNodeCount(1, 10);
updater.incrementNodeCount(2, 20);
updater.incrementRelationshipCount(ANY_LABEL, 1, 2, 30);
updater.incrementRelationshipCount(1, 2, ANY_LABEL, 50);
}
@Override
public long lastCommittedTxId() {
return BASE_TX_ID + 1;
}
}, PageCacheTracer.NULL, NULL, INSTANCE);
}
// then
try (GBPTreeCountsStore countsStore = new GBPTreeCountsStore(pageCache, databaseLayout.countStore(), fileSystem, RecoveryCleanupWorkCollector.immediate(), CountsBuilder.EMPTY, writable(), PageCacheTracer.NULL, GBPTreeCountsStore.NO_MONITOR, DEFAULT_DATABASE_NAME, 1_000)) {
assertEquals(10, countsStore.nodeCount(1, NULL));
assertEquals(20, countsStore.nodeCount(2, NULL));
assertEquals(30, countsStore.relationshipCount(ANY_LABEL, 1, 2, NULL));
assertEquals(50, countsStore.relationshipCount(1, 2, ANY_LABEL, NULL));
}
}
Aggregations