use of org.neo4j.internal.id.indexed.IndexedIdGenerator in project neo4j by neo4j.
the class DefaultIdGeneratorFactory method create.
@Override
public IdGenerator create(PageCache pageCache, Path fileName, IdType idType, long highId, boolean throwIfFileExists, long maxId, DatabaseReadOnlyChecker readOnlyChecker, Config config, CursorContext cursorContext, ImmutableSet<OpenOption> openOptions) throws IOException {
// but there's a naked id generator, then delete the id generator so that it too starts from a clean state.
if (fs.fileExists(fileName)) {
fs.deleteFile(fileName);
}
IndexedIdGenerator generator = new IndexedIdGenerator(pageCache, fileName, recoveryCleanupWorkCollector, idType, allowLargeIdCaches, () -> highId, maxId, readOnlyChecker, config, cursorContext, defaultIdMonitor(fs, fileName, config), databaseName, openOptions);
generator.checkpoint(cursorContext);
generators.put(idType, generator);
return generator;
}
use of org.neo4j.internal.id.indexed.IndexedIdGenerator in project neo4j by neo4j.
the class DefaultIdGeneratorFactory method open.
@Override
public IdGenerator open(PageCache pageCache, Path filename, IdType idType, LongSupplier highIdScanner, long maxId, DatabaseReadOnlyChecker readOnlyChecker, Config config, CursorContext cursorContext, ImmutableSet<OpenOption> openOptions) throws IOException {
IndexedIdGenerator generator = instantiate(fs, pageCache, recoveryCleanupWorkCollector, filename, highIdScanner, maxId, idType, readOnlyChecker, config, cursorContext, databaseName, openOptions);
generators.put(idType, generator);
return generator;
}
use of org.neo4j.internal.id.indexed.IndexedIdGenerator in project neo4j by neo4j.
the class IdGeneratorMigratorTest method assertIdGeneratorContainsIds.
private void assertIdGeneratorContainsIds(Path idFilePath, IdType idType, int rounds, int numDeleted, int numCreated, long startingId) throws IOException {
try (IdGenerator idGenerator = new IndexedIdGenerator(pageCache, idFilePath, immediate(), idType, false, () -> -1, Long.MAX_VALUE, writable(), Config.defaults(), DEFAULT_DATABASE_NAME, CursorContext.NULL)) {
idGenerator.start(ignored -> {
throw new RuntimeException("Should not ask for free ids");
}, CursorContext.NULL);
long nextExpectedId = startingId;
for (int i = 0; i < rounds; i++) {
for (int d = 0; d < numDeleted; d++) {
assertEquals(nextExpectedId++, idGenerator.nextId(CursorContext.NULL));
}
nextExpectedId += numCreated;
}
}
}
use of org.neo4j.internal.id.indexed.IndexedIdGenerator in project neo4j by neo4j.
the class NodeStoreTest method newNodeStore.
private NodeStore newNodeStore(FileSystemAbstraction fs, PageCache pageCache) {
IdGeneratorFactory idGeneratorFactory = spy(new DefaultIdGeneratorFactory(fs, immediate(), databaseLayout.getDatabaseName()) {
@Override
protected IndexedIdGenerator instantiate(FileSystemAbstraction fs, PageCache pageCache, RecoveryCleanupWorkCollector recoveryCleanupWorkCollector, Path fileName, LongSupplier highIdSupplier, long maxValue, IdType idType, DatabaseReadOnlyChecker readOnlyChecker, Config config, CursorContext cursorContext, String databaseName, ImmutableSet<OpenOption> openOptions) {
return spy(super.instantiate(fs, pageCache, recoveryCleanupWorkCollector, fileName, highIdSupplier, maxValue, idType, readOnlyChecker, config, cursorContext, databaseName, openOptions));
}
});
StoreFactory factory = new StoreFactory(databaseLayout, Config.defaults(), idGeneratorFactory, pageCache, fs, NullLogProvider.getInstance(), PageCacheTracer.NULL, writable());
neoStores = factory.openAllNeoStores(true);
nodeStore = neoStores.getNodeStore();
return nodeStore;
}
Aggregations