From 958a4a0ef5dd4ae89078fe4ade068538529c174e Mon Sep 17 00:00:00 2001 From: Olivia Ytterbrink Date: Fri, 23 Feb 2018 16:48:47 +0100 Subject: [PATCH] Changed to do sampling at SpatialFusion level this cleaned up the state handling in SpatialCRSSchemaIndex --- .../helpers/collection/CombiningIterable.java | 5 +- .../impl/index/schema/SamplingUtil.java | 4 +- .../index/schema/SpatialCRSSchemaIndex.java | 108 ++---------------- .../fusion/SpatialFusionIndexAccessor.java | 6 +- .../fusion/SpatialFusionIndexPopulator.java | 68 +++++++++-- .../fusion/SpatialFusionIndexUpdater.java | 14 +-- .../index/schema/SpatialKnownIndexTest.java | 31 ++--- .../SpatialFusionIndexPopulatorTest.java | 28 +---- .../fusion/SpatialFusionIndexUpdaterTest.java | 8 +- .../SpatialFunctionsAcceptanceTest.scala | 3 - 10 files changed, 95 insertions(+), 180 deletions(-) diff --git a/community/collections/src/main/java/org/neo4j/helpers/collection/CombiningIterable.java b/community/collections/src/main/java/org/neo4j/helpers/collection/CombiningIterable.java index 263836321d9f5..79dfda2eb30c9 100644 --- a/community/collections/src/main/java/org/neo4j/helpers/collection/CombiningIterable.java +++ b/community/collections/src/main/java/org/neo4j/helpers/collection/CombiningIterable.java @@ -32,9 +32,10 @@ public class CombiningIterable implements Iterable { private Iterable> iterables; - public CombiningIterable( Iterable> iterables ) + @SuppressWarnings( "unchecked" ) + public > CombiningIterable( Iterable iterables ) { - this.iterables = iterables; + this.iterables = (Iterable) iterables; } @Override diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/SamplingUtil.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/SamplingUtil.java index 99f3d5b9aa147..f0d7af6c574e4 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/SamplingUtil.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/SamplingUtil.java @@ -26,11 +26,11 @@ /** * Utilities for implementing {@link IndexSampler sampling}. */ -class SamplingUtil +public class SamplingUtil { private static final String DELIMITER = "\u001F"; - static String encodedStringValuesForSampling( Object... values ) + public static String encodedStringValuesForSampling( Object... values ) { return StringUtils.join( values, DELIMITER ); } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/SpatialCRSSchemaIndex.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/SpatialCRSSchemaIndex.java index f7b61c160fbef..e3246021b5b66 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/SpatialCRSSchemaIndex.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/SpatialCRSSchemaIndex.java @@ -48,13 +48,10 @@ import org.neo4j.kernel.api.index.IndexUpdater; import org.neo4j.kernel.api.index.SchemaIndexProvider; import org.neo4j.kernel.api.schema.index.IndexDescriptor; -import org.neo4j.kernel.impl.api.index.sampling.DefaultNonUniqueIndexSampler; import org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig; -import org.neo4j.kernel.impl.api.index.sampling.UniqueIndexSampler; import org.neo4j.kernel.impl.index.schema.NativeSchemaIndexPopulator.IndexUpdateApply; import org.neo4j.kernel.impl.index.schema.NativeSchemaIndexPopulator.IndexUpdateWork; import org.neo4j.storageengine.api.schema.IndexReader; -import org.neo4j.storageengine.api.schema.IndexSample; import org.neo4j.values.storable.CoordinateReferenceSystem; import static org.neo4j.helpers.collection.Iterators.asResourceIterator; @@ -70,10 +67,8 @@ */ public class SpatialCRSSchemaIndex { - private UniqueIndexSampler uniqueSampler; private final File indexFile; private final PageCache pageCache; - private final IndexDescriptor descriptor; private final CoordinateReferenceSystem crs; private final FileSystemAbstraction fs; private final RecoveryCleanupWorkCollector recoveryCleanupWorkCollector; @@ -89,7 +84,6 @@ public class SpatialCRSSchemaIndex private Writer singleTreeWriter; private NativeSchemaIndex schemaIndex; private WorkSync,IndexUpdateWork> workSync; - private DefaultNonUniqueIndexSampler generalSampler; public SpatialCRSSchemaIndex( IndexDescriptor descriptor, IndexDirectoryStructure directoryStructure, @@ -100,7 +94,6 @@ public SpatialCRSSchemaIndex( IndexDescriptor descriptor, SchemaIndexProvider.Monitor monitor, RecoveryCleanupWorkCollector recoveryCleanupWorkCollector ) { - this.descriptor = descriptor; this.crs = crs; this.pageCache = pageCache; this.fs = fs; @@ -124,32 +117,19 @@ 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; + state = State.INIT; 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( IndexSamplingConfig samplingConfig ) - { - if ( state == State.NONE ) - { - initialize( samplingConfig ); - } } /** * Makes sure that the index is ready to populate */ - public void startPopulation( IndexSamplingConfig samplingConfig ) throws IOException + public void startPopulation() throws IOException { - init( samplingConfig ); if ( state == State.INIT ) { // First add to sub-index, make sure to create @@ -164,9 +144,8 @@ public void startPopulation( IndexSamplingConfig samplingConfig ) throws IOExcep /** * Makes sure that the index is online */ - public void takeOnline( IndexSamplingConfig samplingConfig ) throws IOException + public void takeOnline() throws IOException { - init( samplingConfig ); if ( !indexExists() ) { throw new IOException( "Index file does not exist." ); @@ -181,24 +160,22 @@ public void takeOnline( IndexSamplingConfig samplingConfig ) throws IOException } } - public IndexUpdater updaterWithCreate( IndexSamplingConfig samplingConfig, boolean populating ) throws IOException + public IndexUpdater updaterWithCreate( boolean populating ) throws IOException { if ( populating ) { - if ( state == State.NONE ) + if ( state == State.INIT ) { // sub-index didn't exist, create in populating mode - initialize( samplingConfig ); create(); } return newPopulatingUpdater(); } else { - if ( state == State.NONE ) + if ( state == State.INIT ) { // sub-index didn't exist, create and make it online - initialize( samplingConfig ); create(); finishPopulation( true ); online(); @@ -291,62 +268,6 @@ public void add( Collection> updates ) throws IOException applyWithWorkSync( updates ); } - public void includeSample( IndexEntryUpdate update ) - { - if ( uniqueSampler != null ) - { - uniqueSampler.increment( 1 ); - } - else if ( generalSampler != null ) - { - generalSampler.include( SamplingUtil.encodedStringValuesForSampling( (Object[]) update.values() ) ); - } - else - { - throw new UnsupportedOperationException(); - } - } - - public IndexSample sampleResult() - { - if ( uniqueSampler != null ) - { - return uniqueSampler.result(); - } - else if ( generalSampler != null ) - { - // Close the writer before scanning - try - { - closeWriter(); - } - catch ( IOException e ) - { - throw new UncheckedIOException( e ); - } - - try - { - return generalSampler.result(); - } - finally - { - try - { - instantiateWriter(); - } - catch ( IOException e ) - { - throw new UncheckedIOException( e ); - } - } - } - else - { - throw new UnsupportedOperationException(); - } - } - private IndexUpdater newPopulatingUpdater() { return new IndexUpdater() @@ -391,7 +312,7 @@ public synchronized void drop() throws IOException finally { dropped = true; - state = State.NONE; + state = State.INIT; } } @@ -440,20 +361,6 @@ private synchronized void create() throws IOException state = State.POPULATING; } - private void initialize( IndexSamplingConfig samplingConfig ) - { - assert state == State.NONE; - if ( isUnique( descriptor ) ) - { - uniqueSampler = new UniqueIndexSampler(); - } - else - { - generalSampler = new DefaultNonUniqueIndexSampler( samplingConfig.sampleSizeLimit() ); - } - state = State.INIT; - } - private void online() throws IOException { assert state == State.POPULATED || state == State.INIT; @@ -544,7 +451,6 @@ private boolean isUnique( IndexDescriptor descriptor ) private enum State { - NONE, INIT, POPULATING, POPULATED, 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 407a37b116f65..c967dc26bb174 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 @@ -63,7 +63,7 @@ class SpatialFusionIndexAccessor implements IndexAccessor this.indexFactory = indexFactory; for ( SpatialCRSSchemaIndex index : indexMap.values() ) { - index.takeOnline( samplingConfig ); + index.takeOnline(); } } @@ -77,7 +77,7 @@ public void drop() throws IOException @Override public IndexUpdater newUpdater( IndexUpdateMode mode ) { - return SpatialFusionIndexUpdater.updaterForAccessor( indexMap, indexId, indexFactory, descriptor, samplingConfig ); + return SpatialFusionIndexUpdater.updaterForAccessor( indexMap, indexId, indexFactory, descriptor ); } @Override @@ -142,7 +142,7 @@ public void close() throws Exception @Override public Iterator iterator() { - return new CombiningIterable( allEntriesReader ).iterator(); + return new CombiningIterable<>( allEntriesReader ).iterator(); } }; } 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 79a4994255add..fb84078b5c990 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 @@ -31,7 +31,10 @@ import org.neo4j.kernel.api.index.IndexUpdater; import org.neo4j.kernel.api.index.PropertyAccessor; import org.neo4j.kernel.api.schema.index.IndexDescriptor; +import org.neo4j.kernel.impl.api.index.sampling.DefaultNonUniqueIndexSampler; import org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig; +import org.neo4j.kernel.impl.api.index.sampling.UniqueIndexSampler; +import org.neo4j.kernel.impl.index.schema.SamplingUtil; import org.neo4j.kernel.impl.index.schema.SpatialCRSSchemaIndex; import org.neo4j.storageengine.api.schema.IndexSample; import org.neo4j.values.storable.CoordinateReferenceSystem; @@ -39,15 +42,14 @@ import org.neo4j.values.storable.Value; import static org.neo4j.kernel.impl.index.schema.fusion.FusionIndexUtils.forAll; -import static org.neo4j.kernel.impl.index.schema.fusion.FusionSchemaIndexProvider.combineSamples; class SpatialFusionIndexPopulator implements IndexPopulator { private final long indexId; private final IndexDescriptor descriptor; - private final IndexSamplingConfig samplingConfig; private final SpatialCRSSchemaIndex.Supplier indexSupplier; private final Map indexMap; + private final IndexSamplerWrapper sampler; SpatialFusionIndexPopulator( Map indexMap, long indexId, IndexDescriptor descriptor, IndexSamplingConfig samplingConfig, SpatialCRSSchemaIndex.Supplier indexSupplier ) @@ -55,8 +57,8 @@ class SpatialFusionIndexPopulator implements IndexPopulator this.indexMap = indexMap; this.indexId = indexId; this.descriptor = descriptor; - this.samplingConfig = samplingConfig; this.indexSupplier = indexSupplier; + this.sampler = new IndexSamplerWrapper( descriptor, samplingConfig ); } @Override @@ -88,7 +90,7 @@ public void add( Collection> updates ) throws Inde for ( CoordinateReferenceSystem crs : batchMap.keySet() ) { SpatialCRSSchemaIndex index = indexSupplier.get( descriptor, indexMap, indexId, crs ); - index.startPopulation( samplingConfig ); + index.startPopulation(); index.add( batchMap.get( crs ) ); } } @@ -110,7 +112,7 @@ public void verifyDeferredConstraints( PropertyAccessor propertyAccessor ) @Override public IndexUpdater newPopulatingUpdater( PropertyAccessor accessor ) { - return SpatialFusionIndexUpdater.updaterForPopulator( indexMap, indexId, indexSupplier, descriptor, samplingConfig ); + return SpatialFusionIndexUpdater.updaterForPopulator( indexMap, indexId, indexSupplier, descriptor ); } @Override @@ -128,17 +130,59 @@ public void markAsFailed( String failure ) @Override public void includeSample( IndexEntryUpdate update ) { - Value[] values = update.values(); - assert values.length == 1; - CoordinateReferenceSystem crs = ((PointValue) values[0]).getCoordinateReferenceSystem(); - SpatialCRSSchemaIndex index = indexSupplier.get( descriptor, indexMap, indexId, crs ); - index.init( samplingConfig ); - index.includeSample( update ); + sampler.includeSample( update.values() ); } @Override public IndexSample sampleResult() { - return combineSamples( indexMap.values().stream().map( SpatialCRSSchemaIndex::sampleResult ).toArray( IndexSample[]::new ) ); + return sampler.sampleResult(); + } + + private static class IndexSamplerWrapper + { + private final DefaultNonUniqueIndexSampler generalSampler; + private final UniqueIndexSampler uniqueSampler; + + IndexSamplerWrapper( IndexDescriptor descriptor, IndexSamplingConfig samplingConfig ) + { + switch ( descriptor.type() ) + { + case GENERAL: + generalSampler = new DefaultNonUniqueIndexSampler( samplingConfig.sampleSizeLimit() ); + uniqueSampler = null; + break; + case UNIQUE: + generalSampler = null; + uniqueSampler = new UniqueIndexSampler(); + break; + default: + throw new UnsupportedOperationException( "Unexpected index type " + descriptor.type() ); + } + } + + void includeSample( Value[] values ) + { + if ( uniqueSampler != null ) + { + uniqueSampler.increment( 1 ); + } + else + { + generalSampler.include( SamplingUtil.encodedStringValuesForSampling( (Object[]) values ) ); + } + } + + IndexSample sampleResult() + { + if ( uniqueSampler != null ) + { + return uniqueSampler.result(); + } + else + { + return generalSampler.result(); + } + } } } 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 fb18114001033..add3cfd4ae331 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 @@ -27,7 +27,6 @@ import org.neo4j.kernel.api.index.IndexEntryUpdate; 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.SpatialCRSSchemaIndex; import org.neo4j.values.storable.CoordinateReferenceSystem; import org.neo4j.values.storable.PointValue; @@ -42,33 +41,30 @@ class SpatialFusionIndexUpdater implements IndexUpdater private final long indexId; private final SpatialCRSSchemaIndex.Supplier indexSupplier; private final IndexDescriptor descriptor; - private final IndexSamplingConfig samplingConfig; private final boolean populating; static SpatialFusionIndexUpdater updaterForAccessor( Map indexMap, long indexId, - SpatialCRSSchemaIndex.Supplier indexFactory, IndexDescriptor descriptor, IndexSamplingConfig samplingConfig ) + SpatialCRSSchemaIndex.Supplier indexFactory, IndexDescriptor descriptor ) { - return new SpatialFusionIndexUpdater( indexMap, indexId, indexFactory, descriptor, samplingConfig, false ); + return new SpatialFusionIndexUpdater( indexMap, indexId, indexFactory, descriptor, false ); } static SpatialFusionIndexUpdater updaterForPopulator( Map indexMap, long indexId, - SpatialCRSSchemaIndex.Supplier indexFactory, IndexDescriptor descriptor, IndexSamplingConfig samplingConfig ) + SpatialCRSSchemaIndex.Supplier indexFactory, IndexDescriptor descriptor ) { - return new SpatialFusionIndexUpdater( indexMap, indexId, indexFactory, descriptor, samplingConfig, true ); + return new SpatialFusionIndexUpdater( indexMap, indexId, indexFactory, descriptor, true ); } private SpatialFusionIndexUpdater( Map indexMap, long indexId, SpatialCRSSchemaIndex.Supplier indexSupplier, IndexDescriptor descriptor, - IndexSamplingConfig samplingConfig, boolean populating ) { this.indexMap = indexMap; this.indexId = indexId; this.indexSupplier = indexSupplier; this.descriptor = descriptor; - this.samplingConfig = samplingConfig; this.populating = populating; } @@ -117,7 +113,7 @@ private IndexUpdater selectUpdater( Value... values ) throws IOException return updater; } SpatialCRSSchemaIndex index = indexSupplier.get( descriptor, indexMap, indexId, crs ); - IndexUpdater indexUpdater = index.updaterWithCreate( samplingConfig, populating ); + IndexUpdater indexUpdater = index.updaterWithCreate( populating ); return remember( crs, indexUpdater ); } 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 cd3ea50f7bcd5..2f221e6d3f48b 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 @@ -88,19 +88,6 @@ public void setup() throws IOException samplingConfig = mock( IndexSamplingConfig.class ); } - @Test - public void shouldNotCreateFileOnInit() - { - // given - assertThat( fs.listFiles( storeDir ).length, equalTo( 0 ) ); - - // when - index.init( samplingConfig ); - - // then - assertThat( fs.listFiles( storeDir ).length, equalTo( 0 ) ); - } - @Test public void shouldCreateFileOnCreate() throws IOException { @@ -108,7 +95,7 @@ public void shouldCreateFileOnCreate() throws IOException assertThat( fs.listFiles( storeDir ).length, equalTo( 0 ) ); // when - index.startPopulation( samplingConfig ); + index.startPopulation(); // then assertThat( fs.listFiles( indexDir ).length, equalTo( 1 ) ); @@ -123,7 +110,7 @@ public void shouldNotTakeOnlineIfIndexNotCreated() throws IOException try { // when - index.takeOnline( samplingConfig ); + index.takeOnline(); fail("should have thrown exception"); } catch ( IOException e ) @@ -139,12 +126,12 @@ public void shouldNotTakeOnlineIfPopulating() throws IOException { // given assertThat( fs.listFiles( storeDir ).length, equalTo( 0 ) ); - index.startPopulation( samplingConfig ); + index.startPopulation(); // when try { - index.takeOnline( samplingConfig ); + index.takeOnline(); fail( "Should have thrown exception." ); } catch ( IllegalStateException e ) @@ -160,11 +147,11 @@ public void shouldTakeOnlineIfDonePopulating() throws IOException { // given assertThat( fs.listFiles( storeDir ).length, equalTo( 0 ) ); - index.startPopulation( samplingConfig ); + index.startPopulation(); index.finishPopulation( true ); // when - index.takeOnline( samplingConfig ); + index.takeOnline(); index.close(); } @@ -174,7 +161,7 @@ public void shouldGetUpdaterWhenOnline() throws IOException, IndexEntryConflictE assertThat( fs.listFiles( storeDir ).length, equalTo( 0 ) ); // when - IndexUpdater updater = index.updaterWithCreate( samplingConfig, false ); + IndexUpdater updater = index.updaterWithCreate( false ); // then assertThat( fs.listFiles( indexDir ).length, equalTo( 1 ) ); @@ -189,7 +176,7 @@ public void shouldGetUpdaterWhenPopulating() throws IOException, IndexEntryConfl assertThat( fs.listFiles( storeDir ).length, equalTo( 0 ) ); // when - IndexUpdater updater = index.updaterWithCreate( samplingConfig, true ); + IndexUpdater updater = index.updaterWithCreate( true ); // then assertThat( fs.listFiles( indexDir ).length, equalTo( 1 ) ); @@ -203,7 +190,7 @@ public void drop() throws IOException { // given assertThat( fs.listFiles( storeDir ).length, equalTo( 0 ) ); - index.startPopulation( samplingConfig ); + index.startPopulation(); assertThat( fs.listFiles( indexDir ).length, equalTo( 1 ) ); // when 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 fb372193457fd..b4237780fe119 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 @@ -28,10 +28,11 @@ import java.util.HashMap; import java.util.Map; -import org.neo4j.internal.kernel.api.schema.LabelSchemaDescriptor; 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.api.schema.index.IndexDescriptorFactory; +import org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig; import org.neo4j.kernel.impl.index.schema.SpatialCRSSchemaIndex; import org.neo4j.values.storable.CoordinateReferenceSystem; import org.neo4j.values.storable.PointValue; @@ -45,7 +46,6 @@ import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.reset; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -62,7 +62,7 @@ public class SpatialFusionIndexPopulatorTest public void setup() throws Exception { SpatialCRSSchemaIndex.Supplier indexSupplier = mock( SpatialCRSSchemaIndex.Supplier.class ); - IndexDescriptor descriptor = mock( IndexDescriptor.class ); + IndexDescriptor descriptor = IndexDescriptorFactory.forLabel( 42, 1337 ); for ( CoordinateReferenceSystem crs : asList( CoordinateReferenceSystem.WGS84, CoordinateReferenceSystem.Cartesian ) ) { @@ -71,7 +71,9 @@ public void setup() throws Exception when( indexSupplier.get( descriptor, indexMap, 0, crs ) ).thenReturn( indexMap.get( crs ) ); } - fusionIndexPopulator = new SpatialFusionIndexPopulator( indexMap, 0, descriptor, null, indexSupplier ); + IndexSamplingConfig samplingConfig = mock( IndexSamplingConfig.class ); + when( samplingConfig.sampleSizeLimit() ).thenReturn( 8_000_000 ); + fusionIndexPopulator = new SpatialFusionIndexPopulator( indexMap, 0, descriptor, samplingConfig, indexSupplier ); } @Test @@ -202,24 +204,6 @@ public void markAsFailedMustMarkAll() throws Exception } } - @Test - public void shouldIncludeSampleOnCorrectPopulator() throws Exception - { - // given - for ( Value value : FusionIndexTestHelp.valuesSupportedBySpatial() ) - { - PointValue point = (PointValue) value; - // when - IndexEntryUpdate update = add( value ); - fusionIndexPopulator.includeSample( update ); - - // then - SpatialCRSSchemaIndex spatialKnownIndex = indexMap.get( point.getCoordinateReferenceSystem() ); - verify( spatialKnownIndex ).includeSample( update ); - reset( spatialKnownIndex ); - } - } - private void closeAndVerifyPropagation( boolean populationCompletedSuccessfully ) throws IOException { fusionIndexPopulator.close( populationCompletedSuccessfully ); 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 46f2ad5c7d220..6bfe1209f34aa 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 @@ -67,14 +67,14 @@ public void setup() throws Exception updaterMap.put( crs, mock( IndexUpdater.class ) ); indexMap.put( crs, mock( SpatialCRSSchemaIndex.class ) ); when( indexSupplier.get( 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 ) ); + when( indexMap.get( crs ).updaterWithCreate( true ) ).thenReturn( updaterMap.get( crs ) ); + when( indexMap.get( crs ).updaterWithCreate( false ) ).thenReturn( updaterMap.get( crs ) ); } fusionIndexAccessorUpdater = SpatialFusionIndexUpdater.updaterForAccessor( - indexMap, 0, indexSupplier, descriptor, samplingConfig ); + indexMap, 0, indexSupplier, descriptor ); fusionIndexPopulatorUpdater = SpatialFusionIndexUpdater.updaterForPopulator( - indexMap, 0, indexSupplier, descriptor, samplingConfig ); + indexMap, 0, indexSupplier, descriptor ); } @Test diff --git a/enterprise/cypher/acceptance-spec-suite/src/test/scala/org/neo4j/internal/cypher/acceptance/SpatialFunctionsAcceptanceTest.scala b/enterprise/cypher/acceptance-spec-suite/src/test/scala/org/neo4j/internal/cypher/acceptance/SpatialFunctionsAcceptanceTest.scala index 9d362443626b5..93a0fa998731c 100644 --- a/enterprise/cypher/acceptance-spec-suite/src/test/scala/org/neo4j/internal/cypher/acceptance/SpatialFunctionsAcceptanceTest.scala +++ b/enterprise/cypher/acceptance-spec-suite/src/test/scala/org/neo4j/internal/cypher/acceptance/SpatialFunctionsAcceptanceTest.scala @@ -19,10 +19,7 @@ */ package org.neo4j.internal.cypher.acceptance -import java.util.concurrent.TimeUnit - import org.neo4j.cypher.ExecutionEngineFunSuite -import org.neo4j.graphdb.Label import org.neo4j.graphdb.spatial.Point import org.neo4j.internal.cypher.acceptance.CypherComparisonSupport._ import org.neo4j.values.storable.{CoordinateReferenceSystem, Values}