use of org.neo4j.internal.batchimport.store.BatchingTokenRepository.BatchingRelationshipTypeTokenRepository in project neo4j by neo4j.
the class BatchingTokenRepositoryTest method shouldRespectExistingTokens.
@Test
void shouldRespectExistingTokens() {
// given
TokenStore<RelationshipTypeTokenRecord> tokenStore = mock(TokenStore.class);
int previousHighId = 5;
when(tokenStore.getHighId()).thenReturn((long) previousHighId);
BatchingRelationshipTypeTokenRepository repo = new BatchingRelationshipTypeTokenRepository(tokenStore);
verify(tokenStore).getHighId();
// when
int tokenId = repo.getOrCreateId("NEW_ONE");
// then
assertEquals(previousHighId, tokenId);
}
use of org.neo4j.internal.batchimport.store.BatchingTokenRepository.BatchingRelationshipTypeTokenRepository 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);
}
}
Aggregations