/** * Open {@link NeoStores} for requested and store types. If requested store depend from non request store, * it will be automatically opened as well. * If some store does not exist it will <b>not</b> be created. * @param storeTypes - types of stores to be opened. * @return container with opened stores */ public NeoStores openNeoStores( StoreType... storeTypes ) { return openNeoStores( false, storeTypes ); }
/** * Open {@link NeoStores} with all possible stores with a possibility to create store if it not exist. * @param createStoreIfNotExists - should store be created if it's not exist * @return container with all opened stores */ public NeoStores openAllNeoStores( boolean createStoreIfNotExists ) { return openNeoStores( createStoreIfNotExists, StoreType.values() ); }
/** * Open {@link NeoStores} with all possible stores. If some store does not exist it will <b>not</b> be created. * @return container with all opened stores */ public NeoStores openAllNeoStores() { return openNeoStores( false, StoreType.values() ); }
private NeoStores instantiateTempStores() { return newStoreFactory( temporaryDatabaseLayout ).openNeoStores( true, TEMP_STORE_TYPES ); }
@Test public void notAllowCreateDynamicStoreWithNegativeBlockSize() { Config config = Config.defaults(); StoreFactory sf = getStoreFactory( config, databaseLayout, fs.get(), NullLogProvider.getInstance() ); exception.expect( IllegalArgumentException.class ); exception.expectMessage( "Block size of dynamic array store should be positive integer." ); try ( NeoStores neoStores = sf.openNeoStores( true ) ) { neoStores.createDynamicArrayStore( new File( "someStore" ), new File( "someIdFile" ), IdType.ARRAY_BLOCK, -2 ); } }
private boolean databaseExistsAndContainsData() { File metaDataFile = databaseLayout.metadataStore(); try ( PagedFile pagedFile = pageCache.map( metaDataFile, pageCache.pageSize(), StandardOpenOption.READ ) ) { // OK so the db probably exists } catch ( IOException e ) { // It's OK return false; } try ( NeoStores stores = newStoreFactory( databaseLayout ).openNeoStores( StoreType.NODE, StoreType.RELATIONSHIP ) ) { return stores.getNodeStore().getHighId() > 0 || stores.getRelationshipStore().getHighId() > 0; } }
public void migrate( DatabaseLayout fromDirectoryStructure, RecordFormats fromFormat, DatabaseLayout toDirectoryStructure, RecordFormats toFormat, ProgressReporter progressReporter, StoreType[] types, StoreType... additionalTypesToOpen ) { StoreType[] storesToOpen = ArrayUtil.concat( types, additionalTypesToOpen ); progressReporter.start( storesToOpen.length ); try ( NeoStores fromStores = new StoreFactory( fromDirectoryStructure, config, new DefaultIdGeneratorFactory( fs ), pageCache, fs, fromFormat, NullLogProvider.getInstance(), EmptyVersionContextSupplier.EMPTY ) .openNeoStores( true, storesToOpen ); NeoStores toStores = new StoreFactory( toDirectoryStructure, withPersistedStoreHeadersAsConfigFrom( fromStores, storesToOpen ), new DefaultIdGeneratorFactory( fs ), pageCache, fs, toFormat, NullLogProvider.getInstance(), EmptyVersionContextSupplier.EMPTY ) .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 ) ); progressReporter.progress( 1 ); } } } }
private NeoStores open( FileSystemAbstraction fs, PageCache pageCache, RecordFormats format, Function<FileSystemAbstraction,IdGeneratorFactory> idGeneratorFactory, String... config ) throws IOException { assert neoStores == null : "Already opened"; TestDirectory testDirectory = TestDirectory.testDirectory( fs ); testDirectory.prepareDirectory( testClass, null ); Config configuration = configOf( config ); StoreFactory storeFactory = new StoreFactory( testDirectory.databaseLayout(), configuration, idGeneratorFactory.apply( fs ), pageCache, fs, format, NullLogProvider.getInstance(), EmptyVersionContextSupplier.EMPTY ); return neoStores = stores.length == 0 ? storeFactory.openAllNeoStores( true ) : storeFactory.openNeoStores( true, stores ); }
private MetaDataStore newMetaDataStore() { LogProvider logProvider = NullLogProvider.getInstance(); StoreFactory storeFactory = new StoreFactory( testDirectory.databaseLayout(), Config.defaults(), new DefaultIdGeneratorFactory( fs ), pageCacheWithFakeOverflow, fs, logProvider, EmptyVersionContextSupplier.EMPTY ); return storeFactory.openNeoStores( true, StoreType.META_DATA ).getMetaDataStore(); }
pageCache.getPageCache( fs.get() ), fs.get(), logProvider, EmptyVersionContextSupplier.EMPTY ); try ( NeoStores stores = storeFactory.openNeoStores( true, StoreType.RELATIONSHIP_GROUP ) )
@Test public void isPresentFalseAfterCreatingAllButLastStoreType() throws Exception { // given FileSystemAbstraction fileSystem = fs.get(); fileSystem.deleteRecursively( databaseLayout.databaseDirectory() ); DefaultIdGeneratorFactory idFactory = new DefaultIdGeneratorFactory( fileSystem ); StoreFactory factory = new StoreFactory( databaseLayout, Config.defaults(), idFactory, pageCache, fileSystem, LOG_PROVIDER, EmptyVersionContextSupplier.EMPTY ); StoreType[] allStoreTypes = StoreType.values(); StoreType[] allButLastStoreTypes = Arrays.copyOf( allStoreTypes, allStoreTypes.length - 1 ); // when try ( NeoStores ignore = factory.openNeoStores( true, allButLastStoreTypes ) ) { // then assertFalse( NeoStores.isStorePresent( pageCache, databaseLayout ) ); } }
@Test public void impossibleToGetNotRequestedStore() { Config config = Config.defaults(); StoreFactory sf = getStoreFactory( config, databaseLayout, fs.get(), NullLogProvider.getInstance() ); exception.expect( IllegalStateException.class ); exception.expectMessage( "Specified store was not initialized. Please specify " + StoreType.META_DATA.name() + " as one of the stores types that should be open to be able to use it." ); try ( NeoStores neoStores = sf.openNeoStores( true, StoreType.NODE_LABEL ) ) { neoStores.getMetaDataStore(); } }
private void rebuildCountsFromScratch( DatabaseLayout sourceStructure, DatabaseLayout migrationStructure, long lastTxId, ProgressReporter progressMonitor, String expectedStoreVersion, PageCache pageCache, LogProvider logProvider ) { RecordFormats recordFormats = selectForVersion( expectedStoreVersion ); IdGeneratorFactory idGeneratorFactory = new ReadOnlyIdGeneratorFactory( fileSystem ); StoreFactory storeFactory = new StoreFactory( sourceStructure, config, idGeneratorFactory, pageCache, fileSystem, recordFormats, logProvider, EmptyVersionContextSupplier.EMPTY ); try ( NeoStores neoStores = storeFactory .openNeoStores( StoreType.NODE, StoreType.RELATIONSHIP, StoreType.LABEL_TOKEN, StoreType.RELATIONSHIP_TYPE_TOKEN ) ) { neoStores.verifyStoreOk(); NodeStore nodeStore = neoStores.getNodeStore(); RelationshipStore relationshipStore = neoStores.getRelationshipStore(); try ( Lifespan life = new Lifespan() ) { int highLabelId = (int) neoStores.getLabelTokenStore().getHighId(); int highRelationshipTypeId = (int) neoStores.getRelationshipTypeTokenStore().getHighId(); CountsComputer initializer = new CountsComputer( lastTxId, nodeStore, relationshipStore, highLabelId, highRelationshipTypeId, NumberArrayFactory.auto( pageCache, migrationStructure.databaseDirectory(), true, NumberArrayFactory.NO_MONITOR ), progressMonitor ); life.add( new CountsTracker( logProvider, fileSystem, pageCache, config, migrationStructure, EmptyVersionContextSupplier.EMPTY ).setInitializer( initializer ) ); } } } }
@Before public void setupStore() { neoStores = new StoreFactory( storage.directory().databaseLayout(), Config.defaults(), new DefaultIdGeneratorFactory( storage.fileSystem() ), storage.pageCache(), storage.fileSystem(), NullLogProvider.getInstance(), EmptyVersionContextSupplier.EMPTY ).openNeoStores( true, StoreType.PROPERTY, StoreType.PROPERTY_ARRAY, StoreType.PROPERTY_STRING ); propertyStore = neoStores.getPropertyStore(); }
@Before public void startStore() { neoStores = new StoreFactory( storage.directory().databaseLayout(), Config.defaults(), new DefaultIdGeneratorFactory( storage.fileSystem() ), storage.pageCache(), storage.fileSystem(), NullLogProvider.getInstance(), EmptyVersionContextSupplier.EMPTY ).openNeoStores( true, StoreType.PROPERTY, StoreType.PROPERTY_STRING, StoreType.PROPERTY_ARRAY ); propertyStore = neoStores.getPropertyStore(); records = new DirectRecordAccess<>( propertyStore, Loaders.propertyLoader( propertyStore ) ); creator = new PropertyCreator( propertyStore, new PropertyTraverser() ); }
new DefaultIdGeneratorFactory( storage.fileSystem() ), pageCache, storage.fileSystem(), NullLogProvider.getInstance(), EmptyVersionContextSupplier.EMPTY ) .openNeoStores( true, StoreType.PROPERTY_KEY_TOKEN, StoreType.PROPERTY_KEY_TOKEN_NAME ) )
/** * Open {@link NeoStores} for requested and store types. If requested store depend from non request store, * it will be automatically opened as well. * If some store does not exist it will <b>not</b> be created. * @param storeTypes - types of stores to be opened. * @return container with opened stores */ public NeoStores openNeoStores( StoreType... storeTypes ) { return openNeoStores( false, storeTypes ); }
/** * Open {@link NeoStores} with all possible stores. If some store does not exist it will <b>not</b> be created. * @return container with all opened stores */ public NeoStores openAllNeoStores() { return openNeoStores( false, StoreType.values() ); }
/** * Open {@link NeoStores} with all possible stores with a possibility to create store if it not exist. * @param createStoreIfNotExists - should store be created if it's not exist * @return container with all opened stores */ public NeoStores openAllNeoStores( boolean createStoreIfNotExists ) { return openNeoStores( createStoreIfNotExists, StoreType.values() ); }
private NeoStores instantiateTempStores() { return newStoreFactory( temporaryDatabaseLayout ).openNeoStores( true, TEMP_STORE_TYPES ); }