Skip to content

Commit

Permalink
Add support for Spatial and Temporal in IndexProvider Fusion-1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
burqen committed Mar 22, 2018
1 parent c96c29f commit cc23be1
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 22 deletions.
Expand Up @@ -24,11 +24,13 @@
import org.neo4j.storageengine.api.schema.IndexReader; import org.neo4j.storageengine.api.schema.IndexReader;
import org.neo4j.values.storable.Value; import org.neo4j.values.storable.Value;
import org.neo4j.values.storable.ValueGroup; import org.neo4j.values.storable.ValueGroup;
import org.neo4j.values.storable.Values;


import static org.neo4j.internal.kernel.api.IndexQuery.ExactPredicate; import static org.neo4j.internal.kernel.api.IndexQuery.ExactPredicate;
import static org.neo4j.internal.kernel.api.IndexQuery.NumberRangePredicate;
import static org.neo4j.kernel.impl.index.schema.fusion.FusionIndexBase.LUCENE; import static org.neo4j.kernel.impl.index.schema.fusion.FusionIndexBase.LUCENE;
import static org.neo4j.kernel.impl.index.schema.fusion.FusionIndexBase.NUMBER; import static org.neo4j.kernel.impl.index.schema.fusion.FusionIndexBase.NUMBER;
import static org.neo4j.kernel.impl.index.schema.fusion.FusionIndexBase.SPATIAL;
import static org.neo4j.kernel.impl.index.schema.fusion.FusionIndexBase.TEMPORAL;




