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/SpatialKnownIndex.java index ecaa7cf09c53..36965b5f1be1 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/SpatialKnownIndex.java @@ -54,7 +54,6 @@ import org.neo4j.storageengine.api.schema.IndexReader; import org.neo4j.storageengine.api.schema.IndexSample; import org.neo4j.values.storable.CoordinateReferenceSystem; -import org.neo4j.values.storable.Value; import static org.neo4j.helpers.collection.Iterators.asResourceIterator; import static org.neo4j.helpers.collection.Iterators.iterator; @@ -116,7 +115,10 @@ public SpatialKnownIndex( IndexDirectoryStructure directoryStructure, Coordinate state = State.NONE; } - public void initIfNeeded( IndexDescriptor descriptor, IndexSamplingConfig samplingConfig ) + /** + * Makes sure that the index is initialized + */ + public void init( IndexDescriptor descriptor, IndexSamplingConfig samplingConfig ) { if ( state == State.NONE ) { @@ -124,18 +126,29 @@ public void initIfNeeded( IndexDescriptor descriptor, IndexSamplingConfig sampli } } - public void createIfNeeded() throws IOException + /** + * Makes sure that the index is ready to populate + */ + public void startPopulation( IndexDescriptor descriptor, IndexSamplingConfig samplingConfig ) throws IOException { + init( descriptor, samplingConfig ); if ( state == State.INIT ) { // First add to sub-index, make sure to create create(); } + if ( state != State.POPULATING ) + { + throw new IllegalStateException( "Failed to start populating index." ); + } } + /** + * Makes sure that the index is online + */ public void takeOnline( IndexDescriptor descriptor, IndexSamplingConfig samplingConfig ) throws IOException { - initIfNeeded( descriptor, samplingConfig ); + init( descriptor, samplingConfig ); if ( !indexExists() ) { throw new IOException( "Index file does not exist." ); @@ -169,7 +182,7 @@ public IndexUpdater updaterWithCreate( IndexDescriptor descriptor, IndexSampling // sub-index didn't exist, create and make it online initialize( descriptor, samplingConfig ); create(); - close( true ); + finishPopulation( true ); online(); } return newUpdater(); @@ -220,7 +233,7 @@ private IndexUpdater newUpdater() // POPULATING - public synchronized void close( boolean populationCompletedSuccessfully ) throws IOException + public synchronized void finishPopulation( boolean populationCompletedSuccessfully ) throws IOException { assert state == State.POPULATING; closeWriter(); @@ -233,7 +246,7 @@ public synchronized void close( boolean populationCompletedSuccessfully ) throws { if ( populationCompletedSuccessfully ) { - assertPopulatorOpen(); + schemaIndex.assertOpen(); markTreeAsOnline(); state = State.POPULATED; } @@ -449,14 +462,6 @@ private void applyWithWorkSync( Collection> update } } - private void assertPopulatorOpen() - { - if ( schemaIndex.tree == null ) - { - throw new IllegalStateException( "Populator has already been closed." ); - } - } - private void closeWriter() throws IOException { singleTreeWriter = schemaIndex.closeIfPresent( singleTreeWriter ); @@ -531,8 +536,6 @@ private enum State public interface Factory { - SpatialKnownIndex selectAndCreate( Map indexMap, long indexId, Value value ); - SpatialKnownIndex selectAndCreate( Map indexMap, long indexId, CoordinateReferenceSystem crs ); } 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 c8bd4c3962b3..e8d61b7233d6 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 @@ -87,8 +87,8 @@ public void add( Collection> updates ) throws Inde } for ( CoordinateReferenceSystem crs : batchMap.keySet() ) { - SpatialKnownIndex index = getOrCreateInitializedIndex( crs ); - index.createIfNeeded(); + SpatialKnownIndex index = indexFactory.selectAndCreate( indexMap, indexId, crs ); + index.startPopulation( descriptor, samplingConfig ); index.add( batchMap.get( crs ) ); } } @@ -116,7 +116,7 @@ public IndexUpdater newPopulatingUpdater( PropertyAccessor accessor ) @Override public void close( boolean populationCompletedSuccessfully ) throws IOException { - forAll( entry -> ((SpatialKnownIndex) entry).close( populationCompletedSuccessfully ), indexMap.values().toArray() ); + forAll( entry -> ((SpatialKnownIndex) entry).finishPopulation( populationCompletedSuccessfully ), indexMap.values().toArray() ); } @Override @@ -131,15 +131,9 @@ public void includeSample( IndexEntryUpdate update ) Value[] values = update.values(); assert values.length == 1; CoordinateReferenceSystem crs = ((PointValue) values[0]).getCoordinateReferenceSystem(); - SpatialKnownIndex index = getOrCreateInitializedIndex( crs ); - index.includeSample( update ); - } - - private SpatialKnownIndex getOrCreateInitializedIndex( CoordinateReferenceSystem crs ) - { SpatialKnownIndex index = indexFactory.selectAndCreate( indexMap, indexId, crs ); - index.initIfNeeded( descriptor, samplingConfig ); - return index; + index.init( descriptor, samplingConfig ); + index.includeSample( update ); } @Override 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 faccf0557dc4..35655c084b29 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 @@ -123,31 +123,24 @@ 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 InternalIndexState state = InternalIndexState.ONLINE; - if ( !indexes.containsKey( indexId ) ) + for ( SpatialKnownIndex index : indexesFor( indexId ).values() ) { - return InternalIndexState.ONLINE; - } - for ( SpatialKnownIndex index : indexes.get( indexId ).values() ) - { - if ( index.indexExists() ) + try { - try - { - switch ( index.readState( descriptor ) ) - { - case FAILED: - return InternalIndexState.FAILED; - case POPULATING: - state = InternalIndexState.POPULATING; - default: - } - } - catch ( IOException e ) + switch ( index.readState( descriptor ) ) { - monitor.failedToOpenIndex( indexId, descriptor, "Requesting re-population.", e ); + case FAILED: + return InternalIndexState.FAILED; + case POPULATING: state = InternalIndexState.POPULATING; + default: } } + catch ( IOException e ) + { + monitor.failedToOpenIndex( indexId, descriptor, "Requesting re-population.", e ); + state = InternalIndexState.POPULATING; + } } return state; } @@ -167,19 +160,11 @@ public StoreMigrationParticipant storeMigrationParticipant( FileSystemAbstractio return StoreMigrationParticipant.NOT_PARTICIPATING; } - @Override - public SpatialKnownIndex selectAndCreate( Map indexMap, long indexId, Value value ) - { - PointValue pointValue = (PointValue) value; - CoordinateReferenceSystem crs = pointValue.getCoordinateReferenceSystem(); - return selectAndCreate( indexMap, indexId, crs ); - } - @Override public SpatialKnownIndex selectAndCreate( Map indexMap, long indexId, CoordinateReferenceSystem crs ) { return indexMap.computeIfAbsent( crs, - k -> new SpatialKnownIndex( directoryStructure(), crs, indexId, pageCache, fs, monitor, recoveryCleanupWorkCollector ) ); + crsKey -> new SpatialKnownIndex( directoryStructure(), crsKey, indexId, pageCache, fs, monitor, recoveryCleanupWorkCollector ) ); } /** diff --git a/community/kernel/src/test/java/org/neo4j/graphdb/IndexingAcceptanceTest.java b/community/kernel/src/test/java/org/neo4j/graphdb/IndexingAcceptanceTest.java index 8d270cfe2b8f..f4958a269e9d 100644 --- a/community/kernel/src/test/java/org/neo4j/graphdb/IndexingAcceptanceTest.java +++ b/community/kernel/src/test/java/org/neo4j/graphdb/IndexingAcceptanceTest.java @@ -359,8 +359,8 @@ public void shouldBeAbleToQuerySupportedPropertyTypes() assertCanCreateAndFind( db, LABEL1, property, 12L ); assertCanCreateAndFind( db, LABEL1, property, (float)12. ); assertCanCreateAndFind( db, LABEL1, property, 12. ); - assertCanCreateAndFind( db, LABEL1, property, new SpatialMocks.MockPoint( 12.3, 45.6, mockWGS84() ) ); - assertCanCreateAndFind( db, LABEL1, property, new SpatialMocks.MockPoint( 123, 456, mockCartesian() ) ); + assertCanCreateAndFind( db, LABEL1, property, SpatialMocks.mockPoint( 12.3, 45.6, mockWGS84() ) ); + assertCanCreateAndFind( db, LABEL1, property, SpatialMocks.mockPoint( 123, 456, mockCartesian() ) ); assertCanCreateAndFind( db, LABEL1, property, Values.pointValue( CoordinateReferenceSystem.WGS84, 12.3, 45.6 ) ); assertCanCreateAndFind( db, LABEL1, property, Values.pointValue( CoordinateReferenceSystem.Cartesian, 123, 456 ) ); @@ -381,8 +381,8 @@ public void shouldBeAbleToQuerySupportedPropertyTypes() assertCanCreateAndFind( db, LABEL1, property, new Float[]{(float)19.} ); assertCanCreateAndFind( db, LABEL1, property, new double[]{20.} ); assertCanCreateAndFind( db, LABEL1, property, new Double[]{21.} ); - assertCanCreateAndFind( db, LABEL1, property, new Point[]{new SpatialMocks.MockPoint( 12.3, 45.6, mockWGS84() )} ); - assertCanCreateAndFind( db, LABEL1, property, new Point[]{new SpatialMocks.MockPoint( 123, 456, mockCartesian() )} ); + assertCanCreateAndFind( db, LABEL1, property, new Point[]{SpatialMocks.mockPoint( 12.3, 45.6, mockWGS84() )} ); + assertCanCreateAndFind( db, LABEL1, property, new Point[]{SpatialMocks.mockPoint( 123, 456, mockCartesian() )} ); assertCanCreateAndFind( db, LABEL1, property, new PointValue[]{Values.pointValue( CoordinateReferenceSystem.WGS84, 12.3, 45.6 )} ); assertCanCreateAndFind( db, LABEL1, property, new PointValue[]{Values.pointValue( CoordinateReferenceSystem.Cartesian, 123, 456 )} ); } diff --git a/community/kernel/src/test/java/org/neo4j/graphdb/SpatialMocks.java b/community/kernel/src/test/java/org/neo4j/graphdb/SpatialMocks.java index 4fc4c41399a7..7b81d937e270 100644 --- a/community/kernel/src/test/java/org/neo4j/graphdb/SpatialMocks.java +++ b/community/kernel/src/test/java/org/neo4j/graphdb/SpatialMocks.java @@ -29,6 +29,15 @@ public class SpatialMocks { + public static MockPoint mockPoint( double x, double y, CRS crs ) + { + return new MockPoint( x, y, crs ); + } + + public static MockGeometry mockGeometry( String geometryType, List coordinates, CRS crs ) + { + return new MockGeometry( geometryType, coordinates, crs ); + } public static CRS mockWGS84() { @@ -40,7 +49,7 @@ public static CRS mockCartesian() return mockCRS( 7203, "cartesian", "http://spatialreference.org/ref/sr-org/7203/" ); } - public static CRS mockCRS( final int code, final String type, final String href ) + private static CRS mockCRS( final int code, final String type, final String href ) { return new CRS() { @@ -61,11 +70,11 @@ public String getHref() }; } - public static class MockPoint extends MockGeometry implements Point + private static class MockPoint extends MockGeometry implements Point { private final Coordinate coordinate; - public MockPoint( final double x, final double y, final CRS crs ) + private MockPoint( final double x, final double y, final CRS crs ) { super( "Point", new ArrayList<>(), crs ); this.coordinate = new Coordinate( x, y ); @@ -73,13 +82,13 @@ public MockPoint( final double x, final double y, final CRS crs ) } } - public static class MockGeometry implements Geometry + private static class MockGeometry implements Geometry { - protected final String geometryType; + final String geometryType; + final List coordinates; protected final CRS crs; - protected final List coordinates; - public MockGeometry( String geometryType, final List coordinates, final CRS crs ) + private MockGeometry( String geometryType, final List coordinates, final CRS crs ) { this.geometryType = geometryType; this.coordinates = coordinates; diff --git a/community/kernel/src/test/java/org/neo4j/kernel/api/index/NodeUpdatesTest.java b/community/kernel/src/test/java/org/neo4j/kernel/api/index/NodeUpdatesTest.java index d7d9b4d44e5a..9c44fa742f29 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/api/index/NodeUpdatesTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/api/index/NodeUpdatesTest.java @@ -83,7 +83,7 @@ public void shouldNotGenerateUpdateForMultipleExistingPropertiesAndLabels() NodeUpdates updates = NodeUpdates.forNode( nodeId, labels ) .existing( propertyKeyId1, Values.of( "Neo" ) ) .existing( propertyKeyId2, Values.of( 100L ) ) - .existing( propertyKeyId3, Values.of( Values.pointValue( CoordinateReferenceSystem.WGS84, 12.3, 45.6 ) ) ) + .existing( propertyKeyId3, Values.pointValue( CoordinateReferenceSystem.WGS84, 12.3, 45.6 ) ) .build(); // Then @@ -122,7 +122,7 @@ public void shouldGenerateUpdatesForLabelAdditionWithExistingProperties() NodeUpdates.forNode( nodeId, empty, labels ) .existing( propertyKeyId1, Values.of( "Neo" ) ) .existing( propertyKeyId2, Values.of( 100L ) ) - .existing( propertyKeyId3, Values.of( Values.pointValue( CoordinateReferenceSystem.WGS84, 12.3, 45.6 ) ) ) + .existing( propertyKeyId3, Values.pointValue( CoordinateReferenceSystem.WGS84, 12.3, 45.6 ) ) .build(); // Then diff --git a/community/kernel/src/test/java/org/neo4j/kernel/api/index/SimpleIndexAccessorCompatibility.java b/community/kernel/src/test/java/org/neo4j/kernel/api/index/SimpleIndexAccessorCompatibility.java index 75210ad21877..22d007b7f075 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/api/index/SimpleIndexAccessorCompatibility.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/api/index/SimpleIndexAccessorCompatibility.java @@ -27,9 +27,6 @@ import org.neo4j.internal.kernel.api.IndexQuery; import org.neo4j.kernel.api.schema.index.IndexDescriptor; import org.neo4j.kernel.api.schema.index.IndexDescriptorFactory; -import org.neo4j.values.storable.CoordinateReferenceSystem; -import org.neo4j.values.storable.PointValue; -import org.neo4j.values.storable.Values; import static java.util.Arrays.asList; import static java.util.Collections.EMPTY_LIST; 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 5ebf965c1c73..0ab89549055f 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 @@ -26,6 +26,7 @@ import java.io.File; import java.io.IOException; +import java.nio.file.NoSuchFileException; import org.neo4j.index.internal.gbptree.RecoveryCleanupWorkCollector; import org.neo4j.io.fs.FileSystemAbstraction; @@ -46,6 +47,7 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; +import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.junit.rules.RuleChain.outerRule; import static org.mockito.Mockito.mock; @@ -75,13 +77,15 @@ public void setup() throws IOException storeDir = new File( "store" ); fs.deleteRecursively( storeDir ); fs.mkdir( storeDir ); - indexDir = new File( new File( new File( new File( new File( storeDir, "schema" ), "index" ), "spatial-1.0" ), "1" ), "1-4326" ); + + CoordinateReferenceSystem crs = CoordinateReferenceSystem.WGS84; + 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, CoordinateReferenceSystem.WGS84, 1L, pageCacheRule.getPageCache( fs ), fs, + index = new SpatialKnownIndex( dirStructure, crs, 1L, pageCacheRule.getPageCache( fs ), fs, SchemaIndexProvider.Monitor.EMPTY, RecoveryCleanupWorkCollector.IMMEDIATE ); descriptor = IndexDescriptorFactory.forLabel( 42, 1337 ); samplingConfig = mock( IndexSamplingConfig.class ); - CoordinateReferenceSystem crs = CoordinateReferenceSystem.WGS84; } @Test @@ -91,7 +95,7 @@ public void shouldNotCreateFileOnInit() assertThat( fs.listFiles( storeDir ).length, equalTo( 0 ) ); // when - index.initIfNeeded( descriptor, samplingConfig ); + index.init( descriptor, samplingConfig ); // then assertThat( fs.listFiles( storeDir ).length, equalTo( 0 ) ); @@ -102,14 +106,13 @@ public void shouldCreateFileOnCreate() throws IOException { // given assertThat( fs.listFiles( storeDir ).length, equalTo( 0 ) ); - index.initIfNeeded( descriptor, samplingConfig ); // when - index.createIfNeeded(); + index.startPopulation( descriptor, samplingConfig ); // then assertThat( fs.listFiles( indexDir ).length, equalTo( 1 ) ); - index.close( true ); + index.finishPopulation( true ); } @Test @@ -136,8 +139,7 @@ public void shouldNotTakeOnlineIfPopulating() throws IOException { // given assertThat( fs.listFiles( storeDir ).length, equalTo( 0 ) ); - index.initIfNeeded( descriptor, samplingConfig ); - index.createIfNeeded(); + index.startPopulation( descriptor, samplingConfig ); // when try @@ -149,7 +151,7 @@ public void shouldNotTakeOnlineIfPopulating() throws IOException { // then assertThat( e.getMessage(), containsString( "Failed to bring index online." ) ); - index.close( true ); + index.finishPopulation( true ); } } @@ -158,9 +160,8 @@ public void shouldTakeOnlineIfDonePopulating() throws IOException { // given assertThat( fs.listFiles( storeDir ).length, equalTo( 0 ) ); - index.initIfNeeded( descriptor, samplingConfig ); - index.createIfNeeded(); - index.close( true ); + index.startPopulation( descriptor, samplingConfig ); + index.finishPopulation( true ); // when index.takeOnline( descriptor, samplingConfig ); @@ -194,7 +195,7 @@ public void shouldGetUpdaterWhenPopuating() throws IOException, IndexEntryConfli assertThat( fs.listFiles( indexDir ).length, equalTo( 1 ) ); updater.close(); - index.close( true ); + index.finishPopulation( true ); } @Test @@ -202,8 +203,7 @@ public void drop() throws IOException { // given assertThat( fs.listFiles( storeDir ).length, equalTo( 0 ) ); - index.initIfNeeded( descriptor, samplingConfig ); - index.createIfNeeded(); + index.startPopulation( descriptor, samplingConfig ); assertThat( fs.listFiles( indexDir ).length, equalTo( 1 ) ); // when @@ -212,4 +212,18 @@ public void drop() throws IOException // then assertThat( fs.listFiles( indexDir ).length, equalTo( 0 ) ); } + + @Test + public void shouldThrowIfFileNotExistReadingInitialState() + { + try + { + index.readState( descriptor ); + fail( "Should throw if no index file exists." ); + } + catch ( IOException e ) + { + assertTrue( e instanceof NoSuchFileException ); + } + } } 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 e93663389131..ff4a8291a706 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 @@ -73,12 +73,6 @@ public void setup() throws Exception when( indexFactory.selectAndCreate( indexMap, 0, crs ) ).thenReturn( indexMap.get( crs ) ); } - when( indexFactory.selectAndCreate( eq( indexMap ), eq( 0L ), any( PointValue.class ) ) ).thenAnswer( a -> - { - PointValue pointValue = a.getArgument( 3 ); - return indexMap.get( pointValue.getCoordinateReferenceSystem() ); - } ); - fusionIndexPopulator = new SpatialFusionIndexPopulator( indexMap, 0, descriptor, null, indexFactory ); } @@ -151,28 +145,28 @@ public void unsuccessfulCloseMustCloseAll() throws Exception public void closeMustCloseOtherAndThrowIfCloseWGSThrow() throws Exception { IOException failure = new IOException( "fail" ); - doThrow( failure ).when( indexMap.get( CoordinateReferenceSystem.WGS84 ) ).close( anyBoolean() ); + doThrow( failure ).when( indexMap.get( CoordinateReferenceSystem.WGS84 ) ).finishPopulation( anyBoolean() ); verifyCallFail( failure, () -> { fusionIndexPopulator.close( true ); return null; } ); - verify( indexMap.get( CoordinateReferenceSystem.Cartesian ), times( 1 ) ).close( true ); + verify( indexMap.get( CoordinateReferenceSystem.Cartesian ), times( 1 ) ).finishPopulation( true ); } @Test public void closeMustCloseOtherAndThrowIfCloseCartesianThrow() throws Exception { IOException failure = new IOException( "fail" ); - doThrow( failure ).when( indexMap.get( CoordinateReferenceSystem.Cartesian ) ).close( anyBoolean() ); + doThrow( failure ).when( indexMap.get( CoordinateReferenceSystem.Cartesian ) ).finishPopulation( anyBoolean() ); verifyCallFail( failure, () -> { fusionIndexPopulator.close( true ); return null; } ); - verify( indexMap.get( CoordinateReferenceSystem.WGS84 ), times( 1 ) ).close( true ); + verify( indexMap.get( CoordinateReferenceSystem.WGS84 ), times( 1 ) ).finishPopulation( true ); } @Test @@ -180,8 +174,8 @@ public void closeMustThrowIfAllThrow() throws Exception { IOException wgsFailure = new IOException( "fail" ); IOException cartesianFailure = new IOException( "fail" ); - doThrow( cartesianFailure ).when( indexMap.get( CoordinateReferenceSystem.Cartesian ) ).close( anyBoolean() ); - doThrow( wgsFailure ).when( indexMap.get( CoordinateReferenceSystem.WGS84 ) ).close( anyBoolean() ); + doThrow( cartesianFailure ).when( indexMap.get( CoordinateReferenceSystem.Cartesian ) ).finishPopulation( anyBoolean() ); + doThrow( wgsFailure ).when( indexMap.get( CoordinateReferenceSystem.WGS84 ) ).finishPopulation( anyBoolean() ); try { @@ -235,7 +229,7 @@ private void closeAndVerifyPropagation( boolean populationCompletedSuccessfully // then for ( SpatialKnownIndex index : indexMap.values() ) { - verify( index, times( 1 ) ).close( populationCompletedSuccessfully ); + verify( index, times( 1 ) ).finishPopulation( populationCompletedSuccessfully ); } } 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 76381c177563..98db2618ef99 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 @@ -118,7 +118,7 @@ public void mustSelectCorrectTargetForValues() throws Exception { PointValue point = (PointValue) spatialValue; CoordinateReferenceSystem crs = point.getCoordinateReferenceSystem(); - SpatialKnownIndex index = provider.selectAndCreate( indexMap, 0, point ); + SpatialKnownIndex index = provider.selectAndCreate( indexMap, 0, point.getCoordinateReferenceSystem() ); assertSame( indexMap.get( crs ), index ); index = provider.selectAndCreate( indexMap, 0, crs ); assertSame( indexMap.get( crs ), index ); diff --git a/community/server/src/test/java/org/neo4j/server/rest/transactional/ExecutionResultSerializerTest.java b/community/server/src/test/java/org/neo4j/server/rest/transactional/ExecutionResultSerializerTest.java index 089331bfd47d..b9d7c8b37730 100644 --- a/community/server/src/test/java/org/neo4j/server/rest/transactional/ExecutionResultSerializerTest.java +++ b/community/server/src/test/java/org/neo4j/server/rest/transactional/ExecutionResultSerializerTest.java @@ -408,9 +408,9 @@ public void shouldSerializePointsAsListOfMapsOfProperties() throws Exception points.add( new Coordinate( 1, 2 ) ); points.add( new Coordinate( 2, 3 ) ); Result executionResult = mockExecutionResult( - map( "geom", new SpatialMocks.MockPoint( 12.3, 45.6, mockWGS84() ) ), - map( "geom", new SpatialMocks.MockPoint( 123, 456, mockCartesian() ) ), - map( "geom", new SpatialMocks.MockGeometry( "LineString", points, mockCartesian() ) ) ); + map( "geom", SpatialMocks.mockPoint( 12.3, 45.6, mockWGS84() ) ), + map( "geom", SpatialMocks.mockPoint( 123, 456, mockCartesian() ) ), + map( "geom", SpatialMocks.mockGeometry( "LineString", points, mockCartesian() ) ) ); // when serializer.statementResult( executionResult, false ); diff --git a/community/server/src/test/java/org/neo4j/server/rest/transactional/Neo4jJsonCodecTest.java b/community/server/src/test/java/org/neo4j/server/rest/transactional/Neo4jJsonCodecTest.java index 333a3deda4ec..0e3b3af8ded4 100644 --- a/community/server/src/test/java/org/neo4j/server/rest/transactional/Neo4jJsonCodecTest.java +++ b/community/server/src/test/java/org/neo4j/server/rest/transactional/Neo4jJsonCodecTest.java @@ -231,7 +231,7 @@ public void shouldWriteAMapContainingNullAsKeysAndValues() throws IOException public void testGeographicPointWriting() throws IOException { //Given - Point value = new SpatialMocks.MockPoint( 12.3, 45.6, mockWGS84() ); + Point value = SpatialMocks.mockPoint( 12.3, 45.6, mockWGS84() ); //When jsonCodec.writeValue( jsonGenerator, value ); @@ -244,7 +244,7 @@ public void testGeographicPointWriting() throws IOException public void testCartesianPointWriting() throws IOException { //Given - Point value = new SpatialMocks.MockPoint( 123.0, 456.0, mockCartesian() ); + Point value = SpatialMocks.mockPoint( 123.0, 456.0, mockCartesian() ); //When jsonCodec.writeValue( jsonGenerator, value ); @@ -260,7 +260,7 @@ public void testGeometryWriting() throws IOException List points = new ArrayList<>(); points.add( new Coordinate( 1, 2 ) ); points.add( new Coordinate( 2, 3 ) ); - Geometry value = new SpatialMocks.MockGeometry( "LineString", points, mockCartesian() ); + Geometry value = SpatialMocks.mockGeometry( "LineString", points, mockCartesian() ); //When jsonCodec.writeValue( jsonGenerator, value );