Skip to content

Commit

Permalink
PR comment: GraphDatabaseSettings#SchemaIndex owns index provider pri…
Browse files Browse the repository at this point in the history
…ority
  • Loading branch information
burqen committed Jul 27, 2018
1 parent d64c89b commit 1876944
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 35 deletions.
Expand Up @@ -37,6 +37,7 @@
import org.neo4j.helpers.ListenSocketAddress; import org.neo4j.helpers.ListenSocketAddress;
import org.neo4j.io.ByteUnit; import org.neo4j.io.ByteUnit;
import org.neo4j.kernel.configuration.BoltConnectorValidator; import org.neo4j.kernel.configuration.BoltConnectorValidator;
import org.neo4j.kernel.configuration.Config;
import org.neo4j.kernel.configuration.ConfigurationMigrator; import org.neo4j.kernel.configuration.ConfigurationMigrator;
import org.neo4j.kernel.configuration.GraphDatabaseConfigurationMigrator; import org.neo4j.kernel.configuration.GraphDatabaseConfigurationMigrator;
import org.neo4j.kernel.configuration.Group; import org.neo4j.kernel.configuration.Group;
Expand Down Expand Up @@ -559,16 +560,18 @@ public class GraphDatabaseSettings implements LoadableConfig


public enum SchemaIndex public enum SchemaIndex
{ {
NATIVE_GBPTREE10( "native-gbptree", "1.0" ), NATIVE_GBPTREE10( 0, "native-gbptree", "1.0" ), // TODO: Zero because should not be default yet.
NATIVE20( "lucene+native", "2.0" ), NATIVE20( 3, "lucene+native", "2.0" ),
NATIVE10( "lucene+native", "1.0" ), NATIVE10( 2, "lucene+native", "1.0" ),
LUCENE10( "lucene", "1.0" ); LUCENE10( 1, "lucene", "1.0" );


private final int priority; // Higher is better
private final String providerName; private final String providerName;
private final String providerVersion; private final String providerVersion;


SchemaIndex( String providerName, String providerVersion ) SchemaIndex( int priority, String providerName, String providerVersion )
{ {
this.priority = priority;
this.providerName = providerName; this.providerName = providerName;
this.providerVersion = providerVersion; this.providerVersion = providerVersion;
} }
Expand All @@ -587,6 +590,12 @@ public String providerVersion()
{ {
return providerVersion; return providerVersion;
} }

public int priority( Config config )
{
String configuredSchemaProvider = config.get( GraphDatabaseSettings.default_schema_provider );
return providerIdentifier().equals( configuredSchemaProvider ) ? 100 : priority;
}
} }


@Description( "Index provider to use for newly created schema indexes. " + @Description( "Index provider to use for newly created schema indexes. " +
Expand Down
Expand Up @@ -21,7 +21,6 @@


import java.io.File; import java.io.File;


import org.neo4j.graphdb.factory.GraphDatabaseSettings;
import org.neo4j.index.internal.gbptree.RecoveryCleanupWorkCollector; import org.neo4j.index.internal.gbptree.RecoveryCleanupWorkCollector;
import org.neo4j.io.fs.FileSystemAbstraction; import org.neo4j.io.fs.FileSystemAbstraction;
import org.neo4j.io.pagecache.PageCache; import org.neo4j.io.pagecache.PageCache;
Expand Down Expand Up @@ -60,12 +59,6 @@ public Lifecycle newInstance( KernelContext context, Dependencies dependencies )
return internalCreate( pageCache, databaseDir, fs, monitor, config, operationalMode, recoveryCleanupWorkCollector ); return internalCreate( pageCache, databaseDir, fs, monitor, config, operationalMode, recoveryCleanupWorkCollector );
} }


protected static int adjustPriorityForConfig( int basePriority, GraphDatabaseSettings.SchemaIndex target, Config config )
{
String defaultSchemaProvider = config.get( GraphDatabaseSettings.default_schema_provider );
return target.providerIdentifier().equals( defaultSchemaProvider ) ? 100 : basePriority;
}

protected abstract Class loggingClass(); protected abstract Class loggingClass();


