diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/SpatialKnownIndex.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/SpatialCRSSchemaIndex.java similarity index 90% rename from community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/SpatialKnownIndex.java rename to community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/SpatialCRSSchemaIndex.java index 3edb2080b8b57..a523a30dc57ed 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/SpatialKnownIndex.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/SpatialCRSSchemaIndex.java @@ -65,18 +65,17 @@ import static org.neo4j.kernel.impl.index.schema.NativeSchemaIndexPopulator.BYTE_POPULATING; /** - * An instance of this class represents a dynamically created sub-index specific to a particular coordinate reference system. + * A dynamically created sub-index specific to a particular coordinate reference system. * This allows the fusion index design to be extended to an unknown number of sub-indexes, one for each CRS. */ -public class SpatialKnownIndex +public class SpatialCRSSchemaIndex { private UniqueIndexSampler uniqueSampler; private final File indexFile; private final PageCache pageCache; + private final IndexDescriptor descriptor; private final CoordinateReferenceSystem crs; - private final long indexId; private final FileSystemAbstraction fs; - private final SchemaIndexProvider.Monitor monitor; private final RecoveryCleanupWorkCollector recoveryCleanupWorkCollector; private final SpaceFillingCurve curve; @@ -92,18 +91,19 @@ public class SpatialKnownIndex private WorkSync,IndexUpdateWork> workSync; private DefaultNonUniqueIndexSampler generalSampler; - /** - * Create a representation of a spatial index for a specific coordinate reference system. - * This constructor should be used for first time creation. - */ - public SpatialKnownIndex( IndexDirectoryStructure directoryStructure, CoordinateReferenceSystem crs, long indexId, PageCache pageCache, - FileSystemAbstraction fs, SchemaIndexProvider.Monitor monitor, RecoveryCleanupWorkCollector recoveryCleanupWorkCollector ) + public SpatialCRSSchemaIndex( IndexDescriptor descriptor, + IndexDirectoryStructure directoryStructure, + CoordinateReferenceSystem crs, + long indexId, + PageCache pageCache, + FileSystemAbstraction fs, + SchemaIndexProvider.Monitor monitor, + RecoveryCleanupWorkCollector recoveryCleanupWorkCollector ) { + this.descriptor = descriptor; this.crs = crs; - this.indexId = indexId; this.pageCache = pageCache; this.fs = fs; - this.monitor = monitor; this.recoveryCleanupWorkCollector = recoveryCleanupWorkCollector; // Depends on crs @@ -125,25 +125,31 @@ else if ( crs.getDimension() == 3 ) throw new IllegalArgumentException( "Cannot create spatial index with other than 2D or 3D coordinate reference system: " + crs ); } state = State.NONE; + + layout = layout( descriptor ); + treeKey = layout.newKey(); + treeValue = layout.newValue(); + schemaIndex = new NativeSchemaIndex<>( pageCache, fs, indexFile, layout, monitor, descriptor, indexId ); + } /** * Makes sure that the index is initialized */ - public void init( IndexDescriptor descriptor, IndexSamplingConfig samplingConfig ) + public void init( IndexSamplingConfig samplingConfig ) { if ( state == State.NONE ) { - initialize( descriptor, samplingConfig ); + initialize( samplingConfig ); } } /** * Makes sure that the index is ready to populate */ - public void startPopulation( IndexDescriptor descriptor, IndexSamplingConfig samplingConfig ) throws IOException + public void startPopulation( IndexSamplingConfig samplingConfig ) throws IOException { - init( descriptor, samplingConfig ); + init( samplingConfig ); if ( state == State.INIT ) { // First add to sub-index, make sure to create @@ -158,9 +164,9 @@ public void startPopulation( IndexDescriptor descriptor, IndexSamplingConfig sam /** * Makes sure that the index is online */ - public void takeOnline( IndexDescriptor descriptor, IndexSamplingConfig samplingConfig ) throws IOException + public void takeOnline( IndexSamplingConfig samplingConfig ) throws IOException { - init( descriptor, samplingConfig ); + init( samplingConfig ); if ( !indexExists() ) { throw new IOException( "Index file does not exist." ); @@ -175,14 +181,14 @@ public void takeOnline( IndexDescriptor descriptor, IndexSamplingConfig sampling } } - public IndexUpdater updaterWithCreate( IndexDescriptor descriptor, IndexSamplingConfig samplingConfig, boolean populating ) throws IOException + public IndexUpdater updaterWithCreate( IndexSamplingConfig samplingConfig, boolean populating ) throws IOException { if ( populating ) { if ( state == State.NONE ) { // sub-index didn't exist, create in populating mode - initialize( descriptor, samplingConfig ); + initialize( samplingConfig ); create(); } return newPopulatingUpdater(); @@ -192,7 +198,7 @@ public IndexUpdater updaterWithCreate( IndexDescriptor descriptor, IndexSampling if ( state == State.NONE ) { // sub-index didn't exist, create and make it online - initialize( descriptor, samplingConfig ); + initialize( samplingConfig ); create(); finishPopulation( true ); online(); @@ -434,13 +440,9 @@ private synchronized void create() throws IOException state = State.POPULATING; } - private void initialize( IndexDescriptor descriptor, IndexSamplingConfig samplingConfig ) + private void initialize( IndexSamplingConfig samplingConfig ) { assert state == State.NONE; - layout = layout( descriptor ); - treeKey = layout.newKey(); - treeValue = layout.newValue(); - schemaIndex = new NativeSchemaIndex<>( pageCache, fs, indexFile, layout, monitor, descriptor, indexId ); if ( isUnique( descriptor ) ) { uniqueSampler = new UniqueIndexSampler(); @@ -552,7 +554,8 @@ private enum State public interface Factory { - SpatialKnownIndex selectAndCreate( Map indexMap, long indexId, + SpatialCRSSchemaIndex selectAndCreate( IndexDescriptor descriptor, + Map indexMap, long indexId, CoordinateReferenceSystem crs ); } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/SpatialSchemaIndexReader.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/SpatialSchemaIndexReader.java index c8cb0c08e21c4..cbb5ddfb00348 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/SpatialSchemaIndexReader.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/SpatialSchemaIndexReader.java @@ -34,12 +34,10 @@ import org.neo4j.internal.kernel.api.IndexQuery; import org.neo4j.internal.kernel.api.IndexQuery.ExactPredicate; import org.neo4j.internal.kernel.api.IndexQuery.GeometryRangePredicate; -import org.neo4j.kernel.api.exceptions.index.IndexNotApplicableKernelException; import org.neo4j.kernel.api.schema.index.IndexDescriptor; import org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig; import org.neo4j.kernel.impl.index.schema.fusion.BridgingIndexProgressor; import org.neo4j.storageengine.api.schema.IndexProgressor; -import org.neo4j.values.storable.PointValue; import org.neo4j.values.storable.Value; import static java.lang.String.format; @@ -128,7 +126,7 @@ private void startSeekForRange( IndexProgressor.NodeValueClient client, Geometry BridgingIndexProgressor multiProgressor = new BridgingIndexProgressor( client, descriptor.schema().getPropertyIds() ); client.initialize( descriptor, multiProgressor, query ); SpaceFillingCurve curve = spatial.getSpaceFillingCurve(); - Envelope completeEnvelope = SpatialKnownIndex.envelopeFromCRS( spatial.crs ); + Envelope completeEnvelope = SpatialCRSSchemaIndex.envelopeFromCRS( spatial.crs ); double[] from = rangePredicate.from() == null ? completeEnvelope.getMin() : rangePredicate.from().coordinate(); double[] to = rangePredicate.to() == null ? completeEnvelope.getMax() : rangePredicate.to().coordinate(); Envelope envelope = new Envelope( from, to ); diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/fusion/SpatialFusionIndexAccessor.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/fusion/SpatialFusionIndexAccessor.java index 5eddbcd8741c7..1648a7ad7b31a 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/fusion/SpatialFusionIndexAccessor.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/fusion/SpatialFusionIndexAccessor.java @@ -38,7 +38,7 @@ import org.neo4j.kernel.api.schema.index.IndexDescriptor; import org.neo4j.kernel.impl.api.index.IndexUpdateMode; import org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig; -import org.neo4j.kernel.impl.index.schema.SpatialKnownIndex; +import org.neo4j.kernel.impl.index.schema.SpatialCRSSchemaIndex; import org.neo4j.storageengine.api.schema.IndexReader; import org.neo4j.values.storable.CoordinateReferenceSystem; @@ -47,30 +47,30 @@ class SpatialFusionIndexAccessor implements IndexAccessor { - private final Map indexMap; + private final Map indexMap; private final long indexId; private final IndexDescriptor descriptor; private final IndexSamplingConfig samplingConfig; - private final SpatialKnownIndex.Factory indexFactory; + private final SpatialCRSSchemaIndex.Factory indexFactory; - SpatialFusionIndexAccessor( Map indexMap, long indexId, IndexDescriptor descriptor, - IndexSamplingConfig samplingConfig, SpatialKnownIndex.Factory indexFactory ) throws IOException + SpatialFusionIndexAccessor( Map indexMap, long indexId, IndexDescriptor descriptor, + IndexSamplingConfig samplingConfig, SpatialCRSSchemaIndex.Factory indexFactory ) throws IOException { this.indexMap = indexMap; this.indexId = indexId; this.descriptor = descriptor; this.samplingConfig = samplingConfig; this.indexFactory = indexFactory; - for ( SpatialKnownIndex index : indexMap.values() ) + for ( SpatialCRSSchemaIndex index : indexMap.values() ) { - index.takeOnline(descriptor, samplingConfig); + index.takeOnline( samplingConfig ); } } @Override public void drop() throws IOException { - forAll( SpatialKnownIndex::drop, indexMap.values() ); + forAll( SpatialCRSSchemaIndex::drop, indexMap.values() ); indexMap.clear(); } @@ -83,7 +83,7 @@ public IndexUpdater newUpdater( IndexUpdateMode mode ) @Override public void force( IOLimiter ioLimiter ) throws IOException { - forAll( spatialKnownIndex -> spatialKnownIndex.force( ioLimiter ), indexMap.values() ); + forAll( spatialCRSSchemaIndex -> spatialCRSSchemaIndex.force( ioLimiter ), indexMap.values() ); } @Override @@ -95,14 +95,14 @@ public void refresh() @Override public void close() throws IOException { - forAll( SpatialKnownIndex::close, indexMap.values() ); + forAll( SpatialCRSSchemaIndex::close, indexMap.values() ); } @Override public IndexReader newReader() { Map indexReaders = new HashMap<>(); - for ( Map.Entry index : indexMap.entrySet() ) + for ( Map.Entry index : indexMap.entrySet() ) { // TODO should this be populated here, or delegate to SpatialFusionIndexReader? indexReaders.put( index.getKey(), index.getValue().newReader( samplingConfig, descriptor ) ); @@ -114,7 +114,7 @@ public IndexReader newReader() public BoundedIterable newAllEntriesReader() { ArrayList> allEntriesReader = new ArrayList<>(); - for ( SpatialKnownIndex index : indexMap.values() ) + for ( SpatialCRSSchemaIndex index : indexMap.values() ) { allEntriesReader.add( index.newAllEntriesReader() ); } @@ -151,7 +151,7 @@ public Iterator iterator() public ResourceIterator snapshotFiles() throws IOException { List> snapshotFiles = new ArrayList<>(); - for ( SpatialKnownIndex index : indexMap.values() ) + for ( SpatialCRSSchemaIndex index : indexMap.values() ) { snapshotFiles.add( index.snapshotFiles() ); } @@ -168,6 +168,6 @@ public void verifyDeferredConstraints( PropertyAccessor propertyAccessor ) @Override public boolean isDirty() { - return indexMap.values().stream().anyMatch( SpatialKnownIndex::wasDirtyOnStartup ); + return indexMap.values().stream().anyMatch( SpatialCRSSchemaIndex::wasDirtyOnStartup ); } } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/fusion/SpatialFusionIndexPopulator.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/fusion/SpatialFusionIndexPopulator.java index 6838844af43db..9e1524616dd9f 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/fusion/SpatialFusionIndexPopulator.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/fusion/SpatialFusionIndexPopulator.java @@ -32,7 +32,7 @@ import org.neo4j.kernel.api.index.PropertyAccessor; import org.neo4j.kernel.api.schema.index.IndexDescriptor; import org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig; -import org.neo4j.kernel.impl.index.schema.SpatialKnownIndex; +import org.neo4j.kernel.impl.index.schema.SpatialCRSSchemaIndex; import org.neo4j.storageengine.api.schema.IndexSample; import org.neo4j.values.storable.CoordinateReferenceSystem; import org.neo4j.values.storable.PointValue; @@ -46,11 +46,11 @@ class SpatialFusionIndexPopulator implements IndexPopulator private final long indexId; private final IndexDescriptor descriptor; private final IndexSamplingConfig samplingConfig; - private final SpatialKnownIndex.Factory indexFactory; - private final Map indexMap; + private final SpatialCRSSchemaIndex.Factory indexFactory; + private final Map indexMap; - SpatialFusionIndexPopulator( Map indexMap, long indexId, IndexDescriptor descriptor, - IndexSamplingConfig samplingConfig, SpatialKnownIndex.Factory indexFactory ) + SpatialFusionIndexPopulator( Map indexMap, long indexId, IndexDescriptor descriptor, + IndexSamplingConfig samplingConfig, SpatialCRSSchemaIndex.Factory indexFactory ) { this.indexMap = indexMap; this.indexId = indexId; @@ -73,7 +73,7 @@ public void create() throws IOException @Override public void drop() throws IOException { - forAll( SpatialKnownIndex::drop, indexMap.values() ); + forAll( SpatialCRSSchemaIndex::drop, indexMap.values() ); indexMap.clear(); } @@ -87,8 +87,8 @@ public void add( Collection> updates ) throws Inde } for ( CoordinateReferenceSystem crs : batchMap.keySet() ) { - SpatialKnownIndex index = indexFactory.selectAndCreate( indexMap, indexId, crs ); - index.startPopulation( descriptor, samplingConfig ); + SpatialCRSSchemaIndex index = indexFactory.selectAndCreate( descriptor, indexMap, indexId, crs ); + index.startPopulation( samplingConfig ); index.add( batchMap.get( crs ) ); } } @@ -131,14 +131,14 @@ public void includeSample( IndexEntryUpdate update ) Value[] values = update.values(); assert values.length == 1; CoordinateReferenceSystem crs = ((PointValue) values[0]).getCoordinateReferenceSystem(); - SpatialKnownIndex index = indexFactory.selectAndCreate( indexMap, indexId, crs ); - index.init( descriptor, samplingConfig ); + SpatialCRSSchemaIndex index = indexFactory.selectAndCreate( descriptor, indexMap, indexId, crs ); + index.init( samplingConfig ); index.includeSample( update ); } @Override public IndexSample sampleResult() { - return combineSamples( indexMap.values().stream().map( SpatialKnownIndex::sampleResult ).toArray( IndexSample[]::new ) ); + return combineSamples( indexMap.values().stream().map( SpatialCRSSchemaIndex::sampleResult ).toArray( IndexSample[]::new ) ); } } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/fusion/SpatialFusionIndexUpdater.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/fusion/SpatialFusionIndexUpdater.java index 9f9624a89dde8..d1e18d285d299 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/fusion/SpatialFusionIndexUpdater.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/fusion/SpatialFusionIndexUpdater.java @@ -28,7 +28,7 @@ import org.neo4j.kernel.api.index.IndexUpdater; import org.neo4j.kernel.api.schema.index.IndexDescriptor; import org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig; -import org.neo4j.kernel.impl.index.schema.SpatialKnownIndex; +import org.neo4j.kernel.impl.index.schema.SpatialCRSSchemaIndex; import org.neo4j.values.storable.CoordinateReferenceSystem; import org.neo4j.values.storable.PointValue; import org.neo4j.values.storable.Value; @@ -37,27 +37,27 @@ class SpatialFusionIndexUpdater implements IndexUpdater { - private final Map indexMap; + private final Map indexMap; private final Map currentUpdaters = new HashMap<>(); private final long indexId; - private final SpatialKnownIndex.Factory indexFactory; + private final SpatialCRSSchemaIndex.Factory indexFactory; private final IndexDescriptor descriptor; private final IndexSamplingConfig samplingConfig; private final boolean populating; - static SpatialFusionIndexUpdater updaterForAccessor( Map indexMap, long indexId, - SpatialKnownIndex.Factory indexFactory, IndexDescriptor descriptor, IndexSamplingConfig samplingConfig ) + static SpatialFusionIndexUpdater updaterForAccessor( Map indexMap, long indexId, + SpatialCRSSchemaIndex.Factory indexFactory, IndexDescriptor descriptor, IndexSamplingConfig samplingConfig ) { return new SpatialFusionIndexUpdater( indexMap, indexId, indexFactory, descriptor, samplingConfig, false ); } - static SpatialFusionIndexUpdater updaterForPopulator( Map indexMap, long indexId, - SpatialKnownIndex.Factory indexFactory, IndexDescriptor descriptor, IndexSamplingConfig samplingConfig ) + static SpatialFusionIndexUpdater updaterForPopulator( Map indexMap, long indexId, + SpatialCRSSchemaIndex.Factory indexFactory, IndexDescriptor descriptor, IndexSamplingConfig samplingConfig ) { return new SpatialFusionIndexUpdater( indexMap, indexId, indexFactory, descriptor, samplingConfig, true ); } - private SpatialFusionIndexUpdater( Map indexMap, long indexId, SpatialKnownIndex.Factory indexFactory, + private SpatialFusionIndexUpdater( Map indexMap, long indexId, SpatialCRSSchemaIndex.Factory indexFactory, IndexDescriptor descriptor, IndexSamplingConfig samplingConfig, boolean populating ) { this.indexMap = indexMap; @@ -112,8 +112,8 @@ private IndexUpdater selectUpdater( Value... values ) throws IOException { return updater; } - SpatialKnownIndex index = indexFactory.selectAndCreate( indexMap, indexId, crs ); - IndexUpdater indexUpdater = index.updaterWithCreate( descriptor, samplingConfig, populating ); + SpatialCRSSchemaIndex index = indexFactory.selectAndCreate( descriptor, indexMap, indexId, crs ); + IndexUpdater indexUpdater = index.updaterWithCreate( samplingConfig, populating ); return remember( crs, indexUpdater ); } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/fusion/SpatialFusionSchemaIndexProvider.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/fusion/SpatialFusionSchemaIndexProvider.java index c96bae765c0fd..0824a29ae1ca3 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/fusion/SpatialFusionSchemaIndexProvider.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/fusion/SpatialFusionSchemaIndexProvider.java @@ -38,17 +38,18 @@ import org.neo4j.kernel.api.index.SchemaIndexProvider; import org.neo4j.kernel.api.schema.index.IndexDescriptor; import org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig; -import org.neo4j.kernel.impl.index.schema.SpatialKnownIndex; +import org.neo4j.kernel.impl.index.schema.SpatialCRSSchemaIndex; import org.neo4j.kernel.impl.storemigration.StoreMigrationParticipant; import org.neo4j.values.storable.CoordinateReferenceSystem; /** * Schema index provider for native indexes backed by e.g. {@link GBPTree}. */ -public class SpatialFusionSchemaIndexProvider extends SchemaIndexProvider implements SpatialKnownIndex.Factory +public class SpatialFusionSchemaIndexProvider extends SchemaIndexProvider implements SpatialCRSSchemaIndex.Factory { public static final String KEY = "spatial"; public static final Descriptor SPATIAL_PROVIDER_DESCRIPTOR = new Descriptor( KEY, "1.0" ); + private static final Pattern CRS_DIR_PATTERN = Pattern.compile( "(\\d+)-(\\d+)" ); private final PageCache pageCache; private final FileSystemAbstraction fs; @@ -56,7 +57,7 @@ public class SpatialFusionSchemaIndexProvider extends SchemaIndexProvider implem private final RecoveryCleanupWorkCollector recoveryCleanupWorkCollector; private final boolean readOnly; - private Map> indexes = new HashMap<>(); + private Map> indexes = new HashMap<>(); public SpatialFusionSchemaIndexProvider( PageCache pageCache, FileSystemAbstraction fs, IndexDirectoryStructure.Factory directoryStructure, Monitor monitor, @@ -68,7 +69,6 @@ public SpatialFusionSchemaIndexProvider( PageCache pageCache, FileSystemAbstract this.monitor = monitor; this.recoveryCleanupWorkCollector = recoveryCleanupWorkCollector; this.readOnly = readOnly; - findAndCreateKnownSpatialIndexes(); } @Override @@ -87,7 +87,7 @@ public IndexAccessor getOnlineAccessor( long indexId, IndexDescriptor descriptor return new SpatialFusionIndexAccessor( indexesFor( indexId ), indexId, descriptor, samplingConfig, this ); } - Map indexesFor( long indexId ) + Map indexesFor( long indexId ) { return indexes.computeIfAbsent( indexId, k -> new HashMap<>() ); } @@ -99,7 +99,7 @@ public String getPopulationFailure( long indexId, IndexDescriptor descriptor ) t { // This assumes a previous call to getInitialState returned that at least one index was failed // We find the first failed index failure message - for ( SpatialKnownIndex index : indexesFor( indexId ).values() ) + for ( SpatialCRSSchemaIndex index : indexesFor( indexId ).values() ) { String indexFailure = index.readPopulationFailure( descriptor ); if ( indexFailure != null ) @@ -120,8 +120,12 @@ public InternalIndexState getInitialState( long indexId, IndexDescriptor descrip { // loop through all files, check if file exists, then check state // if any have failed, return failed, else if any are populating return populating, else online + + Map indexMap = indexesFor( indexId ); + findAndCreateSpatialIndex( indexMap, indexId, descriptor ); + InternalIndexState state = InternalIndexState.ONLINE; - for ( SpatialKnownIndex index : indexesFor( indexId ).values() ) + for ( SpatialCRSSchemaIndex index : indexMap.values() ) { try { @@ -159,10 +163,12 @@ public StoreMigrationParticipant storeMigrationParticipant( FileSystemAbstractio } @Override - public SpatialKnownIndex selectAndCreate( Map indexMap, long indexId, CoordinateReferenceSystem crs ) + public SpatialCRSSchemaIndex selectAndCreate( IndexDescriptor descriptor, + Map indexMap, long indexId, CoordinateReferenceSystem crs ) { return indexMap.computeIfAbsent( crs, - crsKey -> new SpatialKnownIndex( directoryStructure(), crsKey, indexId, pageCache, fs, monitor, recoveryCleanupWorkCollector ) ); + crsKey -> new SpatialCRSSchemaIndex( descriptor, directoryStructure(), crsKey, indexId, pageCache, fs, monitor, + recoveryCleanupWorkCollector ) ); } /** @@ -170,39 +176,26 @@ public SpatialKnownIndex selectAndCreate( Map indexMap, long indexId, IndexDescriptor descriptor ) { - Pattern pattern = Pattern.compile( "(\\d+)-(\\d+)" ); - File rootDirectory = this.directoryStructure().rootDirectory(); - if ( rootDirectory == null ) - { - return; - } - File[] files = rootDirectory.listFiles(); - if ( files != null ) + File directoryForIndex = this.directoryStructure().directoryForIndex( indexId ); + if ( directoryForIndex != null ) { - for ( File file : files ) + File[] crsDirs = directoryForIndex.listFiles(); + if ( crsDirs != null ) { - if ( file.isDirectory() ) + for ( File crsDir : crsDirs ) { - Integer indexId = Integer.valueOf( file.getName() ); - File[] subdirs = this.directoryStructure().directoryForIndex( indexId ).listFiles(); - if ( subdirs != null ) + Matcher m = CRS_DIR_PATTERN.matcher( crsDir.getName() ); + if ( m.matches() ) { - for ( File subdir : subdirs ) + int tableId = Integer.parseInt( m.group( 1 ) ); + int code = Integer.parseInt( m.group( 2 ) ); + CoordinateReferenceSystem crs = CoordinateReferenceSystem.get( tableId, code ); + SpatialCRSSchemaIndex index = selectAndCreate( descriptor, indexMap, indexId, crs ); + if ( !index.indexExists() ) { - Matcher m = pattern.matcher( subdir.getName() ); - if ( m.matches() ) - { - int tableId = Integer.parseInt( m.group( 1 ) ); - int code = Integer.parseInt( m.group( 2 ) ); - CoordinateReferenceSystem crs = CoordinateReferenceSystem.get( tableId, code ); - SpatialKnownIndex index = selectAndCreate( indexesFor( indexId ), indexId, crs ); - if ( !index.indexExists() ) - { - index.markAsFailed( "Index file was not found" ); - } - } + index.markAsFailed( "Index file was not found" ); } } } diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/SpatialKnownIndexTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/SpatialKnownIndexTest.java index bb72840288f7a..cd3ea50f7bcd5 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/SpatialKnownIndexTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/SpatialKnownIndexTest.java @@ -63,7 +63,7 @@ public class SpatialKnownIndexTest @Rule public final RuleChain rules = outerRule( fsRule ).around( directory ).around( pageCacheRule ).around( random ); - private SpatialKnownIndex index; + private SpatialCRSSchemaIndex index; private IndexDescriptor descriptor; private IndexSamplingConfig samplingConfig; private FileSystemAbstraction fs; @@ -82,9 +82,9 @@ public void setup() throws IOException String crsDir = String.format("%s-%s", crs.getTable().getTableId(), crs.getCode() ); indexDir = new File( new File( new File( new File( new File( storeDir, "schema" ), "index" ), "spatial-1.0" ), "1" ), crsDir ); IndexDirectoryStructure dirStructure = IndexDirectoryStructure.directoriesByProvider( storeDir ).forProvider( SPATIAL_PROVIDER_DESCRIPTOR ); - index = new SpatialKnownIndex( dirStructure, crs, 1L, pageCacheRule.getPageCache( fs ), fs, - SchemaIndexProvider.Monitor.EMPTY, RecoveryCleanupWorkCollector.IMMEDIATE ); descriptor = IndexDescriptorFactory.forLabel( 42, 1337 ); + index = new SpatialCRSSchemaIndex( descriptor, dirStructure, crs, 1L, pageCacheRule.getPageCache( fs ), fs, + SchemaIndexProvider.Monitor.EMPTY, RecoveryCleanupWorkCollector.IMMEDIATE ); samplingConfig = mock( IndexSamplingConfig.class ); } @@ -95,7 +95,7 @@ public void shouldNotCreateFileOnInit() assertThat( fs.listFiles( storeDir ).length, equalTo( 0 ) ); // when - index.init( descriptor, samplingConfig ); + index.init( samplingConfig ); // then assertThat( fs.listFiles( storeDir ).length, equalTo( 0 ) ); @@ -108,7 +108,7 @@ public void shouldCreateFileOnCreate() throws IOException assertThat( fs.listFiles( storeDir ).length, equalTo( 0 ) ); // when - index.startPopulation( descriptor, samplingConfig ); + index.startPopulation( samplingConfig ); // then assertThat( fs.listFiles( indexDir ).length, equalTo( 1 ) ); @@ -123,7 +123,7 @@ public void shouldNotTakeOnlineIfIndexNotCreated() throws IOException try { // when - index.takeOnline( descriptor, samplingConfig ); + index.takeOnline( samplingConfig ); fail("should have thrown exception"); } catch ( IOException e ) @@ -139,12 +139,12 @@ public void shouldNotTakeOnlineIfPopulating() throws IOException { // given assertThat( fs.listFiles( storeDir ).length, equalTo( 0 ) ); - index.startPopulation( descriptor, samplingConfig ); + index.startPopulation( samplingConfig ); // when try { - index.takeOnline( descriptor, samplingConfig ); + index.takeOnline( samplingConfig ); fail( "Should have thrown exception." ); } catch ( IllegalStateException e ) @@ -160,11 +160,11 @@ public void shouldTakeOnlineIfDonePopulating() throws IOException { // given assertThat( fs.listFiles( storeDir ).length, equalTo( 0 ) ); - index.startPopulation( descriptor, samplingConfig ); + index.startPopulation( samplingConfig ); index.finishPopulation( true ); // when - index.takeOnline( descriptor, samplingConfig ); + index.takeOnline( samplingConfig ); index.close(); } @@ -174,7 +174,7 @@ public void shouldGetUpdaterWhenOnline() throws IOException, IndexEntryConflictE assertThat( fs.listFiles( storeDir ).length, equalTo( 0 ) ); // when - IndexUpdater updater = index.updaterWithCreate( descriptor, samplingConfig, false ); + IndexUpdater updater = index.updaterWithCreate( samplingConfig, false ); // then assertThat( fs.listFiles( indexDir ).length, equalTo( 1 ) ); @@ -189,7 +189,7 @@ public void shouldGetUpdaterWhenPopulating() throws IOException, IndexEntryConfl assertThat( fs.listFiles( storeDir ).length, equalTo( 0 ) ); // when - IndexUpdater updater = index.updaterWithCreate( descriptor, samplingConfig, true ); + IndexUpdater updater = index.updaterWithCreate( samplingConfig, true ); // then assertThat( fs.listFiles( indexDir ).length, equalTo( 1 ) ); @@ -203,7 +203,7 @@ public void drop() throws IOException { // given assertThat( fs.listFiles( storeDir ).length, equalTo( 0 ) ); - index.startPopulation( descriptor, samplingConfig ); + index.startPopulation( samplingConfig ); assertThat( fs.listFiles( indexDir ).length, equalTo( 1 ) ); // when diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/fusion/SpatialFusionIndexAccessorTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/fusion/SpatialFusionIndexAccessorTest.java index de654c5c30017..99a380bc76aed 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/fusion/SpatialFusionIndexAccessorTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/fusion/SpatialFusionIndexAccessorTest.java @@ -35,7 +35,7 @@ import org.neo4j.helpers.collection.BoundedIterable; import org.neo4j.helpers.collection.Iterables; import org.neo4j.kernel.api.schema.index.IndexDescriptor; -import org.neo4j.kernel.impl.index.schema.SpatialKnownIndex; +import org.neo4j.kernel.impl.index.schema.SpatialCRSSchemaIndex; import org.neo4j.values.storable.CoordinateReferenceSystem; import static java.util.Arrays.asList; @@ -63,16 +63,16 @@ public class SpatialFusionIndexAccessorTest { private SpatialFusionIndexAccessor fusionIndexAccessor; - private Map indexMap = new HashMap<>(); + private Map indexMap = new HashMap<>(); @Before public void setup() throws Exception { - SpatialKnownIndex.Factory indexFactory = mock( SpatialKnownIndex.Factory.class ); + SpatialCRSSchemaIndex.Factory indexFactory = mock( SpatialCRSSchemaIndex.Factory.class ); for ( CoordinateReferenceSystem crs : asList( WGS84, Cartesian ) ) { - indexMap.put( crs, mock( SpatialKnownIndex.class ) ); + indexMap.put( crs, mock( SpatialCRSSchemaIndex.class ) ); } fusionIndexAccessor = new SpatialFusionIndexAccessor( indexMap, 0, mock( IndexDescriptor.class ), null, indexFactory ); @@ -83,7 +83,7 @@ public void dropMustDropAll() throws Exception { fusionIndexAccessor.drop(); - for ( SpatialKnownIndex spatialKnownIndex : indexMap.values() ) + for ( SpatialCRSSchemaIndex spatialKnownIndex : indexMap.values() ) { verify( spatialKnownIndex, times( 1 ) ).drop(); } @@ -126,7 +126,7 @@ public void clostMustCloseAll() throws Exception { fusionIndexAccessor.close(); - for ( SpatialKnownIndex spatialKnownIndex : indexMap.values() ) + for ( SpatialCRSSchemaIndex spatialKnownIndex : indexMap.values() ) { verify( spatialKnownIndex, times( 1 ) ).close(); } @@ -135,7 +135,7 @@ public void clostMustCloseAll() throws Exception @Test public void closeMustCloseOthersIfCloseOneFail() throws Exception { - for ( SpatialKnownIndex failingIndex : indexMap.values() ) + for ( SpatialCRSSchemaIndex failingIndex : indexMap.values() ) { IOException failure = new IOException( "fail" ); doThrow( failure ).when( failingIndex ).close(); @@ -151,7 +151,7 @@ public void closeMustCloseOthersIfCloseOneFail() throws Exception } // then - for ( SpatialKnownIndex successfulIndex : indexMap.values() ) + for ( SpatialCRSSchemaIndex successfulIndex : indexMap.values() ) { if ( failingIndex != successfulIndex ) { @@ -165,7 +165,7 @@ public void closeMustCloseOthersIfCloseOneFail() throws Exception @Test public void closeMustThrowIfCloseOneFail() throws Exception { - for ( SpatialKnownIndex index : indexMap.values() ) + for ( SpatialCRSSchemaIndex index : indexMap.values() ) { IOException expectedFailure = new IOException( "fail" ); doThrow( expectedFailure ).when( index ).close(); @@ -187,7 +187,7 @@ public void closeMustThrowIfAllFail() throws Exception { // given List failures = new ArrayList<>(); - for ( SpatialKnownIndex index : indexMap.values() ) + for ( SpatialCRSSchemaIndex index : indexMap.values() ) { IOException exception = new IOException( "unknown" ); failures.add( exception ); @@ -354,7 +354,7 @@ public void allEntriesReaderMustReportFusionMacCountOfAll() assertThat( fusionAllEntriesReader.maxCount(), is( 9L ) ); } - private void verifyFailOnSingleDropFailure( SpatialKnownIndex spatialKnownIndex ) throws IOException + private void verifyFailOnSingleDropFailure( SpatialCRSSchemaIndex spatialKnownIndex ) throws IOException { IOException expectedFailure = new IOException( "fail" ); doThrow( expectedFailure ).when( spatialKnownIndex ).drop(); @@ -369,14 +369,14 @@ private void verifyFailOnSingleDropFailure( SpatialKnownIndex spatialKnownIndex } } - private BoundedIterable mockSingleAllEntriesReader( SpatialKnownIndex spatialKnownIndex, long[] entries ) + private BoundedIterable mockSingleAllEntriesReader( SpatialCRSSchemaIndex spatialKnownIndex, long[] entries ) { BoundedIterable allEntriesReader = mockedAllEntriesReader( entries ); when( spatialKnownIndex.newAllEntriesReader() ).thenReturn( allEntriesReader ); return allEntriesReader; } - private void mockSingleAllEntriesReaderWithUnknownMaxCount( SpatialKnownIndex spatialKnownIndex, long[] entries ) + private void mockSingleAllEntriesReaderWithUnknownMaxCount( SpatialCRSSchemaIndex spatialKnownIndex, long[] entries ) { BoundedIterable allEntriesReader = mockedAllEntriesReaderUnknownMaxCount( entries ); when( spatialKnownIndex.newAllEntriesReader() ).thenReturn( allEntriesReader ); diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/fusion/SpatialFusionIndexPopulatorTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/fusion/SpatialFusionIndexPopulatorTest.java index 1f89467bae069..ec51335cad34b 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/fusion/SpatialFusionIndexPopulatorTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/fusion/SpatialFusionIndexPopulatorTest.java @@ -32,7 +32,7 @@ import org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException; import org.neo4j.kernel.api.index.IndexEntryUpdate; import org.neo4j.kernel.api.schema.index.IndexDescriptor; -import org.neo4j.kernel.impl.index.schema.SpatialKnownIndex; +import org.neo4j.kernel.impl.index.schema.SpatialCRSSchemaIndex; import org.neo4j.values.storable.CoordinateReferenceSystem; import org.neo4j.values.storable.PointValue; import org.neo4j.values.storable.Value; @@ -56,19 +56,19 @@ public class SpatialFusionIndexPopulatorTest { private SpatialFusionIndexPopulator fusionIndexPopulator; - private Map indexMap = new HashMap<>(); + private Map indexMap = new HashMap<>(); @Before public void setup() throws Exception { - SpatialKnownIndex.Factory indexFactory = mock( SpatialKnownIndex.Factory.class ); + SpatialCRSSchemaIndex.Factory indexFactory = mock( SpatialCRSSchemaIndex.Factory.class ); IndexDescriptor descriptor = mock( IndexDescriptor.class ); for ( CoordinateReferenceSystem crs : asList( CoordinateReferenceSystem.WGS84, CoordinateReferenceSystem.Cartesian ) ) { - indexMap.put( crs, mock( SpatialKnownIndex.class ) ); + indexMap.put( crs, mock( SpatialCRSSchemaIndex.class ) ); - when( indexFactory.selectAndCreate( indexMap, 0, crs ) ).thenReturn( indexMap.get( crs ) ); + when( indexFactory.selectAndCreate( descriptor, indexMap, 0, crs ) ).thenReturn( indexMap.get( crs ) ); } fusionIndexPopulator = new SpatialFusionIndexPopulator( indexMap, 0, descriptor, null, indexFactory ); @@ -81,7 +81,7 @@ public void dropMustDropAll() throws Exception fusionIndexPopulator.drop(); // then - for ( SpatialKnownIndex spatialKnownIndex : indexMap.values() ) + for ( SpatialCRSSchemaIndex spatialKnownIndex : indexMap.values() ) { verify( spatialKnownIndex, times( 1 ) ).drop(); } @@ -196,7 +196,7 @@ public void markAsFailedMustMarkAll() throws Exception fusionIndexPopulator.markAsFailed( failureMessage ); // then - for ( SpatialKnownIndex spatialKnownIndex : indexMap.values() ) + for ( SpatialCRSSchemaIndex spatialKnownIndex : indexMap.values() ) { verify( spatialKnownIndex, times( 1 ) ).markAsFailed( failureMessage ); } @@ -214,7 +214,7 @@ public void shouldIncludeSampleOnCorrectPopulator() throws Exception fusionIndexPopulator.includeSample( update ); // then - SpatialKnownIndex spatialKnownIndex = indexMap.get( point.getCoordinateReferenceSystem() ); + SpatialCRSSchemaIndex spatialKnownIndex = indexMap.get( point.getCoordinateReferenceSystem() ); verify( spatialKnownIndex ).includeSample( update ); reset( spatialKnownIndex ); } @@ -225,18 +225,19 @@ private void closeAndVerifyPropagation( boolean populationCompletedSuccessfully fusionIndexPopulator.close( populationCompletedSuccessfully ); // then - for ( SpatialKnownIndex index : indexMap.values() ) + for ( SpatialCRSSchemaIndex index : indexMap.values() ) { verify( index, times( 1 ) ).finishPopulation( populationCompletedSuccessfully ); } } - private void verifyAddWithCorrectSpatialIndex( SpatialKnownIndex correctSpatialIndex, Value numberValues ) throws IndexEntryConflictException, IOException + private void verifyAddWithCorrectSpatialIndex( SpatialCRSSchemaIndex correctSpatialIndex, Value numberValues ) + throws IndexEntryConflictException, IOException { Collection> update = Collections.singletonList( add( numberValues ) ); fusionIndexPopulator.add( update ); verify( correctSpatialIndex, times( 1 ) ).add( update ); - for ( SpatialKnownIndex spatialKnownIndex : indexMap.values() ) + for ( SpatialCRSSchemaIndex spatialKnownIndex : indexMap.values() ) { if ( spatialKnownIndex != correctSpatialIndex ) { diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/fusion/SpatialFusionIndexUpdaterTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/fusion/SpatialFusionIndexUpdaterTest.java index 26ef538165385..f110da4f15a32 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/fusion/SpatialFusionIndexUpdaterTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/fusion/SpatialFusionIndexUpdaterTest.java @@ -32,7 +32,7 @@ import org.neo4j.kernel.api.index.IndexUpdater; import org.neo4j.kernel.api.schema.index.IndexDescriptor; import org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig; -import org.neo4j.kernel.impl.index.schema.SpatialKnownIndex; +import org.neo4j.kernel.impl.index.schema.SpatialCRSSchemaIndex; import org.neo4j.values.storable.CoordinateReferenceSystem; import org.neo4j.values.storable.PointValue; import org.neo4j.values.storable.Value; @@ -51,24 +51,24 @@ public class SpatialFusionIndexUpdaterTest { private Map updaterMap = new HashMap<>(); - private Map indexMap = new HashMap<>(); + private Map indexMap = new HashMap<>(); private SpatialFusionIndexUpdater fusionIndexAccessorUpdater; private SpatialFusionIndexUpdater fusionIndexPopulatorUpdater; @Before public void setup() throws Exception { - SpatialKnownIndex.Factory indexFactory = mock( SpatialKnownIndex.Factory.class ); + SpatialCRSSchemaIndex.Factory indexFactory = mock( SpatialCRSSchemaIndex.Factory.class ); IndexDescriptor descriptor = mock( IndexDescriptor.class ); IndexSamplingConfig samplingConfig = mock( IndexSamplingConfig.class ); for ( CoordinateReferenceSystem crs : asList( CoordinateReferenceSystem.WGS84, CoordinateReferenceSystem.Cartesian ) ) { updaterMap.put( crs, mock( IndexUpdater.class ) ); - indexMap.put( crs, mock( SpatialKnownIndex.class ) ); - when( indexFactory.selectAndCreate( indexMap, 0, crs ) ).thenReturn( indexMap.get( crs ) ); - when( indexMap.get( crs ).updaterWithCreate( descriptor, samplingConfig, true ) ).thenReturn( updaterMap.get( crs ) ); - when( indexMap.get( crs ).updaterWithCreate( descriptor, samplingConfig, false ) ).thenReturn( updaterMap.get( crs ) ); + indexMap.put( crs, mock( SpatialCRSSchemaIndex.class ) ); + when( indexFactory.selectAndCreate( descriptor, indexMap, 0, crs ) ).thenReturn( indexMap.get( crs ) ); + when( indexMap.get( crs ).updaterWithCreate( samplingConfig, true ) ).thenReturn( updaterMap.get( crs ) ); + when( indexMap.get( crs ).updaterWithCreate( samplingConfig, false ) ).thenReturn( updaterMap.get( crs ) ); } fusionIndexAccessorUpdater = SpatialFusionIndexUpdater.updaterForAccessor( diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/fusion/SpatialFusionSchemaIndexProviderTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/fusion/SpatialFusionSchemaIndexProviderTest.java index 98db2618ef994..a0db8eabacf8d 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/fusion/SpatialFusionSchemaIndexProviderTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/fusion/SpatialFusionSchemaIndexProviderTest.java @@ -32,7 +32,7 @@ import org.neo4j.kernel.api.index.SchemaIndexProvider; import org.neo4j.kernel.api.schema.index.IndexDescriptor; import org.neo4j.kernel.api.schema.index.IndexDescriptorFactory; -import org.neo4j.kernel.impl.index.schema.SpatialKnownIndex; +import org.neo4j.kernel.impl.index.schema.SpatialCRSSchemaIndex; import org.neo4j.test.rule.RandomRule; import org.neo4j.values.storable.CoordinateReferenceSystem; import org.neo4j.values.storable.PointValue; @@ -51,7 +51,7 @@ public class SpatialFusionSchemaIndexProviderTest @Rule public RandomRule random = new RandomRule(); - private Map indexMap; + private Map indexMap; private SpatialFusionSchemaIndexProvider provider; private IndexDescriptor descriptor = IndexDescriptorFactory.forLabel( 1, 1 ); @@ -66,8 +66,8 @@ public void setup() null, false ); indexMap = provider.indexesFor( 0 ); - indexMap.put( CoordinateReferenceSystem.WGS84, mock( SpatialKnownIndex.class ) ); - indexMap.put( CoordinateReferenceSystem.Cartesian, mock( SpatialKnownIndex.class ) ); + indexMap.put( CoordinateReferenceSystem.WGS84, mock( SpatialCRSSchemaIndex.class ) ); + indexMap.put( CoordinateReferenceSystem.Cartesian, mock( SpatialCRSSchemaIndex.class ) ); } @Test @@ -76,12 +76,12 @@ public void shouldReportPopulatingIfAnyIsPopulating() throws Exception for ( InternalIndexState state : array( InternalIndexState.ONLINE, InternalIndexState.POPULATING ) ) { // when - for ( SpatialKnownIndex index : indexMap.values() ) + for ( SpatialCRSSchemaIndex index : indexMap.values() ) { setInitialState( index, state ); } - for ( SpatialKnownIndex index : indexMap.values() ) + for ( SpatialCRSSchemaIndex index : indexMap.values() ) { setInitialState( index, InternalIndexState.POPULATING ); // then @@ -96,7 +96,7 @@ public void getPopulationFailureMustThrowIfNoFailure() throws Exception { // when // ... no failure - for ( SpatialKnownIndex index : indexMap.values() ) + for ( SpatialCRSSchemaIndex index : indexMap.values() ) { when( index.readPopulationFailure( descriptor ) ).thenReturn( null ); } @@ -118,14 +118,14 @@ public void mustSelectCorrectTargetForValues() throws Exception { PointValue point = (PointValue) spatialValue; CoordinateReferenceSystem crs = point.getCoordinateReferenceSystem(); - SpatialKnownIndex index = provider.selectAndCreate( indexMap, 0, point.getCoordinateReferenceSystem() ); + SpatialCRSSchemaIndex index = provider.selectAndCreate( descriptor, indexMap, 0, point.getCoordinateReferenceSystem() ); assertSame( indexMap.get( crs ), index ); - index = provider.selectAndCreate( indexMap, 0, crs ); + index = provider.selectAndCreate( descriptor, indexMap, 0, crs ); assertSame( indexMap.get( crs ), index ); } } - private void setInitialState( SpatialKnownIndex mockedIndex, InternalIndexState state ) throws IOException + private void setInitialState( SpatialCRSSchemaIndex mockedIndex, InternalIndexState state ) throws IOException { when( mockedIndex.indexExists() ).thenReturn( true ); when( mockedIndex.readState( descriptor ) ).thenReturn( state );