public static GenericNativeIndexProvider create( PageCache pageCache, File storeDir, FileSystemAbstraction fs, IndexProvider.Monitor monitor, Config config, OperationalMode mode, RecoveryCleanupWorkCollector recoveryCleanupWorkCollector ) { IndexDirectoryStructure.Factory directoryStructure = directoriesByProvider( storeDir ); boolean readOnly = config.get( GraphDatabaseSettings.read_only ) && (OperationalMode.single == mode); return new GenericNativeIndexProvider( directoryStructure, pageCache, fs, monitor, recoveryCleanupWorkCollector, readOnly, config ); }
@Override public File rootDirectory() { return parentStructure.rootDirectory(); }
SpatialIndexFiles( IndexDirectoryStructure directoryStructure, long indexId, FileSystemAbstraction fs, ConfiguredSpaceFillingCurveSettingsCache settingsCache ) { this.fs = fs; this.configuredSettings = settingsCache; indexDirectory = directoryStructure.directoryForIndex( indexId ); }
private static IndexDirectoryStructure.Factory subProviderDirectoryStructure( File storeDir ) { IndexDirectoryStructure parentDirectoryStructure = directoriesByProvider( storeDir ).forProvider( DESCRIPTOR ); return directoriesBySubProvider( parentDirectoryStructure ); }
/** * @param databaseStoreDir store directory of database, i.e. {@code db} in the example above. * @return {@link Factory} for creating {@link IndexDirectoryStructure} returning directories looking something like: * * <pre> * <db>/schema/index/<providerKey>-<providerVersion>/<indexId>/ * </pre> */ public static Factory directoriesByProvider( File databaseStoreDir ) { return descriptor -> new SubDirectoryByIndexId( path( baseSchemaIndexFolder( databaseStoreDir ), fileNameFriendly( descriptor ) ) ); }
private void assertCorrectDirectories( IndexDirectoryStructure directoryStructure, File expectedRootDirectory, File expectedIndexDirectory ) { // when File rootDirectory = directoryStructure.rootDirectory(); File indexDirectory = directoryStructure.directoryForIndex( indexId ); // then assertEquals( expectedRootDirectory, rootDirectory ); assertEquals( expectedIndexDirectory, indexDirectory ); } }
@Before public void setup() throws IOException { valueCreatorUtil = createValueCreatorUtil(); indexDescriptor = valueCreatorUtil.indexDescriptor(); layout = createLayout(); indexDirectoryStructure = directoriesByProvider( directory.directory( "root" ) ).forProvider( indexDescriptor.providerDescriptor() ); indexFile = indexDirectoryStructure.directoryForIndex( indexDescriptor.getId() ); fs.mkdirs( indexFile.getParentFile() ); pageCache = pageCacheRule.getPageCache( fs ); }
public static FusionIndexProvider newInstance( PageCache pageCache, File databaseDirectory, FileSystemAbstraction fs, IndexProvider.Monitor monitor, Config config, OperationalMode operationalMode, RecoveryCleanupWorkCollector recoveryCleanupWorkCollector ) { boolean readOnly = IndexProviderFactoryUtil.isReadOnly( config, operationalMode ); boolean archiveFailedIndex = config.get( GraphDatabaseSettings.archive_failed_index ); IndexDirectoryStructure.Factory luceneDirStructure = directoriesByProviderKey( databaseDirectory ); IndexDirectoryStructure.Factory childDirectoryStructure = subProviderDirectoryStructure( databaseDirectory ); LuceneIndexProvider lucene = IndexProviderFactoryUtil.luceneProvider( fs, luceneDirStructure, monitor, config, operationalMode ); TemporalIndexProvider temporal = IndexProviderFactoryUtil.temporalProvider( pageCache, fs, childDirectoryStructure, monitor, recoveryCleanupWorkCollector, readOnly ); SpatialIndexProvider spatial = IndexProviderFactoryUtil.spatialProvider( pageCache, fs, childDirectoryStructure, monitor, recoveryCleanupWorkCollector, readOnly, config ); return new FusionIndexProvider( EMPTY, EMPTY, spatial, temporal, lucene, new FusionSlotSelector00(), PROVIDER_DESCRIPTOR, directoriesByProvider( databaseDirectory ), fs, archiveFailedIndex ); }
@Test public void shouldNotAcceptFileFromPureLuceneProvider() throws IOException { // given File dir = directoriesByProviderKey( storeDir ).forProvider( LUCENE_DESCRTIPTOR ).directoryForIndex( 1 ); File file = new File( dir, "some-file" ); createFile( file ); // when boolean accepted = filter.accept( file ); // then assertFalse( accepted ); }
public NativeIndexFileFilter( File storeDir ) { indexRoot = IndexDirectoryStructure.baseSchemaIndexFolder( storeDir ).toPath().toAbsolutePath(); }
public static IndexDirectoryStructure.Factory defaultDirectoryStructure( File storeDir ) { return IndexDirectoryStructure.directoriesByProviderKey( storeDir ); }
public static IndexDirectoryStructure.Factory subProviderDirectoryStructure( File databaseDirectory, IndexProviderDescriptor descriptor ) { IndexDirectoryStructure parentDirectoryStructure = directoriesByProvider( databaseDirectory ).forProvider( descriptor ); return directoriesBySubProvider( parentDirectoryStructure ); } }
@Test public void dropShouldDeleteEntireIndexFolder() { // given File root = storage.directory().directory( "root" ); IndexDirectoryStructure directoryStructure = IndexDirectoryStructure.directoriesByProvider( root ).forProvider( GenericNativeIndexProvider.DESCRIPTOR ); long indexId = 8; File indexDirectory = directoryStructure.directoryForIndex( indexId ); File indexFile = new File( indexDirectory, "my-index" ); StoreIndexDescriptor descriptor = IndexDescriptorFactory.forSchema( SchemaDescriptorFactory.forLabel( 1, 1 ) ).withId( indexId ); IndexSpecificSpaceFillingCurveSettingsCache spatialSettings = mock( IndexSpecificSpaceFillingCurveSettingsCache.class ); FileSystemAbstraction fs = storage.fileSystem(); GenericNativeIndexAccessor accessor = new GenericNativeIndexAccessor( storage.pageCache(), fs, indexFile, new GenericLayout( 1, spatialSettings ), immediate(), EMPTY, descriptor, spatialSettings, directoryStructure, mock( SpaceFillingCurveConfiguration.class ) ); // when accessor.drop(); // then assertFalse( fs.fileExists( indexDirectory ) ); } }
private long dbSpecificLuceneSize( File databaseDirectory ) { return sumIndexFiles( baseSchemaIndexFolder( databaseDirectory ), getNativeIndexFileFilter( databaseDirectory, true ) ); }
/** * @param databaseStoreDir store directory of database, i.e. {@code db} in the example above. * @return {@link Factory} for creating {@link IndexDirectoryStructure} returning directories looking something like: * * <pre> * <db>/schema/index/<providerKey>/<indexId>/ * </pre> */ public static Factory directoriesByProviderKey( File databaseStoreDir ) { return descriptor -> new SubDirectoryByIndexId( path( baseSchemaIndexFolder( databaseStoreDir ), fileNameFriendly( descriptor.getKey() ) ) ); }
private PartitionedIndexStorage getIndexStorage() { IndexStorageFactory storageFactory = new IndexStorageFactory( directoryFactory, fileSystem, directoriesByProviderKey( storeDirectory ).forProvider( PROVIDER_DESCRIPTOR ) ); return storageFactory.indexStorageOf( 1 ); }
private File archiveFile() { File indexDir = nativeIndexDirectoryStructure( db.databaseLayout() ).rootDirectory(); File[] files = indexDir.listFiles( pathname -> pathname.isFile() && pathname.getName().startsWith( "archive-" ) ); if ( files == null || files.length == 0 ) { return null; } assertEquals( 1, files.length ); return files[0]; }
@Override public Lifecycle newInstance( KernelContext context, Supplier noDependencies ) return new IndexProvider( INDEX_PROVIDER, directoriesByProvider( new File( "not-even-persistent" ) ) )
@Override public File directoryForIndex( long indexId ) { return path( parentStructure.directoryForIndex( indexId ), fileNameFriendly( descriptor ) ); } };
private IndexDirectoryStructure.Factory directory() { File storeDir = rules.directory().databaseDir(); return directoriesBySubProvider( directoriesByProvider( storeDir ).forProvider( PROVIDER ) ); }