protected abstract String descriptorString(); protected abstract String descriptorString();
Expand Down
Expand Up @@ -82,9 +82,9 @@
*/ */
public class GenericNativeIndexProvider extends NativeIndexProvider<CompositeGenericKey,NativeIndexValue> public class GenericNativeIndexProvider extends NativeIndexProvider<CompositeGenericKey,NativeIndexValue>
{ {
public static final String KEY = GraphDatabaseSettings.SchemaIndex.NATIVE_GBPTREE10.providerName(); public static final GraphDatabaseSettings.SchemaIndex SCHEMA_INDEX = GraphDatabaseSettings.SchemaIndex.NATIVE_GBPTREE10;
public static final String VERSION = GraphDatabaseSettings.SchemaIndex.NATIVE_GBPTREE10.providerVersion(); public static final String KEY = SCHEMA_INDEX.providerName();
public static final IndexProvider.Descriptor DESCRIPTOR = new IndexProvider.Descriptor( KEY, VERSION ); public static final IndexProvider.Descriptor DESCRIPTOR = new IndexProvider.Descriptor( KEY, SCHEMA_INDEX.providerVersion() );


// TODO implement // TODO implement
public static final IndexCapability CAPABILITY = new IndexCapability() public static final IndexCapability CAPABILITY = new IndexCapability()
Expand Down
Expand Up @@ -37,8 +37,6 @@
@Service.Implementation( KernelExtensionFactory.class ) @Service.Implementation( KernelExtensionFactory.class )
public class GenericNativeIndexProviderFactory extends AbstractIndexProviderFactory public class GenericNativeIndexProviderFactory extends AbstractIndexProviderFactory
{ {
private static final int PRIORITY = 0; // TODO: Zero because should not be default yet.

public GenericNativeIndexProviderFactory() public GenericNativeIndexProviderFactory()
{ {
super( GenericNativeIndexProvider.KEY ); super( GenericNativeIndexProvider.KEY );
Expand Down Expand Up @@ -66,7 +64,7 @@ protected GenericNativeIndexProvider internalCreate( PageCache pageCache, File s
public static GenericNativeIndexProvider create( PageCache pageCache, File storeDir, FileSystemAbstraction fs, IndexProvider.Monitor monitor, Config config, public static GenericNativeIndexProvider create( PageCache pageCache, File storeDir, FileSystemAbstraction fs, IndexProvider.Monitor monitor, Config config,
OperationalMode mode, RecoveryCleanupWorkCollector recoveryCleanupWorkCollector ) OperationalMode mode, RecoveryCleanupWorkCollector recoveryCleanupWorkCollector )
{ {
int priority = adjustPriorityForConfig( PRIORITY, GraphDatabaseSettings.SchemaIndex.NATIVE_GBPTREE10, config ); int priority = GenericNativeIndexProvider.SCHEMA_INDEX.priority( config );


IndexDirectoryStructure.Factory directoryStructure = directoriesByProvider( storeDir ); IndexDirectoryStructure.Factory directoryStructure = directoriesByProvider( storeDir );
boolean readOnly = config.get( GraphDatabaseSettings.read_only ) && (OperationalMode.single == mode); boolean readOnly = config.get( GraphDatabaseSettings.read_only ) && (OperationalMode.single == mode);
Expand Down
Expand Up @@ -48,8 +48,6 @@


public class LuceneIndexProvider extends IndexProvider public class LuceneIndexProvider extends IndexProvider
{ {
static final int PRIORITY = 1;

private final IndexStorageFactory indexStorageFactory; private final IndexStorageFactory indexStorageFactory;
private final Config config; private final Config config;
private final OperationalMode operationalMode; private final OperationalMode operationalMode;
Expand All @@ -60,7 +58,7 @@ public LuceneIndexProvider( FileSystemAbstraction fileSystem, DirectoryFactory d
IndexDirectoryStructure.Factory directoryStructureFactory, Monitor monitor, Config config, IndexDirectoryStructure.Factory directoryStructureFactory, Monitor monitor, Config config,
OperationalMode operationalMode ) OperationalMode operationalMode )
{ {
super( LuceneIndexProviderFactory.PROVIDER_DESCRIPTOR, PRIORITY, directoryStructureFactory ); super( LuceneIndexProviderFactory.PROVIDER_DESCRIPTOR, 0, directoryStructureFactory );
this.monitor = monitor; this.monitor = monitor;
this.indexStorageFactory = buildIndexStorageFactory( fileSystem, directoryFactory ); this.indexStorageFactory = buildIndexStorageFactory( fileSystem, directoryFactory );
this.fileSystem = fileSystem; this.fileSystem = fileSystem;
Expand Down
Expand Up @@ -44,9 +44,9 @@
@Service.Implementation( KernelExtensionFactory.class ) @Service.Implementation( KernelExtensionFactory.class )
public class LuceneIndexProviderFactory extends AbstractIndexProviderFactory public class LuceneIndexProviderFactory extends AbstractIndexProviderFactory
{ {
public static final String KEY = GraphDatabaseSettings.SchemaIndex.LUCENE10.providerName(); private static final GraphDatabaseSettings.SchemaIndex SCHEMA_INDEX = GraphDatabaseSettings.SchemaIndex.LUCENE10;
public static final String VERSION = GraphDatabaseSettings.SchemaIndex.LUCENE10.providerVersion(); private static final String KEY = SCHEMA_INDEX.providerName();
public static final IndexProvider.Descriptor PROVIDER_DESCRIPTOR = new IndexProvider.Descriptor( KEY, VERSION ); public static final IndexProvider.Descriptor PROVIDER_DESCRIPTOR = new IndexProvider.Descriptor( KEY, SCHEMA_INDEX.providerVersion() );


public LuceneIndexProviderFactory() public LuceneIndexProviderFactory()
{ {
Expand Down Expand Up @@ -87,7 +87,7 @@ public static FusionIndexProvider newInstance( PageCache pageCache, File databas
SpatialIndexProvider spatial = SpatialIndexProvider spatial =
IndexProviderFactoryUtil.spatialProvider( pageCache, fs, childDirectoryStructure, monitor, recoveryCleanupWorkCollector, readOnly, config ); IndexProviderFactoryUtil.spatialProvider( pageCache, fs, childDirectoryStructure, monitor, recoveryCleanupWorkCollector, readOnly, config );


int priority = adjustPriorityForConfig( LuceneIndexProvider.PRIORITY, GraphDatabaseSettings.SchemaIndex.LUCENE10, config ); int priority = SCHEMA_INDEX.priority( config );
return new FusionIndexProvider( EMPTY, EMPTY, spatial, temporal, lucene, new FusionSlotSelector00(), return new FusionIndexProvider( EMPTY, EMPTY, spatial, temporal, lucene, new FusionSlotSelector00(),
PROVIDER_DESCRIPTOR, priority, directoriesByProvider( databaseDirectory ), fs, archiveFailedIndex ); PROVIDER_DESCRIPTOR, priority, directoriesByProvider( databaseDirectory ), fs, archiveFailedIndex );
} }
Expand Down
Expand Up @@ -43,10 +43,9 @@
@Service.Implementation( KernelExtensionFactory.class ) @Service.Implementation( KernelExtensionFactory.class )
public class NativeLuceneFusionIndexProviderFactory10 extends NativeLuceneFusionIndexProviderFactory public class NativeLuceneFusionIndexProviderFactory10 extends NativeLuceneFusionIndexProviderFactory
{ {
public static final String KEY = GraphDatabaseSettings.SchemaIndex.NATIVE10.providerName(); private static final GraphDatabaseSettings.SchemaIndex SCHEMA_INDEX = GraphDatabaseSettings.SchemaIndex.NATIVE10;
public static final String VERSION = GraphDatabaseSettings.SchemaIndex.NATIVE10.providerVersion(); private static final String KEY = SCHEMA_INDEX.providerName();
public static final IndexProvider.Descriptor DESCRIPTOR = new IndexProvider.Descriptor( KEY, VERSION ); public static final IndexProvider.Descriptor DESCRIPTOR = new IndexProvider.Descriptor( KEY, SCHEMA_INDEX.providerVersion() );
static final int PRIORITY = LuceneIndexProvider.PRIORITY + 1;


public NativeLuceneFusionIndexProviderFactory10() public NativeLuceneFusionIndexProviderFactory10()
{ {
Expand Down Expand Up @@ -82,7 +81,7 @@ public static FusionIndexProvider create( PageCache pageCache, File databaseDire
IndexProviderFactoryUtil.temporalProvider( pageCache, fs, childDirectoryStructure, monitor, recoveryCleanupWorkCollector, readOnly ); IndexProviderFactoryUtil.temporalProvider( pageCache, fs, childDirectoryStructure, monitor, recoveryCleanupWorkCollector, readOnly );
LuceneIndexProvider lucene = IndexProviderFactoryUtil.luceneProvider( fs, childDirectoryStructure, monitor, config, operationalMode ); LuceneIndexProvider lucene = IndexProviderFactoryUtil.luceneProvider( fs, childDirectoryStructure, monitor, config, operationalMode );


int priority = adjustPriorityForConfig( PRIORITY, GraphDatabaseSettings.SchemaIndex.NATIVE10, config ); int priority = SCHEMA_INDEX.priority( config );
return new FusionIndexProvider( EMPTY, number, spatial, temporal, lucene, new FusionSlotSelector10(), return new FusionIndexProvider( EMPTY, number, spatial, temporal, lucene, new FusionSlotSelector10(),
DESCRIPTOR, priority, directoriesByProvider( databaseDirectory ), fs, archiveFailedIndex ); DESCRIPTOR, priority, directoriesByProvider( databaseDirectory ), fs, archiveFailedIndex );
} }
Expand Down
Expand Up @@ -43,10 +43,9 @@
@Service.Implementation( KernelExtensionFactory.class ) @Service.Implementation( KernelExtensionFactory.class )
public class NativeLuceneFusionIndexProviderFactory20 extends NativeLuceneFusionIndexProviderFactory public class NativeLuceneFusionIndexProviderFactory20 extends NativeLuceneFusionIndexProviderFactory
{ {
public static final String KEY = GraphDatabaseSettings.SchemaIndex.NATIVE20.providerName(); private static final GraphDatabaseSettings.SchemaIndex SCHEMA_INDEX = GraphDatabaseSettings.SchemaIndex.NATIVE20;
public static final String VERSION = GraphDatabaseSettings.SchemaIndex.NATIVE20.providerVersion(); public static final String KEY = SCHEMA_INDEX.providerName();
public static final IndexProvider.Descriptor DESCRIPTOR = new IndexProvider.Descriptor( KEY, VERSION ); public static final IndexProvider.Descriptor DESCRIPTOR = new IndexProvider.Descriptor( KEY, SCHEMA_INDEX.providerVersion() );
private static final int PRIORITY = NativeLuceneFusionIndexProviderFactory10.PRIORITY + 1;


public NativeLuceneFusionIndexProviderFactory20() public NativeLuceneFusionIndexProviderFactory20()
{ {
Expand Down Expand Up @@ -84,7 +83,7 @@ public static FusionIndexProvider create( PageCache pageCache, File databaseDire
IndexProviderFactoryUtil.temporalProvider( pageCache, fs, childDirectoryStructure, monitor, recoveryCleanupWorkCollector, readOnly ); IndexProviderFactoryUtil.temporalProvider( pageCache, fs, childDirectoryStructure, monitor, recoveryCleanupWorkCollector, readOnly );
LuceneIndexProvider lucene = IndexProviderFactoryUtil.luceneProvider( fs, childDirectoryStructure, monitor, config, operationalMode ); LuceneIndexProvider lucene = IndexProviderFactoryUtil.luceneProvider( fs, childDirectoryStructure, monitor, config, operationalMode );


int priority = adjustPriorityForConfig( PRIORITY, GraphDatabaseSettings.SchemaIndex.NATIVE20, config ); int priority = SCHEMA_INDEX.priority( config );
return new FusionIndexProvider( string, number, spatial, temporal, lucene, new FusionSlotSelector20(), return new FusionIndexProvider( string, number, spatial, temporal, lucene, new FusionSlotSelector20(),
DESCRIPTOR, priority, directoriesByProvider( databaseDirectory ), fs, archiveFailedIndex ); DESCRIPTOR, priority, directoriesByProvider( databaseDirectory ), fs, archiveFailedIndex );
} }
Expand Down

0 comments on commit 1876944

Please sign in to comment.