use of org.neo4j.kernel.impl.store.id.DefaultIdGeneratorFactory in project neo4j by neo4j.
the class AbstractDynamicStoreTest method newTestableDynamicStore.
private AbstractDynamicStore newTestableDynamicStore() {
DefaultIdGeneratorFactory idGeneratorFactory = new DefaultIdGeneratorFactory(fs);
AbstractDynamicStore store = new AbstractDynamicStore(fileName, Config.empty(), IdType.ARRAY_BLOCK, idGeneratorFactory, pageCache, NullLogProvider.getInstance(), "test", BLOCK_SIZE, formats.dynamic(), formats.storeVersion()) {
@Override
public void accept(Processor processor, DynamicRecord record) {
// Ignore
}
@Override
public String getTypeDescriptor() {
return "TestDynamicStore";
}
};
store.initialise(true);
return store;
}
use of org.neo4j.kernel.impl.store.id.DefaultIdGeneratorFactory in project neo4j by neo4j.
the class NeoStoreDataSourceRule method getDataSource.
public NeoStoreDataSource getDataSource(File storeDir, FileSystemAbstraction fs, PageCache pageCache, Map<String, String> additionalConfig, DatabaseHealth databaseHealth) {
CommunityIdTypeConfigurationProvider idTypeConfigurationProvider = new CommunityIdTypeConfigurationProvider();
DefaultIdGeneratorFactory idGeneratorFactory = new DefaultIdGeneratorFactory(fs);
NullLogService logService = NullLogService.getInstance();
return getDataSource(storeDir, fs, idGeneratorFactory, idTypeConfigurationProvider, pageCache, additionalConfig, databaseHealth, logService);
}
use of org.neo4j.kernel.impl.store.id.DefaultIdGeneratorFactory in project neo4j by neo4j.
the class NeoStoresRule method open.
public NeoStores open(FileSystemAbstraction fs, PageCache pageCache, RecordFormats format, String... config) throws IOException {
assert neoStores == null : "Already opened";
TestDirectory testDirectory = TestDirectory.testDirectory(testClass, fs);
File storeDir = testDirectory.makeGraphDbDir();
Config configuration = Config.embeddedDefaults(stringMap(config));
StoreFactory storeFactory = new StoreFactory(storeDir, configuration, new DefaultIdGeneratorFactory(fs), pageCache, fs, format, NullLogProvider.getInstance());
return neoStores = stores.length == 0 ? storeFactory.openAllNeoStores(true) : storeFactory.openNeoStores(true, stores);
}
use of org.neo4j.kernel.impl.store.id.DefaultIdGeneratorFactory in project neo4j by neo4j.
the class DirectRecordStoreMigrator method migrate.
public void migrate(File fromStoreDir, RecordFormats fromFormat, File toStoreDir, RecordFormats toFormat, MigrationProgressMonitor.Section progressMonitor, StoreType[] types, StoreType... additionalTypesToOpen) {
StoreType[] storesToOpen = ArrayUtil.concat(types, additionalTypesToOpen);
progressMonitor.start(storesToOpen.length);
try (NeoStores fromStores = new StoreFactory(fromStoreDir, config, new DefaultIdGeneratorFactory(fs), pageCache, fs, fromFormat, NullLogProvider.getInstance()).openNeoStores(true, storesToOpen);
NeoStores toStores = new StoreFactory(toStoreDir, withPersistedStoreHeadersAsConfigFrom(fromStores, storesToOpen), new DefaultIdGeneratorFactory(fs), pageCache, fs, toFormat, NullLogProvider.getInstance()).openNeoStores(true, storesToOpen)) {
for (StoreType type : types) {
// This condition will exclude counts store first and foremost.
if (type.isRecordStore()) {
migrate(fromStores.getRecordStore(type), toStores.getRecordStore(type));
progressMonitor.progress(1);
}
}
}
}
use of org.neo4j.kernel.impl.store.id.DefaultIdGeneratorFactory in project neo4j by neo4j.
the class TestGrowingFileMemoryMapping method shouldGrowAFileWhileContinuingToMemoryMapNewRegions.
@Test
public void shouldGrowAFileWhileContinuingToMemoryMapNewRegions() throws Exception {
// don't run on windows because memory mapping doesn't work properly there
assumeTrue(!SystemUtils.IS_OS_WINDOWS);
// given
int NUMBER_OF_RECORDS = 1000000;
File storeDir = testDirectory.graphDbDir();
Config config = Config.embeddedDefaults(stringMap(pagecache_memory.name(), mmapSize(NUMBER_OF_RECORDS, NodeRecordFormat.RECORD_SIZE)));
FileSystemAbstraction fileSystemAbstraction = fileSystemRule.get();
DefaultIdGeneratorFactory idGeneratorFactory = new DefaultIdGeneratorFactory(fileSystemAbstraction);
PageCache pageCache = pageCacheRule.getPageCache(fileSystemAbstraction, config);
StoreFactory storeFactory = new StoreFactory(storeDir, config, idGeneratorFactory, pageCache, fileSystemAbstraction, NullLogProvider.getInstance());
NeoStores neoStores = storeFactory.openAllNeoStores(true);
NodeStore nodeStore = neoStores.getNodeStore();
// when
int iterations = 2 * NUMBER_OF_RECORDS;
long startingId = nodeStore.nextId();
long nodeId = startingId;
for (int i = 0; i < iterations; i++) {
NodeRecord record = new NodeRecord(nodeId, false, i, 0);
record.setInUse(true);
nodeStore.updateRecord(record);
nodeId = nodeStore.nextId();
}
// then
NodeRecord record = new NodeRecord(0, false, 0, 0);
for (int i = 0; i < iterations; i++) {
record.setId(startingId + i);
nodeStore.getRecord(i, record, NORMAL);
assertTrue("record[" + i + "] should be in use", record.inUse());
assertThat("record[" + i + "] should have nextRelId of " + i, record.getNextRel(), is((long) i));
}
neoStores.close();
}
Aggregations