use of org.neo4j.token.TokenHolders in project neo4j by neo4j.
the class BatchingNeoStores method instantiateStores.
private void instantiateStores() throws IOException {
neoStores = newStoreFactory(databaseLayout, idGeneratorFactory, pageCacheTracer, immutable.empty()).openAllNeoStores(true);
propertyKeyRepository = new BatchingPropertyKeyTokenRepository(neoStores.getPropertyKeyTokenStore());
labelRepository = new BatchingLabelTokenRepository(neoStores.getLabelTokenStore());
relationshipTypeRepository = new BatchingRelationshipTypeTokenRepository(neoStores.getRelationshipTypeTokenStore());
tokenHolders = new TokenHolders(new DelegatingTokenHolder((key, internal) -> propertyKeyRepository.getOrCreateId(key, internal), TYPE_PROPERTY_KEY), new DelegatingTokenHolder((key, internal) -> labelRepository.getOrCreateId(key, internal), TYPE_LABEL), new DelegatingTokenHolder((key, internal) -> relationshipTypeRepository.getOrCreateId(key, internal), TYPE_RELATIONSHIP_TYPE));
tokenHolders.propertyKeyTokens().setInitialTokens(neoStores.getPropertyKeyTokenStore().getTokens(CursorContext.NULL));
temporaryNeoStores = instantiateTempStores();
try (var cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer(BATCHING_STORE_CREATION_TAG))) {
neoStores.start(cursorContext);
temporaryNeoStores.start(cursorContext);
MetaDataStore metaDataStore = neoStores.getMetaDataStore();
metaDataStore.setLastCommittedAndClosedTransactionId(initialIds.lastCommittedTransactionId(), initialIds.lastCommittedTransactionChecksum(), BASE_TX_COMMIT_TIMESTAMP, initialIds.lastCommittedTransactionLogByteOffset(), initialIds.lastCommittedTransactionLogVersion(), cursorContext);
metaDataStore.setCheckpointLogVersion(initialIds.checkpointLogVersion(), cursorContext);
}
}
use of org.neo4j.token.TokenHolders in project neo4j by neo4j.
the class SchemaStorageReadAndWriteTest method before.
@BeforeAll
void before() throws Exception {
testDirectory.prepareDirectory(getClass(), "test");
var storeFactory = new StoreFactory(databaseLayout, Config.defaults(), new DefaultIdGeneratorFactory(fs, immediate(), databaseLayout.getDatabaseName()), pageCache, fs, NullLogProvider.getInstance(), PageCacheTracer.NULL, writable());
neoStores = storeFactory.openNeoStores(true, StoreType.SCHEMA, StoreType.PROPERTY_KEY_TOKEN, StoreType.LABEL_TOKEN, StoreType.RELATIONSHIP_TYPE_TOKEN);
AtomicInteger tokenIdCounter = new AtomicInteger();
TokenCreator tokenCreator = (name, internal) -> tokenIdCounter.incrementAndGet();
TokenHolders tokens = new TokenHolders(new DelegatingTokenHolder(tokenCreator, TokenHolder.TYPE_PROPERTY_KEY), new DelegatingTokenHolder(tokenCreator, TokenHolder.TYPE_LABEL), new DelegatingTokenHolder(tokenCreator, TokenHolder.TYPE_RELATIONSHIP_TYPE));
tokens.setInitialTokens(StoreTokens.allTokens(neoStores), NULL);
tokenIdCounter.set(Math.max(tokenIdCounter.get(), tokens.propertyKeyTokens().size()));
tokenIdCounter.set(Math.max(tokenIdCounter.get(), tokens.labelTokens().size()));
tokenIdCounter.set(Math.max(tokenIdCounter.get(), tokens.relationshipTypeTokens().size()));
storage = new SchemaStorage(neoStores.getSchemaStore(), tokens, () -> KernelVersion.LATEST);
}
Aggregations