/** /**
Expand All @@ -40,7 +42,7 @@ public class FusionSelector10 implements FusionIndexProvider.Selector
@Override @Override
public void validateSatisfied( Object[] instances ) public void validateSatisfied( Object[] instances )
{ {
FusionIndexBase.validateSelectorInstances( instances, NUMBER, LUCENE ); FusionIndexBase.validateSelectorInstances( instances, NUMBER, LUCENE, SPATIAL, TEMPORAL );
} }


@Override @Override
Expand All @@ -59,6 +61,16 @@ public int selectSlot( Value... values )
return NUMBER; return NUMBER;
} }


if ( Values.isGeometryValue( singleValue ) )
{
return SPATIAL;
}

if ( Values.isTemporalValue( singleValue ) )
{
return TEMPORAL;
}

return LUCENE; return LUCENE;
} }


Expand All @@ -77,9 +89,23 @@ public IndexReader select( IndexReader[] instances, IndexQuery... predicates )
return select( instances, exactPredicate.value() ); return select( instances, exactPredicate.value() );
} }


if ( predicate instanceof NumberRangePredicate ) if ( predicate instanceof IndexQuery.RangePredicate )
{ {
return instances[NUMBER]; switch ( predicate.valueGroup() )
{
case NUMBER:
return instances[NUMBER];
case GEOMETRY:
return instances[SPATIAL];
case DATE:
case LOCAL_DATE_TIME:
case ZONED_DATE_TIME:
case LOCAL_TIME:
case ZONED_TIME:
case DURATION:
return instances[TEMPORAL];
default: // fall through
}
} }


if ( predicate instanceof ExistsPredicate ) if ( predicate instanceof ExistsPredicate )
Expand Down
Expand Up @@ -46,7 +46,7 @@ FusionIndexProvider.Selector selector()
@Override @Override
int[] aliveSlots() int[] aliveSlots()
{ {
return new int[]{NUMBER, LUCENE}; return new int[]{NUMBER, LUCENE, SPATIAL, TEMPORAL};
} }


@Override @Override
Expand Down
Expand Up @@ -42,31 +42,29 @@ static boolean isReadOnly( Config config, OperationalMode operationalMode )
return config.get( GraphDatabaseSettings.read_only ) && (OperationalMode.single == operationalMode); return config.get( GraphDatabaseSettings.read_only ) && (OperationalMode.single == operationalMode);
} }


static NumberIndexProvider numberProvider( PageCache pageCache, FileSystemAbstraction fs, IndexProvider.Monitor monitor, static NumberIndexProvider numberProvider( PageCache pageCache, FileSystemAbstraction fs, IndexDirectoryStructure.Factory childDirectoryStructure,
RecoveryCleanupWorkCollector recoveryCleanupWorkCollector, IndexDirectoryStructure.Factory childDirectoryStructure, boolean readOnly ) IndexProvider.Monitor monitor, RecoveryCleanupWorkCollector recoveryCleanupWorkCollector, boolean readOnly )
{ {
return new NumberIndexProvider( pageCache, fs, childDirectoryStructure, monitor, recoveryCleanupWorkCollector, readOnly ); return new NumberIndexProvider( pageCache, fs, childDirectoryStructure, monitor, recoveryCleanupWorkCollector, readOnly );
} }


static SpatialFusionIndexProvider spatialProvider( PageCache pageCache, FileSystemAbstraction fs, IndexProvider.Monitor monitor, static SpatialFusionIndexProvider spatialProvider( PageCache pageCache, FileSystemAbstraction fs, IndexDirectoryStructure.Factory directoryStructure,
RecoveryCleanupWorkCollector recoveryCleanupWorkCollector, boolean readOnly, IndexDirectoryStructure.Factory directoryStructure, IndexProvider.Monitor monitor, RecoveryCleanupWorkCollector recoveryCleanupWorkCollector, boolean readOnly, Config config )
Config config )
{ {
return new SpatialFusionIndexProvider( pageCache, fs, directoryStructure, monitor, recoveryCleanupWorkCollector, readOnly, config ); return new SpatialFusionIndexProvider( pageCache, fs, directoryStructure, monitor, recoveryCleanupWorkCollector, readOnly, config );
} }


static TemporalIndexProvider temporalProvider( PageCache pageCache, FileSystemAbstraction fs, IndexProvider.Monitor monitor, static TemporalIndexProvider temporalProvider( PageCache pageCache, FileSystemAbstraction fs, IndexDirectoryStructure.Factory directoryStructure,
RecoveryCleanupWorkCollector recoveryCleanupWorkCollector, boolean readOnly, IndexDirectoryStructure.Factory directoryStructure ) IndexProvider.Monitor monitor, RecoveryCleanupWorkCollector recoveryCleanupWorkCollector, boolean readOnly )
{ {
return new TemporalIndexProvider( pageCache, fs, directoryStructure, monitor, recoveryCleanupWorkCollector, readOnly ); return new TemporalIndexProvider( pageCache, fs, directoryStructure, monitor, recoveryCleanupWorkCollector, readOnly );
} }


static LuceneIndexProvider luceneProvider( FileSystemAbstraction fileSystemAbstraction, static LuceneIndexProvider luceneProvider( FileSystemAbstraction fs, IndexDirectoryStructure.Factory directoryStructure, IndexProvider.Monitor monitor,
IndexDirectoryStructure.Factory directoryStructure, IndexProvider.Monitor monitor, Config config, Config config, OperationalMode operationalMode )
OperationalMode operationalMode )
{ {
boolean ephemeral = config.get( GraphDatabaseFacadeFactory.Configuration.ephemeral ); boolean ephemeral = config.get( GraphDatabaseFacadeFactory.Configuration.ephemeral );
DirectoryFactory directoryFactory = directoryFactory( ephemeral, fileSystemAbstraction ); DirectoryFactory directoryFactory = directoryFactory( ephemeral, fs );
return new LuceneIndexProvider( fileSystemAbstraction, directoryFactory, directoryStructure, monitor, config, operationalMode ); return new LuceneIndexProvider( fs, directoryFactory, directoryStructure, monitor, config, operationalMode );
} }
} }
Expand Up @@ -100,9 +100,9 @@ public static FusionIndexProvider newInstance( PageCache pageCache, File storeDi


LuceneIndexProvider lucene = IndexProviderFactoryUtil.luceneProvider( fs, baseDirStructure, monitor, config, operationalMode ); LuceneIndexProvider lucene = IndexProviderFactoryUtil.luceneProvider( fs, baseDirStructure, monitor, config, operationalMode );
TemporalIndexProvider temporal = TemporalIndexProvider temporal =
IndexProviderFactoryUtil.temporalProvider( pageCache, fs, monitor, recoveryCleanupWorkCollector, readOnly, childDirectoryStructure ); IndexProviderFactoryUtil.temporalProvider( pageCache, fs, childDirectoryStructure, monitor, recoveryCleanupWorkCollector, readOnly );
SpatialFusionIndexProvider spatial = SpatialFusionIndexProvider spatial =
IndexProviderFactoryUtil.spatialProvider( pageCache, fs, monitor, recoveryCleanupWorkCollector, readOnly, childDirectoryStructure, config ); IndexProviderFactoryUtil.spatialProvider( pageCache, fs, childDirectoryStructure, monitor, recoveryCleanupWorkCollector, readOnly, config );


return new FusionIndexProvider( EMPTY, EMPTY, spatial, temporal, lucene, new FusionSelector00(), return new FusionIndexProvider( EMPTY, EMPTY, spatial, temporal, lucene, new FusionSelector00(),
PROVIDER_DESCRIPTOR, LuceneIndexProvider.PRIORITY, directoriesByProvider( storeDir ), fs ); PROVIDER_DESCRIPTOR, LuceneIndexProvider.PRIORITY, directoriesByProvider( storeDir ), fs );
Expand Down
Expand Up @@ -33,8 +33,10 @@
import org.neo4j.kernel.extension.KernelExtensionFactory; import org.neo4j.kernel.extension.KernelExtensionFactory;
import org.neo4j.kernel.impl.factory.OperationalMode; import org.neo4j.kernel.impl.factory.OperationalMode;
import org.neo4j.kernel.impl.index.schema.NumberIndexProvider; import org.neo4j.kernel.impl.index.schema.NumberIndexProvider;
import org.neo4j.kernel.impl.index.schema.TemporalIndexProvider;
import org.neo4j.kernel.impl.index.schema.fusion.FusionIndexProvider; import org.neo4j.kernel.impl.index.schema.fusion.FusionIndexProvider;
import org.neo4j.kernel.impl.index.schema.fusion.FusionSelector10; import org.neo4j.kernel.impl.index.schema.fusion.FusionSelector10;
import org.neo4j.kernel.impl.index.schema.fusion.SpatialFusionIndexProvider;
import org.neo4j.kernel.impl.spi.KernelContext; import org.neo4j.kernel.impl.spi.KernelContext;
import org.neo4j.kernel.monitoring.Monitors; import org.neo4j.kernel.monitoring.Monitors;
import org.neo4j.logging.Log; import org.neo4j.logging.Log;
Expand Down Expand Up @@ -84,14 +86,18 @@ public static FusionIndexProvider newInstance( PageCache pageCache, File storeDi
IndexDirectoryStructure.Factory childDirectoryStructure = subProviderDirectoryStructure( storeDir ); IndexDirectoryStructure.Factory childDirectoryStructure = subProviderDirectoryStructure( storeDir );
boolean readOnly = IndexProviderFactoryUtil.isReadOnly( config, operationalMode ); boolean readOnly = IndexProviderFactoryUtil.isReadOnly( config, operationalMode );


// This is the v1.0 of the lucene+native fusion setup where there's only number+lucene indexes // This is the v1.0 of the lucene+native fusion setup where there's only number+spatial+temporal+lucene indexes
NumberIndexProvider number = NumberIndexProvider number =
IndexProviderFactoryUtil.numberProvider( pageCache, fs, monitor, recoveryCleanupWorkCollector, childDirectoryStructure, readOnly ); IndexProviderFactoryUtil.numberProvider( pageCache, fs, childDirectoryStructure, monitor, recoveryCleanupWorkCollector, readOnly );
SpatialFusionIndexProvider spatial =
IndexProviderFactoryUtil.spatialProvider( pageCache, fs, childDirectoryStructure, monitor, recoveryCleanupWorkCollector, readOnly, config );
TemporalIndexProvider temporal =
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 );


boolean useNativeIndex = config.get( GraphDatabaseSettings.enable_native_schema_index ); boolean useNativeIndex = config.get( GraphDatabaseSettings.enable_native_schema_index );
int priority = useNativeIndex ? PRIORITY : 0; int priority = useNativeIndex ? PRIORITY : 0;
return new FusionIndexProvider( EMPTY, number, EMPTY, EMPTY, lucene, new FusionSelector10(), return new FusionIndexProvider( EMPTY, number, spatial, temporal, lucene, new FusionSelector10(),
DESCRIPTOR, priority, directoriesByProvider( storeDir ), fs ); DESCRIPTOR, priority, directoriesByProvider( storeDir ), fs );
} }


Expand Down

0 comments on commit cc23be1

Please sign in to comment.