use of org.neo4j.kernel.impl.store.StoreFactory in project neo4j by neo4j.
the class DirectRecordStoreMigrator method migrate.
public void migrate(DatabaseLayout fromDirectoryStructure, RecordFormats fromFormat, DatabaseLayout toDirectoryStructure, RecordFormats toFormat, ProgressReporter progressReporter, StoreType[] types, StoreType... additionalTypesToOpen) throws IOException {
StoreType[] storesToOpen = ArrayUtil.concat(types, additionalTypesToOpen);
progressReporter.start(storesToOpen.length);
try (NeoStores fromStores = new StoreFactory(fromDirectoryStructure, config, new ScanOnOpenReadOnlyIdGeneratorFactory(), pageCache, fs, fromFormat, NullLogProvider.getInstance(), cacheTracer, readOnly(), immutable.empty()).openNeoStores(true, storesToOpen);
NeoStores toStores = new StoreFactory(toDirectoryStructure, withPersistedStoreHeadersAsConfigFrom(fromStores, storesToOpen), new DefaultIdGeneratorFactory(fs, immediate(), toDirectoryStructure.getDatabaseName()), pageCache, fs, toFormat, NullLogProvider.getInstance(), cacheTracer, writable(), immutable.empty()).openNeoStores(true, storesToOpen);
var cursorContext = new CursorContext(cacheTracer.createPageCursorTracer(DIRECT_STORE_MIGRATOR_TAG))) {
toStores.start(cursorContext);
for (StoreType type : types) {
// This condition will exclude counts store first and foremost.
migrate(fromStores.getRecordStore(type), toStores.getRecordStore(type), cursorContext);
progressReporter.progress(1);
}
}
}
use of org.neo4j.kernel.impl.store.StoreFactory in project neo4j by neo4j.
the class DeleteDuplicateNodesStepTest method before.
@BeforeEach
void before() {
var storeFactory = new StoreFactory(databaseLayout, Config.defaults(), new DefaultIdGeneratorFactory(fs, immediate(), databaseLayout.getDatabaseName()), pageCache, fs, NullLogProvider.getInstance(), PageCacheTracer.NULL, writable());
neoStores = storeFactory.openAllNeoStores(true);
}
use of org.neo4j.kernel.impl.store.StoreFactory in project neo4j by neo4j.
the class NodeCommandTest method before.
@BeforeEach
void before() {
StoreFactory storeFactory = new StoreFactory(databaseLayout, Config.defaults(), new DefaultIdGeneratorFactory(fs, immediate(), databaseLayout.getDatabaseName()), pageCache, fs, NullLogProvider.getInstance(), PageCacheTracer.NULL, writable());
neoStores = storeFactory.openAllNeoStores(true);
nodeStore = neoStores.getNodeStore();
}
use of org.neo4j.kernel.impl.store.StoreFactory in project neo4j by neo4j.
the class HighIdTransactionApplierTest method before.
@BeforeEach
void before() {
var storeFactory = new StoreFactory(databaseLayout, Config.defaults(), new DefaultIdGeneratorFactory(fs, immediate(), databaseLayout.getDatabaseName()), pageCache, fs, NullLogProvider.getInstance(), PageCacheTracer.NULL, writable());
neoStores = storeFactory.openAllNeoStores(true);
}
use of org.neo4j.kernel.impl.store.StoreFactory in project neo4j by neo4j.
the class IdGeneratorMigratorTest method shouldFindAndStoreDeletedIds.
@Test
void shouldFindAndStoreDeletedIds() throws IOException {
// given
DatabaseLayout db = DatabaseLayout.ofFlat(directory.directory("from"));
DatabaseLayout upgrade = DatabaseLayout.ofFlat(directory.directory("to"));
long nodeStoreStartId;
long stringStoreStartId;
long relationshipStoreStartId;
try (NeoStores neoStores = new StoreFactory(db, defaults(), new DefaultIdGeneratorFactory(fs, immediate(), DEFAULT_DATABASE_NAME), pageCache, fs, StandardV3_4.RECORD_FORMATS, nullLogProvider(), PageCacheTracer.NULL, writable(), immutable.empty()).openAllNeoStores(true)) {
// Let nodes have every fourth a deleted record
createSomeRecordsAndSomeHoles(neoStores.getNodeStore(), 500, 1, 3);
createSomeRecordsAndSomeHoles(neoStores.getPropertyStore().getStringStore(), 100, 1, 2);
nodeStoreStartId = neoStores.getNodeStore().getNumberOfReservedLowIds();
stringStoreStartId = neoStores.getPropertyStore().getStringStore().getNumberOfReservedLowIds();
}
// Pretend that the relationship store was copied so that relationship id file should be migrated from there
try (NeoStores neoStores = new StoreFactory(upgrade, defaults(), new DefaultIdGeneratorFactory(fs, immediate(), DEFAULT_DATABASE_NAME), pageCache, fs, Standard.LATEST_RECORD_FORMATS, nullLogProvider(), PageCacheTracer.NULL, writable(), immutable.empty()).openAllNeoStores(true)) {
// Let relationships have every fourth a created record
createSomeRecordsAndSomeHoles(neoStores.getRelationshipStore(), 600, 3, 1);
relationshipStoreStartId = neoStores.getRelationshipStore().getNumberOfReservedLowIds();
}
fs.deleteFile(upgrade.nodeStore());
fs.deleteFile(upgrade.idNodeStore());
fs.deleteFile(upgrade.propertyStringStore());
fs.deleteFile(upgrade.idPropertyStringStore());
fs.deleteFile(db.relationshipStore());
fs.deleteFile(upgrade.idRelationshipStore());
// when
IdGeneratorMigrator migrator = new IdGeneratorMigrator(fs, pageCache, defaults(), PageCacheTracer.NULL);
migrator.migrate(db, upgrade, ProgressReporter.SILENT, StandardV3_4.STORE_VERSION, Standard.LATEST_STORE_VERSION, IndexImporterFactory.EMPTY);
migrator.moveMigratedFiles(upgrade, db, StandardV3_4.STORE_VERSION, Standard.LATEST_STORE_VERSION);
// then
assertIdGeneratorContainsIds(db.idNodeStore(), IdType.NODE, 500, 1, 3, nodeStoreStartId);
assertIdGeneratorContainsIds(db.idPropertyStringStore(), IdType.STRING_BLOCK, 100, 1, 2, stringStoreStartId);
assertIdGeneratorContainsIds(db.idRelationshipStore(), IdType.RELATIONSHIP, 600, 3, 1, relationshipStoreStartId);
}
Aggregations