Skip to content

Commit

Permalink
Some provider factory additions
Browse files Browse the repository at this point in the history
  • Loading branch information
tinwelint authored and burqen committed Jul 27, 2018
1 parent 28430f8 commit d3b8b23
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 10 deletions.
Expand Up @@ -17,15 +17,13 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.neo4j.kernel.api.impl.schema; package org.neo4j.kernel.api.index;


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


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;
import org.neo4j.kernel.api.index.IndexProvider;
import org.neo4j.kernel.api.index.IndexProviderCompatibilityTestSuite;
import org.neo4j.kernel.configuration.Config; import org.neo4j.kernel.configuration.Config;
import org.neo4j.kernel.impl.factory.OperationalMode; import org.neo4j.kernel.impl.factory.OperationalMode;
import org.neo4j.kernel.impl.index.schema.GenericNativeIndexProviderFactory; import org.neo4j.kernel.impl.index.schema.GenericNativeIndexProviderFactory;
Expand Down
Expand Up @@ -555,6 +555,7 @@ public class GraphDatabaseSettings implements LoadableConfig


public enum SchemaIndex public enum SchemaIndex
{ {
ALL_NATIVE10( "all-native-1.0" ), // TODO naming damnit
NATIVE20( "lucene+native-2.0" ), NATIVE20( "lucene+native-2.0" ),
NATIVE10( "lucene+native-1.0" ), NATIVE10( "lucene+native-1.0" ),
LUCENE10( "lucene-1.0" ); LUCENE10( "lucene-1.0" );
Expand Down Expand Up @@ -590,7 +591,8 @@ public String providerName()
"- Controllable memory usage, due to being bound by the page cache" ) "- Controllable memory usage, due to being bound by the page cache" )
public static final Setting<String> default_schema_provider = public static final Setting<String> default_schema_provider =
setting( "dbms.index.default_schema_provider", setting( "dbms.index.default_schema_provider",
optionsIgnoreCase( SchemaIndex.NATIVE20.providerName(), SchemaIndex.NATIVE10.providerName(), SchemaIndex.LUCENE10.providerName() ), optionsIgnoreCase( SchemaIndex.NATIVE20.providerName(), SchemaIndex.NATIVE10.providerName(), SchemaIndex.LUCENE10.providerName(),
SchemaIndex.ALL_NATIVE10.providerName() ),
null ); null );


@Description( "Location where Neo4j keeps the logical transaction logs." ) @Description( "Location where Neo4j keeps the logical transaction logs." )
Expand Down
Expand Up @@ -32,6 +32,7 @@
import org.neo4j.kernel.api.index.IndexAccessor; import org.neo4j.kernel.api.index.IndexAccessor;
import org.neo4j.kernel.api.index.IndexDirectoryStructure; import org.neo4j.kernel.api.index.IndexDirectoryStructure;
import org.neo4j.kernel.api.index.IndexPopulator; import org.neo4j.kernel.api.index.IndexPopulator;
import org.neo4j.kernel.api.index.IndexProvider;
import org.neo4j.kernel.api.schema.index.StoreIndexDescriptor; import org.neo4j.kernel.api.schema.index.StoreIndexDescriptor;
import org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig; import org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig;
import org.neo4j.values.storable.ValueCategory; import org.neo4j.values.storable.ValueCategory;
Expand All @@ -41,8 +42,9 @@
*/ */
public class GenericNativeIndexProvider extends NativeIndexProvider<CompositeGenericKey,NativeIndexValue> public class GenericNativeIndexProvider extends NativeIndexProvider<CompositeGenericKey,NativeIndexValue>
{ {
public static final String KEY = "native-all"; // TODO should be native, but can't because number index is called that. public static final String KEY = "all-native"; // TODO should be native, but can't because number index is called that.
public static final Descriptor DESCRIPTOR = new Descriptor( KEY, "1.0" ); public static final IndexProvider.Descriptor DESCRIPTOR = new IndexProvider.Descriptor( KEY, "1.0" );

// TODO implement // TODO implement
public static final IndexCapability CAPABILITY = new IndexCapability() public static final IndexCapability CAPABILITY = new IndexCapability()
{ {
Expand All @@ -59,10 +61,10 @@ public IndexValueCapability valueCapability( ValueCategory... valueCategories )
} }
}; };


public GenericNativeIndexProvider( IndexDirectoryStructure.Factory directoryStructureFactory, PageCache pageCache, public GenericNativeIndexProvider( int priority, IndexDirectoryStructure.Factory directoryStructureFactory, PageCache pageCache,
FileSystemAbstraction fs, Monitor monitor, RecoveryCleanupWorkCollector recoveryCleanupWorkCollector, boolean readOnly ) FileSystemAbstraction fs, Monitor monitor, RecoveryCleanupWorkCollector recoveryCleanupWorkCollector, boolean readOnly )
{ {
super( DESCRIPTOR, 1_000, directoryStructureFactory, pageCache, fs, monitor, recoveryCleanupWorkCollector, readOnly ); super( DESCRIPTOR, priority, directoryStructureFactory, pageCache, fs, monitor, recoveryCleanupWorkCollector, readOnly );
} }


@Override @Override
Expand Down
Expand Up @@ -44,9 +44,11 @@
@Service.Implementation( KernelExtensionFactory.class ) @Service.Implementation( KernelExtensionFactory.class )
public class GenericNativeIndexProviderFactory extends KernelExtensionFactory<GenericNativeIndexProviderFactory.Dependencies> public class GenericNativeIndexProviderFactory extends KernelExtensionFactory<GenericNativeIndexProviderFactory.Dependencies>
{ {
private static final int PRIORITY = 0;

public GenericNativeIndexProviderFactory() public GenericNativeIndexProviderFactory()
{ {
super( "all-native" ); super( GenericNativeIndexProvider.KEY );
} }


public interface Dependencies public interface Dependencies
Expand Down Expand Up @@ -83,8 +85,15 @@ public GenericNativeIndexProvider newInstance( KernelContext context, Dependenci
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 )
{ {
String selectedSchemaProvider = config.get( GraphDatabaseSettings.default_schema_provider );
int priority = PRIORITY;
if ( GraphDatabaseSettings.SchemaIndex.ALL_NATIVE10.providerName().equals( selectedSchemaProvider ) )
{
priority = 100;
}

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);
return new GenericNativeIndexProvider( directoryStructure, pageCache, fs, monitor, recoveryCleanupWorkCollector, readOnly ); return new GenericNativeIndexProvider( priority, directoryStructure, pageCache, fs, monitor, recoveryCleanupWorkCollector, readOnly );
} }
} }
@@ -0,0 +1 @@
org.neo4j.kernel.impl.index.schema.GenericNativeIndexProviderFactory

0 comments on commit d3b8b23

Please sign in to comment.