diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/SpatialIndexAccessor.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/SpatialIndexAccessor.java
index 95fcfc7583bfd..387718523247a 100644
--- a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/SpatialIndexAccessor.java
+++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/SpatialIndexAccessor.java
@@ -189,7 +189,7 @@ static class PartAccessor extends NativeIndexAccessor
@Override
public PartAccessor newSpatial( CoordinateReferenceSystem crs ) throws IOException
{
- return createPartAccessor( spatialIndexFiles.forCrs( crs ) );
- }
-
- private PartAccessor createPartAccessor( SpatialIndexFiles.SpatialFileLayout fileLayout ) throws IOException
- {
- if ( !fs.fileExists( fileLayout.indexFile ) )
+ SpatialIndexFiles.SpatialFile indexFile = spatialIndexFiles.forCrs( crs );
+ if ( !fs.fileExists( indexFile.indexFile ) )
{
+ SpatialIndexFiles.SpatialFileLayout fileLayout = indexFile.getLayoutForNewIndex();
createEmptyIndex( fileLayout );
+ return createPartAccessor( fileLayout );
}
else
{
- fileLayout.readHeader( pageCache );
+ return createPartAccessor( indexFile.getLayoutForExistingIndex( pageCache ) );
}
+ }
+
+ private PartAccessor createPartAccessor( SpatialIndexFiles.SpatialFileLayout fileLayout ) throws IOException
+ {
return new PartAccessor( pageCache,
fs,
fileLayout,
diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/SpatialIndexFiles.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/SpatialIndexFiles.java
index e9e065b04bd53..c809087a7f2b1 100644
--- a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/SpatialIndexFiles.java
+++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/SpatialIndexFiles.java
@@ -26,7 +26,6 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.neo4j.index.internal.gbptree.GBPTree;
import org.neo4j.index.internal.gbptree.Layout;
import org.neo4j.io.fs.FileSystemAbstraction;
import org.neo4j.io.pagecache.PageCache;
@@ -49,27 +48,27 @@ class SpatialIndexFiles
indexDirectory = directoryStructure.directoryForIndex( indexId );
}
- Iterable existing()
+ Iterable existing()
{
- List existing = new ArrayList<>();
+ List existing = new ArrayList<>();
addExistingFiles( existing );
return existing;
}
void loadExistingIndexes( SpatialIndexCache indexCache ) throws IOException
{
- for ( SpatialFileLayout fileLayout : existing() )
+ for ( SpatialFile fileLayout : existing() )
{
indexCache.select( fileLayout.crs );
}
}
- SpatialFileLayout forCrs( CoordinateReferenceSystem crs )
+ SpatialFile forCrs( CoordinateReferenceSystem crs )
{
- return new SpatialFileLayout( crs, settingsFactory.settingsFor( crs ).clone(), indexDirectory );
+ return new SpatialFile( crs, settingsFactory, indexDirectory );
}
- private void addExistingFiles( List existing )
+ private void addExistingFiles( List existing )
{
File[] files = fs.listFiles( indexDirectory );
if ( files != null )
@@ -89,30 +88,50 @@ private void addExistingFiles( List existing )
}
}
- static class SpatialFileLayout
+ static class SpatialFile
{
final File indexFile;
- final SpaceFillingCurveSettings settings;
+ final SpaceFillingCurveSettingsFactory settings;
private final CoordinateReferenceSystem crs;
- Layout layout;
- SpatialFileLayout( CoordinateReferenceSystem crs, SpaceFillingCurveSettings settings, File indexDirectory )
+ SpatialFile( CoordinateReferenceSystem crs, SpaceFillingCurveSettingsFactory settingsFactory, File indexDirectory )
{
this.crs = crs;
- this.settings = settings;
- this.layout = new SpatialLayout( crs, settings.curve() );
+ this.settings = settingsFactory;
String s = crs.getTable().getTableId() + "-" + Integer.toString( crs.getCode() );
this.indexFile = new File( indexDirectory, s );
}
- public void readHeader( PageCache pageCache ) throws IOException
+ /**
+ * If this is the first time an index is being created, get the layout settings from the config settings only
+ */
+ SpatialFileLayout getLayoutForNewIndex()
{
- GBPTree.readHeader( pageCache, indexFile, settings.headerReader( NativeIndexHeaderReader::readFailureMessage ) );
- if ( settings.isFailed() )
- {
- throw new IOException( settings.getFailureMessage() );
- }
- this.layout = new SpatialLayout( crs, settings.curve() );
+ return new SpatialFileLayout( this, settings.settingsFor( crs ) );
+ }
+
+ /**
+ * If we are loading a layout for an existing index, read the settings from the index header, and ignore config settings
+ */
+ SpatialFileLayout getLayoutForExistingIndex( PageCache pageCache ) throws IOException
+ {
+ SpaceFillingCurveSettings settings =
+ SpaceFillingCurveSettings.fromGBPTree( indexFile, pageCache, NativeIndexHeaderReader::readFailureMessage );
+ return new SpatialFileLayout( this, settings );
+ }
+ }
+
+ static class SpatialFileLayout
+ {
+ final SpaceFillingCurveSettings settings;
+ final SpatialFile spatialFile;
+ final Layout layout;
+
+ SpatialFileLayout( SpatialFile spatialFile, SpaceFillingCurveSettings settings )
+ {
+ this.spatialFile = spatialFile;
+ this.settings = settings;
+ this.layout = new SpatialLayout( spatialFile.crs, settings.curve() );
}
}
}
diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/SpatialIndexPopulator.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/SpatialIndexPopulator.java
index e11b52d5105eb..369231406f4f7 100644
--- a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/SpatialIndexPopulator.java
+++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/SpatialIndexPopulator.java
@@ -151,7 +151,7 @@ static class PartPopulator extends NativeIndexPopulator
@Override
public PartPopulator newSpatial( CoordinateReferenceSystem crs ) throws IOException
{
- return create( spatialIndexFiles.forCrs(crs) );
+ return create( spatialIndexFiles.forCrs( crs ).getLayoutForNewIndex() );
}
private PartPopulator create( SpatialIndexFiles.SpatialFileLayout fileLayout ) throws IOException
diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/SpatialIndexProvider.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/SpatialIndexProvider.java
index 913d808dcc4be..5dd632884a313 100644
--- a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/SpatialIndexProvider.java
+++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/SpatialIndexProvider.java
@@ -118,7 +118,7 @@ public String getPopulationFailure( StoreIndexDescriptor descriptor ) throws Ill
try
{
- for ( SpatialIndexFiles.SpatialFileLayout subIndex : spatialIndexFiles.existing() )
+ for ( SpatialIndexFiles.SpatialFile subIndex : spatialIndexFiles.existing() )
{
String indexFailure = NativeIndexes.readFailureMessage( pageCache, subIndex.indexFile );
if ( indexFailure != null )
@@ -139,9 +139,9 @@ public InternalIndexState getInitialState( StoreIndexDescriptor descriptor )
{
SpatialIndexFiles spatialIndexFiles = new SpatialIndexFiles( directoryStructure(), descriptor.getId(), fs, settingsFactory );
- final Iterable existing = spatialIndexFiles.existing();
+ final Iterable existing = spatialIndexFiles.existing();
InternalIndexState state = InternalIndexState.ONLINE;
- for ( SpatialIndexFiles.SpatialFileLayout subIndex : existing )
+ for ( SpatialIndexFiles.SpatialFile subIndex : existing )
{
try
{
diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/config/SpaceFillingCurveSettings.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/config/SpaceFillingCurveSettings.java
index da3e28405bbe8..12b7457b08148 100644
--- a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/config/SpaceFillingCurveSettings.java
+++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/config/SpaceFillingCurveSettings.java
@@ -19,6 +19,8 @@
*/
package org.neo4j.kernel.impl.index.schema.config;
+import java.io.File;
+import java.io.IOException;
import java.nio.BufferUnderflowException;
import java.nio.ByteBuffer;
import java.util.Arrays;
@@ -29,7 +31,9 @@
import org.neo4j.gis.spatial.index.curves.HilbertSpaceFillingCurve2D;
import org.neo4j.gis.spatial.index.curves.HilbertSpaceFillingCurve3D;
import org.neo4j.gis.spatial.index.curves.SpaceFillingCurve;
+import org.neo4j.index.internal.gbptree.GBPTree;
import org.neo4j.index.internal.gbptree.Header;
+import org.neo4j.io.pagecache.PageCache;
import org.neo4j.io.pagecache.PageCursor;
import static org.neo4j.kernel.impl.index.schema.NativeIndexPopulator.BYTE_FAILED;
@@ -61,36 +65,124 @@
*
*
*/
-public class SpaceFillingCurveSettings
+public abstract class SpaceFillingCurveSettings
{
- private int dimensions;
- private int maxLevels;
- private Envelope extents;
- private String failureMessage;
+ protected int dimensions;
+ int maxLevels;
+ Envelope extents;
- public SpaceFillingCurveSettings( int dimensions, int maxBits, Envelope extents )
+ static SpaceFillingCurveSettings fromConfig( int dimensions, int maxBits, Envelope extents )
{
- this( dimensions, extents, calcMaxLevels( dimensions, maxBits ) );
+ return new SettingsFromConfig( dimensions, maxBits, extents );
}
- private SpaceFillingCurveSettings( int dimensions, Envelope extents, int maxLevels )
+ public static SpaceFillingCurveSettings fromGBPTree( File indexFile, PageCache pageCache, Function onError ) throws IOException
{
- this.dimensions = dimensions;
- this.extents = extents;
- this.maxLevels = maxLevels;
+ SettingsFromIndexHeader settings = new SettingsFromIndexHeader();
+ GBPTree.readHeader( pageCache, indexFile, settings.headerReader( onError ) );
+ if ( settings.isFailed() )
+ {
+ throw new IOException( settings.getFailureMessage() );
+ }
+ return settings;
}
- @Override
- public SpaceFillingCurveSettings clone()
+ private static class SettingsFromConfig extends SpaceFillingCurveSettings
{
- return new SpaceFillingCurveSettings( this.dimensions, this.extents, this.maxLevels );
+ private SettingsFromConfig( int dimensions, int maxBits, Envelope extents )
+ {
+ super( dimensions, extents, calcMaxLevels( dimensions, maxBits ) );
+ }
+
+ private static int calcMaxLevels( int dimensions, int maxBits )
+ {
+ int maxConfigured = maxBits / dimensions;
+ int maxSupported = (dimensions == 2) ? HilbertSpaceFillingCurve2D.MAX_LEVEL : HilbertSpaceFillingCurve3D.MAX_LEVEL;
+ return Math.min( maxConfigured, maxSupported );
+ }
}
- private static int calcMaxLevels( int dimensions, int maxBits )
+ private static class SettingsFromIndexHeader extends SpaceFillingCurveSettings
{
- int maxConfigured = maxBits / dimensions;
- int maxSupported = (dimensions == 2) ? HilbertSpaceFillingCurve2D.MAX_LEVEL : HilbertSpaceFillingCurve3D.MAX_LEVEL;
- return Math.min( maxConfigured, maxSupported );
+ private String failureMessage;
+
+ private SettingsFromIndexHeader()
+ {
+ super( 0, null, 0 );
+ }
+
+ private void markAsFailed( String failureMessage )
+ {
+ this.failureMessage = failureMessage;
+ }
+
+ private void markAsSucceeded()
+ {
+ this.failureMessage = null;
+ }
+
+ /**
+ * The settings are read from the GBPTree header structure, but when this is a FAILED index, there are no settings, but instead an error message
+ * describing the failure. If that happens, code that triggered the read should check this field and react accordingly. If the the value is null, there
+ * was no failure.
+ */
+ private String getFailureMessage()
+ {
+ return failureMessage;
+ }
+
+ /**
+ * The settings are read from the GBPTree header structure, but when this is a FAILED index, there are no settings, but instead an error message
+ * describing the failure. If that happens, code that triggered the read should check this. If the value is true, calling getFailureMessage() will
+ * provide an error message describing the failure.
+ */
+ private boolean isFailed()
+ {
+ return failureMessage != null;
+ }
+
+ private Header.Reader headerReader( Function onError )
+ {
+ return headerBytes ->
+ {
+ byte state = headerBytes.get();
+ if ( state == BYTE_FAILED )
+ {
+ this.failureMessage = "Unexpectedly trying to read the header of a failed index: " + onError.apply( headerBytes );
+ }
+ else
+ {
+ int typeId = headerBytes.getInt();
+ SpatialIndexType indexType = SpatialIndexType.get( typeId );
+ if ( indexType == null )
+ {
+ markAsFailed( "Unknown spatial index type in index header: " + typeId );
+ }
+ else
+ {
+ markAsSucceeded();
+ indexType.readHeader( this, headerBytes );
+ }
+ }
+ };
+ }
+ }
+
+ public Consumer headerWriter( byte initialIndexState )
+ {
+ return cursor ->
+ {
+ cursor.putByte( initialIndexState );
+ cursor.putInt( SpatialIndexType.SingleSpaceFillingCurve.id );
+ SpatialIndexType.SingleSpaceFillingCurve.writeHeader( this, cursor );
+ };
+ }
+
+ private SpaceFillingCurveSettings( int dimensions, Envelope extents, int maxLevels )
+ {
+ this.dimensions = dimensions;
+ this.extents = extents;
+ this.maxLevels = maxLevels;
}
/**
@@ -124,36 +216,6 @@ public Envelope indexExtents()
return extents;
}
- /**
- * The settings are read from the GBPTree header structure, but when this is a FAILED index, there are no settings, but instead an error message
- * describing the failure. If that happens, code that triggered the read should check this field and react accordingly. If the the value is null, there
- * was no failure.
- */
- public String getFailureMessage()
- {
- return failureMessage;
- }
-
- /**
- * The settings are read from the GBPTree header structure, but when this is a FAILED index, there are no settings, but instead an error message
- * describing the failure. If that happens, code that triggered the read should check this. If the value is true, calling getFailureMessage() will
- * provide an error message describing the failure.
- */
- public boolean isFailed()
- {
- return this.failureMessage != null;
- }
-
- private void markAsFailed( String failureMessage )
- {
- this.failureMessage = failureMessage;
- }
-
- private void markAsSucceeded()
- {
- this.failureMessage = null;
- }
-
/**
* Make an instance of the SpaceFillingCurve that can perform the 2D (or 3D) to 1D mapping based on these settings.
*
@@ -226,7 +288,7 @@ public void writeHeader( SpaceFillingCurveSettings settings, PageCursor cursor )
}
@Override
- public void readHeader( SpaceFillingCurveSettings settings, ByteBuffer headerBytes )
+ public void readHeader( SettingsFromIndexHeader settings, ByteBuffer headerBytes )
{
try
{
@@ -251,7 +313,7 @@ public void readHeader( SpaceFillingCurveSettings settings, ByteBuffer headerByt
public abstract void writeHeader( SpaceFillingCurveSettings settings, PageCursor cursor );
- public abstract void readHeader( SpaceFillingCurveSettings settings, ByteBuffer headerBytes );
+ public abstract void readHeader( SettingsFromIndexHeader settingsFromIndexHeader, ByteBuffer headerBytes );
SpatialIndexType( int id )
{
@@ -270,40 +332,4 @@ static SpatialIndexType get( int id )
return null;
}
}
-
- public Consumer headerWriter( byte initialIndexState )
- {
- return cursor ->
- {
- cursor.putByte( initialIndexState );
- cursor.putInt( SpatialIndexType.SingleSpaceFillingCurve.id );
- SpatialIndexType.SingleSpaceFillingCurve.writeHeader( this, cursor );
- };
- }
-
- public Header.Reader headerReader( Function onError )
- {
- return headerBytes ->
- {
- byte state = headerBytes.get();
- if ( state == BYTE_FAILED )
- {
- this.failureMessage = "Unexpectedly trying to read the header of a failed index: " + onError.apply( headerBytes );
- }
- else
- {
- int typeId = headerBytes.getInt();
- SpatialIndexType indexType = SpatialIndexType.get( typeId );
- if ( indexType == null )
- {
- markAsFailed( "Unknown spatial index type in index header: " + typeId );
- }
- else
- {
- markAsSucceeded();
- indexType.readHeader( SpaceFillingCurveSettings.this, headerBytes );
- }
- }
- };
- }
}
diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/config/SpaceFillingCurveSettingsFactory.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/config/SpaceFillingCurveSettingsFactory.java
index ea444fc11d8cc..095a855057bc1 100644
--- a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/config/SpaceFillingCurveSettingsFactory.java
+++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/config/SpaceFillingCurveSettingsFactory.java
@@ -112,7 +112,7 @@ public SpaceFillingCurveSettingsFactory( Config config )
for ( Map.Entry entry : env.entrySet() )
{
CoordinateReferenceSystem crs = entry.getKey();
- settings.put( crs, new SpaceFillingCurveSettings( crs.getDimension(), this.maxBits, entry.getValue().asEnvelope() ) );
+ settings.put( crs, SpaceFillingCurveSettings.fromConfig( crs.getDimension(), this.maxBits, entry.getValue().asEnvelope() ) );
}
}
@@ -132,7 +132,7 @@ public SpaceFillingCurveSettings settingsFor( CoordinateReferenceSystem crs )
}
else
{
- return new SpaceFillingCurveSettings( crs.getDimension(), maxBits,
+ return SpaceFillingCurveSettings.fromConfig( crs.getDimension(), maxBits,
envelopeFromCRS( crs.getDimension(), crs.isGeographic(), new EnvelopeSettings( crs ) ) );
}
}
diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/SpatialIndexAccessorTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/SpatialIndexAccessorTest.java
index 871755806c718..637aa854dbb81 100644
--- a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/SpatialIndexAccessorTest.java
+++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/SpatialIndexAccessorTest.java
@@ -25,7 +25,6 @@
import org.neo4j.gis.spatial.index.curves.StandardConfiguration;
import org.neo4j.kernel.configuration.Config;
import org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig;
-import org.neo4j.kernel.impl.index.schema.config.SpaceFillingCurveSettings;
import org.neo4j.kernel.impl.index.schema.config.SpaceFillingCurveSettingsFactory;
import org.neo4j.values.storable.CoordinateReferenceSystem;
@@ -34,22 +33,22 @@
abstract class SpatialIndexAccessorTest extends NativeIndexAccessorTest
{
static final CoordinateReferenceSystem crs = CoordinateReferenceSystem.WGS84;
- static final SpaceFillingCurveSettings settings = new SpaceFillingCurveSettingsFactory( Config.defaults() ).settingsFor( crs );
+ static final SpaceFillingCurveSettingsFactory settings = new SpaceFillingCurveSettingsFactory( Config.defaults() );
- SpatialIndexFiles.SpatialFileLayout fileLayout;
+ private SpatialIndexFiles.SpatialFile spatialFile;
@Override
NativeIndexAccessor makeAccessorWithSamplingConfig( IndexSamplingConfig samplingConfig ) throws IOException
{
- fileLayout = new SpatialIndexFiles.SpatialFileLayout( CoordinateReferenceSystem.WGS84, settings, super.getIndexFile() );
- return new SpatialIndexAccessor.PartAccessor( pageCache, fs, fileLayout, IMMEDIATE, monitor, indexDescriptor, samplingConfig,
- new StandardConfiguration() );
+ spatialFile = new SpatialIndexFiles.SpatialFile( CoordinateReferenceSystem.WGS84, settings, super.getIndexFile() );
+ return new SpatialIndexAccessor.PartAccessor( pageCache, fs, spatialFile.getLayoutForNewIndex(), IMMEDIATE, monitor, indexDescriptor,
+ samplingConfig, new StandardConfiguration() );
}
@Override
public File getIndexFile()
{
- return fileLayout.indexFile;
+ return spatialFile.indexFile;
}
@Override
diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/SpatialIndexSettingsTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/SpatialIndexSettingsTest.java
index c0615a9e739bf..f5814db44d481 100644
--- a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/SpatialIndexSettingsTest.java
+++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/SpatialIndexSettingsTest.java
@@ -189,9 +189,9 @@ private void addUpdates( SpatialIndexProvider provider, long indexId, SchemaInde
accessor.close();
}
- private SpatialIndexFiles.SpatialFileLayout makeFileLayout( long indexId, SpaceFillingCurveSettingsFactory settings )
+ private SpatialIndexFiles.SpatialFile makeIndexFile( long indexId, SpaceFillingCurveSettingsFactory settings )
{
- return new SpatialIndexFiles.SpatialFileLayout( CoordinateReferenceSystem.WGS84, settings.settingsFor( crs ), indexDir( indexId ) );
+ return new SpatialIndexFiles.SpatialFile( CoordinateReferenceSystem.WGS84, settings, indexDir( indexId ) );
}
private File indexDir( long indexId )
@@ -202,7 +202,7 @@ private File indexDir( long indexId )
private File indexFile( long indexId )
{
// The indexFile location is independent of the settings, so we just use the defaults
- return makeFileLayout( indexId, new SpaceFillingCurveSettingsFactory( Config.defaults() ) ).indexFile;
+ return makeIndexFile( indexId, new SpaceFillingCurveSettingsFactory( Config.defaults() ) ).indexFile;
}
private File indexRoot()
@@ -212,7 +212,7 @@ private File indexRoot()
private void createEmptyIndex( long indexId, SchemaIndexDescriptor schemaIndexDescriptor, SpaceFillingCurveSettingsFactory settings ) throws IOException
{
- SpatialIndexFiles.SpatialFileLayout fileLayout = makeFileLayout( indexId, settings );
+ SpatialIndexFiles.SpatialFileLayout fileLayout = makeIndexFile( indexId, settings ).getLayoutForNewIndex();
SpatialIndexPopulator.PartPopulator populator =
new SpatialIndexPopulator.PartPopulator( pageCache, fs, fileLayout, monitor, schemaIndexDescriptor, indexId, samplingConfig(),
new StandardConfiguration() );
@@ -231,8 +231,8 @@ private void verifySpatialSettings( File indexFile, SpaceFillingCurveSettings ex
{
try
{
- SpaceFillingCurveSettings settings = new SpaceFillingCurveSettings( 2, 2, null );
- GBPTree.readHeader( pageCache, indexFile, settings.headerReader( NativeSchemaIndexHeaderReader::readFailureMessage ) );
+ SpaceFillingCurveSettings settings =
+ SpaceFillingCurveSettings.fromGBPTree( indexFile, pageCache, NativeSchemaIndexHeaderReader::readFailureMessage );
assertThat( "Should get correct results from header", settings, equalTo( expectedSettings ) );
}
catch ( IOException e )
diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/SpatialNonUniqueIndexAccessorTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/SpatialNonUniqueIndexAccessorTest.java
index 7c6533ace478b..740ef3fd9ae98 100644
--- a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/SpatialNonUniqueIndexAccessorTest.java
+++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/SpatialNonUniqueIndexAccessorTest.java
@@ -26,6 +26,6 @@ public class SpatialNonUniqueIndexAccessorTest extends SpatialIndexAccessorTest
@Override
protected LayoutTestUtil createLayoutTestUtil()
{
- return new SpatialLayoutTestUtil( TestIndexDescriptorFactory.forLabel( 42, 666 ), settings, crs );
+ return new SpatialLayoutTestUtil( TestIndexDescriptorFactory.forLabel( 42, 666 ), settings.settingsFor( crs ), crs );
}
}
diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/SpatialNonUniqueIndexPopulatorTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/SpatialNonUniqueIndexPopulatorTest.java
index 3c5a5d7cf1183..9d06e8d3d3068 100644
--- a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/SpatialNonUniqueIndexPopulatorTest.java
+++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/SpatialNonUniqueIndexPopulatorTest.java
@@ -25,33 +25,33 @@
import org.neo4j.kernel.api.schema.index.TestIndexDescriptorFactory;
import org.neo4j.kernel.configuration.Config;
import org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig;
-import org.neo4j.kernel.impl.index.schema.config.SpaceFillingCurveSettings;
import org.neo4j.kernel.impl.index.schema.config.SpaceFillingCurveSettingsFactory;
import org.neo4j.values.storable.CoordinateReferenceSystem;
public class SpatialNonUniqueIndexPopulatorTest extends NativeNonUniqueIndexPopulatorTest
{
private static final CoordinateReferenceSystem crs = CoordinateReferenceSystem.WGS84;
- private static final SpaceFillingCurveSettings settings = new SpaceFillingCurveSettingsFactory( Config.defaults() ).settingsFor( crs );
+ private static final SpaceFillingCurveSettingsFactory settings = new SpaceFillingCurveSettingsFactory( Config.defaults() );
- private SpatialIndexFiles.SpatialFileLayout fileLayout;
+ private SpatialIndexFiles.SpatialFile spatialFile;
@Override
NativeIndexPopulator createPopulator( IndexSamplingConfig samplingConfig )
{
- fileLayout = new SpatialIndexFiles.SpatialFileLayout( crs, settings, super.getIndexFile() );
- return new SpatialIndexPopulator.PartPopulator( pageCache, fs, fileLayout, monitor, indexDescriptor, samplingConfig, new StandardConfiguration() );
+ spatialFile = new SpatialIndexFiles.SpatialFile( crs, settings, super.getIndexFile() );
+ return new SpatialIndexPopulator.PartPopulator( pageCache, fs, spatialFile.getLayoutForNewIndex(), monitor, indexDescriptor, samplingConfig,
+ new StandardConfiguration() );
}
@Override
public File getIndexFile()
{
- return fileLayout.indexFile;
+ return spatialFile.indexFile;
}
@Override
protected LayoutTestUtil createLayoutTestUtil()
{
- return new SpatialLayoutTestUtil( TestIndexDescriptorFactory.forLabel( 42, 666 ), settings, crs );
+ return new SpatialLayoutTestUtil( TestIndexDescriptorFactory.forLabel( 42, 666 ), settings.settingsFor( crs ), crs );
}
}
diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/SpatialUniqueIndexAccessorTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/SpatialUniqueIndexAccessorTest.java
index 6cdd6301c0da3..f2cb8e6eba8f7 100644
--- a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/SpatialUniqueIndexAccessorTest.java
+++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/SpatialUniqueIndexAccessorTest.java
@@ -26,6 +26,7 @@ public class SpatialUniqueIndexAccessorTest extends SpatialIndexAccessorTest
@Override
protected LayoutTestUtil createLayoutTestUtil()
{
- return new UniqueLayoutTestUtil<>( new SpatialLayoutTestUtil( TestIndexDescriptorFactory.uniqueForLabel( 42, 666 ), settings, crs ) );
+ return new UniqueLayoutTestUtil<>(
+ new SpatialLayoutTestUtil( TestIndexDescriptorFactory.uniqueForLabel( 42, 666 ), settings.settingsFor( crs ), crs ) );
}
}
diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/SpatialUniqueIndexPopulatorTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/SpatialUniqueIndexPopulatorTest.java
index 4a403d71c0a90..f11ad65339cf4 100644
--- a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/SpatialUniqueIndexPopulatorTest.java
+++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/SpatialUniqueIndexPopulatorTest.java
@@ -25,33 +25,34 @@
import org.neo4j.kernel.api.schema.index.TestIndexDescriptorFactory;
import org.neo4j.kernel.configuration.Config;
import org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig;
-import org.neo4j.kernel.impl.index.schema.config.SpaceFillingCurveSettings;
import org.neo4j.kernel.impl.index.schema.config.SpaceFillingCurveSettingsFactory;
import org.neo4j.values.storable.CoordinateReferenceSystem;
public class SpatialUniqueIndexPopulatorTest extends NativeUniqueIndexPopulatorTest
{
private static final CoordinateReferenceSystem crs = CoordinateReferenceSystem.WGS84;
- private static final SpaceFillingCurveSettings settings = new SpaceFillingCurveSettingsFactory( Config.defaults() ).settingsFor( crs );
+ private static final SpaceFillingCurveSettingsFactory settings = new SpaceFillingCurveSettingsFactory( Config.defaults() );
- private SpatialIndexFiles.SpatialFileLayout fileLayout;
+ private SpatialIndexFiles.SpatialFile spatialFile;
@Override
NativeIndexPopulator createPopulator( IndexSamplingConfig samplingConfig )
{
- fileLayout = new SpatialIndexFiles.SpatialFileLayout( crs, settings, super.getIndexFile() );
- return new SpatialIndexPopulator.PartPopulator( pageCache, fs, fileLayout, monitor, indexDescriptor, samplingConfig, new StandardConfiguration() );
+ spatialFile = new SpatialIndexFiles.SpatialFile( crs, settings, super.getIndexFile() );
+ return new SpatialIndexPopulator.PartPopulator( pageCache, fs, spatialFile.getLayoutForNewIndex(), monitor, indexDescriptor, samplingConfig,
+ new StandardConfiguration() );
}
@Override
public File getIndexFile()
{
- return fileLayout.indexFile;
+ return spatialFile.indexFile;
}
@Override
protected LayoutTestUtil createLayoutTestUtil()
{
- return new UniqueLayoutTestUtil<>( new SpatialLayoutTestUtil( TestIndexDescriptorFactory.uniqueForLabel( 42, 666 ), settings, crs ) );
+ return new UniqueLayoutTestUtil<>(
+ new SpatialLayoutTestUtil( TestIndexDescriptorFactory.uniqueForLabel( 42, 666 ), settings.settingsFor( crs ), crs ) );
}
}
diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/config/SpaceFillingCurveSettingsFactoryTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/config/SpaceFillingCurveSettingsFactoryTest.java
index 332fb053914aa..1c9579bea304e 100644
--- a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/config/SpaceFillingCurveSettingsFactoryTest.java
+++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/config/SpaceFillingCurveSettingsFactoryTest.java
@@ -153,7 +153,6 @@ private void shouldGetSettingsFor( Config config, CoordinateReferenceSystem crs,
{
SpaceFillingCurveSettingsFactory factory = new SpaceFillingCurveSettingsFactory( config );
SpaceFillingCurveSettings settings = factory.settingsFor( crs );
- assertThat( "Should not get error when getting valid settings", settings.getFailureMessage(), is( nullValue() ) );
assertThat( "Expected " + dimensions + "D for " + crs.getName(), settings.getDimensions(), equalTo( dimensions ) );
int maxLevels = maxBits / dimensions;
assertThat( "Expected maxLevels=" + maxLevels + " for " + crs.getName(), settings.getMaxLevels(), equalTo( maxLevels ) );