use of org.neo4j.internal.id.BufferingIdGeneratorFactory in project neo4j by neo4j.
the class IdContextFactory method createBufferingIdContext.
private DatabaseIdContext createBufferingIdContext(Function<NamedDatabaseId, ? extends IdGeneratorFactory> idGeneratorFactoryProvider, JobScheduler jobScheduler, PageCacheTracer cacheTracer, NamedDatabaseId namedDatabaseId) {
IdGeneratorFactory idGeneratorFactory = idGeneratorFactoryProvider.apply(namedDatabaseId);
BufferingIdGeneratorFactory bufferingIdGeneratorFactory = new BufferingIdGeneratorFactory(idGeneratorFactory);
BufferedIdController bufferingController = createBufferedIdController(bufferingIdGeneratorFactory, jobScheduler, cacheTracer, namedDatabaseId.name());
return createIdContext(bufferingIdGeneratorFactory, bufferingController);
}
use of org.neo4j.internal.id.BufferingIdGeneratorFactory in project neo4j by neo4j.
the class IdContextFactoryBuilderTest method createContextWithCustomIdGeneratorFactoryWhenProvided.
@Test
void createContextWithCustomIdGeneratorFactoryWhenProvided() throws IOException {
IdGeneratorFactory idGeneratorFactory = mock(IdGeneratorFactory.class);
Config config = defaults();
IdContextFactory contextFactory = IdContextFactoryBuilder.of(fs, jobScheduler, config, PageCacheTracer.NULL).withIdGenerationFactoryProvider(any -> idGeneratorFactory).build();
DatabaseIdContext idContext = contextFactory.createIdContext(databaseIdRepository.getByName("database").get());
IdGeneratorFactory bufferedGeneratorFactory = idContext.getIdGeneratorFactory();
assertThat(idContext.getIdController()).isInstanceOf(BufferedIdController.class);
assertThat(bufferedGeneratorFactory).isInstanceOf(BufferingIdGeneratorFactory.class);
((BufferingIdGeneratorFactory) bufferedGeneratorFactory).initialize(() -> mock(KernelTransactionsSnapshot.class));
Path file = testDirectory.file("a");
IdType idType = IdType.NODE;
LongSupplier highIdSupplier = () -> 0;
int maxId = 100;
idGeneratorFactory.open(pageCache, file, idType, highIdSupplier, maxId, writable(), config, NULL, immutable.empty());
verify(idGeneratorFactory).open(pageCache, file, idType, highIdSupplier, maxId, writable(), config, NULL, immutable.empty());
}
Aggregations