use of org.neo4j.internal.counts.GBPTreeCountsStore 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));
}
}
use of org.neo4j.internal.counts.GBPTreeCountsStore in project neo4j by neo4j.
the class OnlineIndexUpdatesTest method setUp.
@BeforeEach
void setUp() throws IOException {
life = new LifeSupport();
Config config = Config.defaults();
NullLogProvider nullLogProvider = NullLogProvider.getInstance();
StoreFactory storeFactory = new StoreFactory(databaseLayout, config, new DefaultIdGeneratorFactory(fileSystem, immediate(), databaseLayout.getDatabaseName()), pageCache, fileSystem, nullLogProvider, NULL, writable());
neoStores = storeFactory.openAllNeoStores(true);
GBPTreeCountsStore counts = new GBPTreeCountsStore(pageCache, databaseLayout.countStore(), fileSystem, immediate(), new CountsComputer(neoStores, pageCache, NULL, databaseLayout, INSTANCE, NullLog.getInstance()), writable(), NULL, GBPTreeCountsStore.NO_MONITOR, databaseLayout.getDatabaseName(), 1_000);
life.add(wrapInLifecycle(counts));
nodeStore = neoStores.getNodeStore();
relationshipStore = neoStores.getRelationshipStore();
PropertyStore propertyStore = neoStores.getPropertyStore();
schemaCache = new SchemaCache(new StandardConstraintRuleAccessor(), index -> index);
propertyPhysicalToLogicalConverter = new PropertyPhysicalToLogicalConverter(neoStores.getPropertyStore(), CursorContext.NULL);
life.start();
propertyCreator = new PropertyCreator(neoStores.getPropertyStore(), new PropertyTraverser(CursorContext.NULL), CursorContext.NULL, INSTANCE);
recordAccess = new DirectRecordAccess<>(neoStores.getPropertyStore(), Loaders.propertyLoader(propertyStore, CursorContext.NULL));
}
Aggregations