From 791a9e8741b57ae5b27f73cb1d64c81c468f5b97 Mon Sep 17 00:00:00 2001 From: fickludd Date: Tue, 14 Feb 2017 22:00:01 +0100 Subject: [PATCH] Pushed Index Boundary around IndexProvider API --- .../checking/index/IndexAccessors.java | 5 +- .../full/FullCheckIntegrationTest.java | 16 +-- .../kernel/api/index/SchemaIndexProvider.java | 18 +-- .../kernel/api/schema_new/SchemaBoundary.java | 4 +- .../index/AbstractDelegatingIndexProxy.java | 13 +- .../index/AbstractSwallowingIndexProxy.java | 17 +-- .../index/BatchingMultipleIndexPopulator.java | 15 +- .../impl/api/index/FailedIndexProxy.java | 13 +- .../FailedPopulatingIndexProxyFactory.java | 12 +- .../impl/api/index/FlippableIndexProxy.java | 21 +-- .../neo4j/kernel/impl/api/index/IndexMap.java | 7 +- .../impl/api/index/IndexPopulationJob.java | 13 +- .../kernel/impl/api/index/IndexProxy.java | 7 +- .../impl/api/index/IndexProxyCreator.java | 72 +++++----- .../impl/api/index/IndexingService.java | 49 ++++--- .../api/index/MultipleIndexPopulator.java | 23 ++-- .../impl/api/index/OnlineIndexProxy.java | 17 +-- .../impl/api/index/PopulatingIndexProxy.java | 16 +-- .../api/index/RebuildingIndexDescriptor.java | 17 +-- .../impl/api/index/RecoveringIndexProxy.java | 6 +- .../index/TentativeConstraintIndexProxy.java | 13 +- .../sampling/IndexSamplingController.java | 3 +- .../IndexSamplingControllerFactory.java | 7 +- .../propertydeduplication/IndexLookup.java | 4 +- .../internal/BatchInserterImpl.java | 7 +- .../api/index/IndexAccessorCompatibility.java | 14 +- .../IndexProviderCompatibilityTestSuite.java | 6 +- .../NonUniqueIndexAccessorCompatibility.java | 128 +++++------------- .../NonUniqueIndexPopulatorCompatibility.java | 21 ++- .../index/UniqueConstraintCompatibility.java | 4 +- .../UniqueIndexAccessorCompatibility.java | 14 +- .../UniqueIndexPopulatorCompatibility.java | 10 +- .../BatchingMultipleIndexPopulatorTest.java | 9 +- ...ntrolledPopulationSchemaIndexProvider.java | 10 +- .../impl/api/index/FailedIndexProxyTest.java | 8 +- .../kernel/impl/api/index/IndexCRUDIT.java | 32 ++--- .../api/index/IndexPopulationJobTest.java | 18 ++- .../impl/api/index/IndexProxyAdapter.java | 10 +- .../impl/api/index/IndexRecoveryIT.java | 53 +++----- .../index/IndexSamplingCancellationTest.java | 7 +- .../impl/api/index/IndexStatisticsTest.java | 10 +- .../impl/api/index/IndexUpdaterMapTest.java | 5 +- .../impl/api/index/IndexingServiceTest.java | 51 ++++--- .../api/index/MultipleIndexPopulatorTest.java | 14 +- .../MultipleIndexPopulatorUpdatesTest.java | 13 +- .../impl/api/index/OnlineIndexProxyTest.java | 9 +- .../index/inmemory/InMemoryIndexProvider.java | 18 +-- .../sampling/IndexSamplingControllerTest.java | 16 +-- .../sampling/OnlineIndexSamplingJobTest.java | 5 +- .../LabelScanViewNodeStoreScanTest.java | 11 +- .../batchinsert/internal/BatchInsertTest.java | 27 ++-- .../schema/LuceneSchemaIndexProvider.java | 20 ++- .../lucene/legacy/NonUniqueIndexTests.java | 6 +- .../LuceneSchemaIndexPopulatorTest.java | 3 +- .../schema/LuceneSchemaIndexProviderTest.java | 16 ++- .../org/neo4j/kernel/api/SchemaIndexHaIT.java | 13 +- 56 files changed, 385 insertions(+), 591 deletions(-) diff --git a/community/consistency-check/src/main/java/org/neo4j/consistency/checking/index/IndexAccessors.java b/community/consistency-check/src/main/java/org/neo4j/consistency/checking/index/IndexAccessors.java index 761cc8451433..7664181fe3c2 100644 --- a/community/consistency-check/src/main/java/org/neo4j/consistency/checking/index/IndexAccessors.java +++ b/community/consistency-check/src/main/java/org/neo4j/consistency/checking/index/IndexAccessors.java @@ -77,10 +77,7 @@ public IndexAccessors( SchemaIndexProvider provider, for ( IndexRule indexRule : indexRules ) { long indexId = indexRule.getId(); - IndexConfiguration indexConfig = IndexConfiguration.of( indexRule ); - accessors.put( indexId, provider.getOnlineAccessor( indexId, - IndexBoundary.map( indexRule.getIndexDescriptor() ), - indexConfig, samplingConfig ) ); + accessors.put( indexId, provider.getOnlineAccessor( indexId, indexRule.getIndexDescriptor(), samplingConfig ) ); } } diff --git a/community/consistency-check/src/test/java/org/neo4j/consistency/checking/full/FullCheckIntegrationTest.java b/community/consistency-check/src/test/java/org/neo4j/consistency/checking/full/FullCheckIntegrationTest.java index 8347126f33e6..be379548f177 100644 --- a/community/consistency-check/src/test/java/org/neo4j/consistency/checking/full/FullCheckIntegrationTest.java +++ b/community/consistency-check/src/test/java/org/neo4j/consistency/checking/full/FullCheckIntegrationTest.java @@ -414,11 +414,9 @@ public void shouldNotReportIndexInconsistenciesIfIndexIsFailed() throws Exceptio while ( rules.hasNext() ) { IndexRule rule = rules.next(); - IndexDescriptor descriptor = IndexBoundary.map( rule.getIndexDescriptor() ); - IndexConfiguration indexConfig = IndexConfiguration.NON_UNIQUE; IndexSamplingConfig samplingConfig = new IndexSamplingConfig( Config.empty() ); IndexPopulator populator = - storeAccess.indexes().getPopulator( rule.getId(), descriptor, indexConfig, samplingConfig ); + storeAccess.indexes().getPopulator( rule.getId(), rule.getIndexDescriptor(), samplingConfig ); populator.markAsFailed( "Oh noes! I was a shiny index and then I was failed" ); populator.close( false ); @@ -530,8 +528,7 @@ public void shouldReportNodesThatAreNotIndexed() throws Exception { IndexRule indexRule = indexRuleIterator.next(); IndexAccessor accessor = fixture.directStoreAccess().indexes().getOnlineAccessor( - indexRule.getId(), IndexBoundary.map( indexRule.getIndexDescriptor() ), - IndexConfiguration.of( indexRule ), samplingConfig ); + indexRule.getId(), indexRule.getIndexDescriptor(), samplingConfig ); IndexUpdater updater = accessor.newUpdater( IndexUpdateMode.ONLINE ); updater.remove( asPrimitiveLongSet( indexedNodes ) ); updater.close(); @@ -550,19 +547,14 @@ public void shouldReportNodesThatAreNotIndexed() throws Exception public void shouldReportNodesWithDuplicatePropertyValueInUniqueIndex() throws Exception { // given - IndexConfiguration indexConfig = IndexConfiguration.NON_UNIQUE; IndexSamplingConfig samplingConfig = new IndexSamplingConfig( Config.empty() ); Iterator indexRuleIterator = new SchemaStorage( fixture.directStoreAccess().nativeStores().getSchemaStore() ).indexesGetAll(); while ( indexRuleIterator.hasNext() ) { IndexRule indexRule = indexRuleIterator.next(); - IndexAccessor accessor = fixture.directStoreAccess() - .indexes() - .getOnlineAccessor( indexRule.getId(), - IndexBoundary.map( indexRule.getIndexDescriptor() ), - indexConfig, - samplingConfig ); + IndexAccessor accessor = fixture.directStoreAccess().indexes() + .getOnlineAccessor( indexRule.getId(), indexRule.getIndexDescriptor(), samplingConfig ); IndexUpdater updater = accessor.newUpdater( IndexUpdateMode.ONLINE ); updater.process( IndexEntryUpdate.add( 42, indexRule.getIndexDescriptor(), "value" ) ); updater.close(); diff --git a/community/kernel/src/main/java/org/neo4j/kernel/api/index/SchemaIndexProvider.java b/community/kernel/src/main/java/org/neo4j/kernel/api/index/SchemaIndexProvider.java index 7b8eb9d7a3d1..810a2adb7f7c 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/api/index/SchemaIndexProvider.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/api/index/SchemaIndexProvider.java @@ -26,7 +26,7 @@ import org.neo4j.helpers.collection.Iterators; import org.neo4j.io.fs.FileSystemAbstraction; import org.neo4j.io.pagecache.PageCache; -import org.neo4j.kernel.api.schema.IndexDescriptor; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; import org.neo4j.kernel.impl.api.index.IndexingService; import org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig; import org.neo4j.kernel.impl.api.scan.LabelScanStoreProvider; @@ -43,7 +43,7 @@ * * When an index rule is added, the {@link IndexingService} is notified. It will, in turn, ask * your {@link SchemaIndexProvider} for a\ - * {@link #getPopulator(long, IndexDescriptor, IndexConfiguration, IndexSamplingConfig) batch index writer}. + * {@link #getPopulator(long, NewIndexDescriptor, IndexSamplingConfig) batch index writer}. * * A background index job is triggered, and all existing data that applies to the new rule, as well as new data * from the "outside", will be inserted using the writer. You are guaranteed that usage of this writer, @@ -88,7 +88,7 @@ *

Online operation

* * Once the index is online, the database will move to using the - * {@link #getOnlineAccessor(long, IndexDescriptor, IndexConfiguration, IndexSamplingConfig) online accessor} to + * {@link #getOnlineAccessor(long, NewIndexDescriptor, IndexSamplingConfig) online accessor} to * write to the index. */ public abstract class SchemaIndexProvider extends LifecycleAdapter implements Comparable @@ -100,14 +100,14 @@ public abstract class SchemaIndexProvider extends LifecycleAdapter implements Co private final IndexPopulator singlePopulator = new IndexPopulator.Adapter(); @Override - public IndexAccessor getOnlineAccessor( long indexId, IndexDescriptor descriptor, - IndexConfiguration config, IndexSamplingConfig samplingConfig ) + public IndexAccessor getOnlineAccessor( long indexId, NewIndexDescriptor descriptor, + IndexSamplingConfig samplingConfig ) { return singleWriter; } @Override - public IndexPopulator getPopulator( long indexId, IndexDescriptor descriptor, IndexConfiguration config, + public IndexPopulator getPopulator( long indexId, NewIndexDescriptor descriptor, IndexSamplingConfig samplingConfig ) { return singlePopulator; @@ -146,14 +146,14 @@ protected SchemaIndexProvider( Descriptor descriptor, int priority ) /** * Used for initially populating a created index, using batch insertion. */ - public abstract IndexPopulator getPopulator( long indexId, IndexDescriptor descriptor, IndexConfiguration config, + public abstract IndexPopulator getPopulator( long indexId, NewIndexDescriptor descriptor, IndexSamplingConfig samplingConfig ); /** * Used for updating an index once initial population has completed. */ - public abstract IndexAccessor getOnlineAccessor( long indexId, IndexDescriptor descriptor, - IndexConfiguration config, IndexSamplingConfig samplingConfig ) throws IOException; + public abstract IndexAccessor getOnlineAccessor( long indexId, NewIndexDescriptor descriptor, + IndexSamplingConfig samplingConfig ) throws IOException; /** * Returns a failure previously gotten from {@link IndexPopulator#markAsFailed(String)} diff --git a/community/kernel/src/main/java/org/neo4j/kernel/api/schema_new/SchemaBoundary.java b/community/kernel/src/main/java/org/neo4j/kernel/api/schema_new/SchemaBoundary.java index 10e451fa6dee..86fc5c31dc3a 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/api/schema_new/SchemaBoundary.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/api/schema_new/SchemaBoundary.java @@ -45,8 +45,8 @@ public static RelationTypeSchemaDescriptor map( RelationshipPropertyDescriptor d return SchemaDescriptorFactory.forRelType( descriptor.getRelationshipTypeId(), descriptor.getPropertyKeyId() ); } - public static NodePropertyDescriptor map( LabelSchemaDescriptor descriptor ) + public static NodePropertyDescriptor map( LabelSchemaDescriptor schema ) { - return IndexDescriptorFactory.getNodePropertyDescriptor( descriptor.getLabelId(), descriptor.getPropertyIds() ); + return IndexDescriptorFactory.getNodePropertyDescriptor( schema.getLabelId(), schema.getPropertyIds() ); } } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/AbstractDelegatingIndexProxy.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/AbstractDelegatingIndexProxy.java index dbc4551ec948..fde41310ee69 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/AbstractDelegatingIndexProxy.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/AbstractDelegatingIndexProxy.java @@ -28,13 +28,12 @@ import org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException; import org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException; import org.neo4j.kernel.api.exceptions.index.IndexPopulationFailedKernelException; -import org.neo4j.kernel.api.exceptions.schema.UniquePropertyValueValidationException; -import org.neo4j.kernel.api.index.IndexConfiguration; -import org.neo4j.kernel.api.schema.IndexDescriptor; +import org.neo4j.kernel.api.exceptions.schema.ConstraintVerificationFailedKernelException; import org.neo4j.kernel.api.index.IndexUpdater; import org.neo4j.kernel.api.index.InternalIndexState; import org.neo4j.kernel.api.index.PropertyAccessor; import org.neo4j.kernel.api.index.SchemaIndexProvider; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; import org.neo4j.storageengine.api.schema.IndexReader; import org.neo4j.storageengine.api.schema.PopulationProgress; @@ -67,7 +66,7 @@ public InternalIndexState getState() } @Override - public IndexDescriptor getDescriptor() + public NewIndexDescriptor getDescriptor() { return getDelegate().getDescriptor(); } @@ -144,12 +143,6 @@ public ResourceIterator snapshotFiles() throws IOException return getDelegate().snapshotFiles(); } - @Override - public IndexConfiguration config() - { - return getDelegate().config(); - } - @Override public void verifyDeferredConstraints( PropertyAccessor accessor ) throws IndexEntryConflictException, IOException { diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/AbstractSwallowingIndexProxy.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/AbstractSwallowingIndexProxy.java index c6a6b589e3c9..c341d5085432 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/AbstractSwallowingIndexProxy.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/AbstractSwallowingIndexProxy.java @@ -25,6 +25,7 @@ import org.neo4j.kernel.api.schema.IndexDescriptor; import org.neo4j.kernel.api.index.IndexUpdater; import org.neo4j.kernel.api.index.SchemaIndexProvider; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; import org.neo4j.storageengine.api.schema.IndexReader; import org.neo4j.storageengine.api.schema.PopulationProgress; import org.neo4j.kernel.impl.api.index.updater.SwallowingIndexUpdater; @@ -33,18 +34,16 @@ public abstract class AbstractSwallowingIndexProxy implements IndexProxy { - private final IndexDescriptor descriptor; + private final NewIndexDescriptor descriptor; private final SchemaIndexProvider.Descriptor providerDescriptor; private final IndexPopulationFailure populationFailure; - private final IndexConfiguration configuration; - public AbstractSwallowingIndexProxy( IndexDescriptor descriptor, SchemaIndexProvider.Descriptor providerDescriptor, - IndexPopulationFailure populationFailure, IndexConfiguration configuration ) + public AbstractSwallowingIndexProxy( NewIndexDescriptor descriptor, + SchemaIndexProvider.Descriptor providerDescriptor, IndexPopulationFailure populationFailure ) { this.descriptor = descriptor; this.providerDescriptor = providerDescriptor; this.populationFailure = populationFailure; - this.configuration = configuration; } @Override @@ -83,7 +82,7 @@ public void flush() } @Override - public IndexDescriptor getDescriptor() + public NewIndexDescriptor getDescriptor() { return descriptor; } @@ -105,10 +104,4 @@ public IndexReader newReader() { throw new UnsupportedOperationException(); } - - @Override - public IndexConfiguration config() - { - return configuration; - } } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/BatchingMultipleIndexPopulator.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/BatchingMultipleIndexPopulator.java index 78de55f2afa8..8345af8fc447 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/BatchingMultipleIndexPopulator.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/BatchingMultipleIndexPopulator.java @@ -40,11 +40,11 @@ import org.neo4j.helpers.Exceptions; import org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException; import org.neo4j.kernel.api.exceptions.index.IndexPopulationFailedKernelException; -import org.neo4j.kernel.api.index.IndexConfiguration; import org.neo4j.kernel.api.index.IndexEntryUpdate; import org.neo4j.kernel.api.schema.IndexDescriptor; import org.neo4j.kernel.api.index.IndexPopulator; import org.neo4j.kernel.api.index.SchemaIndexProvider; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; import org.neo4j.logging.LogProvider; import org.neo4j.storageengine.api.schema.PopulationProgress; import org.neo4j.unsafe.impl.internal.dragons.FeatureToggles; @@ -121,10 +121,10 @@ public StoreScan indexAllNodes() @Override protected IndexPopulation createPopulation( IndexPopulator populator, long indexId, - IndexDescriptor descriptor, IndexConfiguration config, SchemaIndexProvider.Descriptor providerDescriptor, + NewIndexDescriptor descriptor, SchemaIndexProvider.Descriptor providerDescriptor, FlippableIndexProxy flipper, FailedIndexProxyFactory failedIndexProxyFactory, String indexUserDescription ) { - return new BatchingIndexPopulation( populator, indexId, descriptor, config, providerDescriptor, flipper, + return new BatchingIndexPopulation( populator, indexId, descriptor, providerDescriptor, flipper, failedIndexProxyFactory, indexUserDescription ); } @@ -338,12 +338,11 @@ private int getNumberOfPopulationWorkers() */ private class BatchingIndexPopulation extends IndexPopulation { - BatchingIndexPopulation( IndexPopulator populator, long indexId, IndexDescriptor descriptor, - IndexConfiguration config, SchemaIndexProvider.Descriptor providerDescriptor, - FlippableIndexProxy flipper, FailedIndexProxyFactory failedIndexProxyFactory, - String indexUserDescription ) + BatchingIndexPopulation( IndexPopulator populator, long indexId, NewIndexDescriptor descriptor, + SchemaIndexProvider.Descriptor providerDescriptor, FlippableIndexProxy flipper, + FailedIndexProxyFactory failedIndexProxyFactory, String indexUserDescription ) { - super( populator, indexId, descriptor, config, providerDescriptor, flipper, failedIndexProxyFactory, + super( populator, indexId, descriptor, providerDescriptor, flipper, failedIndexProxyFactory, indexUserDescription ); } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/FailedIndexProxy.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/FailedIndexProxy.java index 7eee9d33738c..39bdf138cd01 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/FailedIndexProxy.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/FailedIndexProxy.java @@ -30,6 +30,8 @@ import org.neo4j.kernel.api.index.IndexPopulator; import org.neo4j.kernel.api.index.InternalIndexState; import org.neo4j.kernel.api.index.SchemaIndexProvider; +import org.neo4j.kernel.api.schema_new.SchemaBoundary; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; import org.neo4j.logging.Log; import org.neo4j.logging.LogProvider; @@ -43,8 +45,7 @@ public class FailedIndexProxy extends AbstractSwallowingIndexProxy private final IndexCountsRemover indexCountsRemover; private final Log log; - public FailedIndexProxy(IndexDescriptor descriptor, - IndexConfiguration configuration, + public FailedIndexProxy( NewIndexDescriptor descriptor, SchemaIndexProvider.Descriptor providerDescriptor, String indexUserDescription, IndexPopulator populator, @@ -52,7 +53,7 @@ public FailedIndexProxy(IndexDescriptor descriptor, IndexCountsRemover indexCountsRemover, LogProvider logProvider ) { - super( descriptor, providerDescriptor, populationFailure, configuration ); + super( descriptor, providerDescriptor, populationFailure ); this.populator = populator; this.indexUserDescription = indexUserDescription; this.indexCountsRemover = indexCountsRemover; @@ -79,7 +80,8 @@ public InternalIndexState getState() @Override public boolean awaitStoreScanCompleted() throws IndexPopulationFailedKernelException { - throw getPopulationFailure().asIndexPopulationFailure( getDescriptor().descriptor(), indexUserDescription ); + throw getPopulationFailure().asIndexPopulationFailure( + SchemaBoundary.map( getDescriptor().schema() ), indexUserDescription ); } @Override @@ -91,7 +93,8 @@ public void activate() @Override public void validate() throws IndexPopulationFailedKernelException { - throw getPopulationFailure().asIndexPopulationFailure( getDescriptor().descriptor(), indexUserDescription ); + throw getPopulationFailure().asIndexPopulationFailure( + SchemaBoundary.map( getDescriptor().schema() ), indexUserDescription ); } @Override diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/FailedPopulatingIndexProxyFactory.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/FailedPopulatingIndexProxyFactory.java index ea3dd7b98a5c..d94144a678df 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/FailedPopulatingIndexProxyFactory.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/FailedPopulatingIndexProxyFactory.java @@ -19,26 +19,23 @@ */ package org.neo4j.kernel.impl.api.index; -import org.neo4j.kernel.api.index.IndexConfiguration; -import org.neo4j.kernel.api.schema.IndexDescriptor; import org.neo4j.kernel.api.index.IndexPopulator; import org.neo4j.kernel.api.index.SchemaIndexProvider; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; import org.neo4j.logging.LogProvider; import static org.neo4j.kernel.impl.api.index.IndexPopulationFailure.failure; public class FailedPopulatingIndexProxyFactory implements FailedIndexProxyFactory { - private final IndexDescriptor descriptor; - private final IndexConfiguration configuration; + private final NewIndexDescriptor descriptor; private final SchemaIndexProvider.Descriptor providerDescriptor; private final IndexPopulator populator; private final String indexUserDescription; private final IndexCountsRemover indexCountsRemover; private final LogProvider logProvider; - FailedPopulatingIndexProxyFactory( IndexDescriptor descriptor, - IndexConfiguration configuration, + FailedPopulatingIndexProxyFactory( NewIndexDescriptor descriptor, SchemaIndexProvider.Descriptor providerDescriptor, IndexPopulator populator, String indexUserDescription, @@ -46,7 +43,6 @@ public class FailedPopulatingIndexProxyFactory implements FailedIndexProxyFactor LogProvider logProvider ) { this.descriptor = descriptor; - this.configuration = configuration; this.providerDescriptor = providerDescriptor; this.populator = populator; this.indexUserDescription = indexUserDescription; @@ -59,7 +55,7 @@ public IndexProxy create( Throwable failure ) { return new FailedIndexProxy( - descriptor, configuration, providerDescriptor, + descriptor, providerDescriptor, indexUserDescription, populator, failure( failure ), indexCountsRemover, logProvider ); } } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/FlippableIndexProxy.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/FlippableIndexProxy.java index 7f6597ccec9c..c0cee539d64c 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/FlippableIndexProxy.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/FlippableIndexProxy.java @@ -35,13 +35,12 @@ import org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException; import org.neo4j.kernel.api.exceptions.index.IndexPopulationFailedKernelException; import org.neo4j.kernel.api.exceptions.index.IndexProxyAlreadyClosedKernelException; -import org.neo4j.kernel.api.exceptions.schema.UniquePropertyValueValidationException; -import org.neo4j.kernel.api.index.IndexConfiguration; -import org.neo4j.kernel.api.schema.IndexDescriptor; +import org.neo4j.kernel.api.exceptions.schema.ConstraintVerificationFailedKernelException; import org.neo4j.kernel.api.index.IndexUpdater; import org.neo4j.kernel.api.index.InternalIndexState; import org.neo4j.kernel.api.index.PropertyAccessor; import org.neo4j.kernel.api.index.SchemaIndexProvider; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; import org.neo4j.kernel.impl.api.index.updater.DelegatingIndexUpdater; import org.neo4j.storageengine.api.schema.IndexReader; import org.neo4j.storageengine.api.schema.PopulationProgress; @@ -211,7 +210,7 @@ private static void barge( ReentrantReadWriteLock.ReadLock lock ) } @Override - public IndexDescriptor getDescriptor() + public NewIndexDescriptor getDescriptor() { lock.readLock().lock(); try @@ -415,20 +414,6 @@ public void flip( Callable actionDuringFlip, FailedIndexProxyFactory failu } } - @Override - public IndexConfiguration config() - { - lock.readLock().lock(); - try - { - return delegate.config(); - } - finally - { - lock.readLock().unlock(); - } - } - @Override public String toString() { diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/IndexMap.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/IndexMap.java index 9793c9bb484f..8b3211b23c41 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/IndexMap.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/IndexMap.java @@ -25,6 +25,7 @@ import java.util.function.BiConsumer; import org.neo4j.kernel.api.schema.IndexDescriptor; +import org.neo4j.kernel.api.schema_new.index.IndexBoundary; /** * Bundles various mappings to IndexProxy. Used by IndexingService via IndexMapReference. @@ -68,8 +69,8 @@ public long getIndexId( IndexDescriptor descriptor ) public void putIndexProxy( long indexId, IndexProxy indexProxy ) { indexesById.put( indexId, indexProxy ); - indexesByDescriptor.put( indexProxy.getDescriptor(), indexProxy ); - indexIdsByDescriptor.put( indexProxy.getDescriptor(), indexId ); + indexesByDescriptor.put( IndexBoundary.map( indexProxy.getDescriptor() ), indexProxy ); + indexIdsByDescriptor.put( IndexBoundary.map( indexProxy.getDescriptor() ), indexId ); } public IndexProxy removeIndexProxy( long indexId ) @@ -77,7 +78,7 @@ public IndexProxy removeIndexProxy( long indexId ) IndexProxy removedProxy = indexesById.remove( indexId ); if ( null != removedProxy ) { - indexesByDescriptor.remove( removedProxy.getDescriptor() ); + indexesByDescriptor.remove( IndexBoundary.map( removedProxy.getDescriptor() ) ); } return removedProxy; } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/IndexPopulationJob.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/IndexPopulationJob.java index bb3a976c888e..bd07fbbc4f0b 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/IndexPopulationJob.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/IndexPopulationJob.java @@ -24,11 +24,10 @@ import org.neo4j.function.Suppliers; import org.neo4j.kernel.api.exceptions.index.IndexPopulationFailedKernelException; -import org.neo4j.kernel.api.index.IndexConfiguration; import org.neo4j.kernel.api.index.IndexEntryUpdate; -import org.neo4j.kernel.api.schema.IndexDescriptor; import org.neo4j.kernel.api.index.IndexPopulator; import org.neo4j.kernel.api.index.SchemaIndexProvider; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; import org.neo4j.storageengine.api.schema.PopulationProgress; import static java.lang.Thread.currentThread; @@ -37,7 +36,7 @@ /** * A background job for initially populating one or more index over existing data in the database. * Use provided store view to scan store. Participating {@link IndexPopulator} are added with - * {@link #addPopulator(IndexPopulator, long, IndexDescriptor, IndexConfiguration, org.neo4j.kernel.api.index.SchemaIndexProvider.Descriptor, String, FlippableIndexProxy, FailedIndexProxyFactory)} + * {@link #addPopulator(IndexPopulator, long, NewIndexDescriptor, org.neo4j.kernel.api.index.SchemaIndexProvider.Descriptor, String, FlippableIndexProxy, FailedIndexProxyFactory)} * before {@link #run() running} this job. */ public class IndexPopulationJob implements Runnable @@ -67,8 +66,7 @@ public IndexPopulationJob( IndexStoreView storeView, * be added before calling {@link #run()}. * * @param populator {@link IndexPopulator} to participate. - * @param descriptor {@link IndexDescriptor} describing the index. - * @param config {@link IndexConfiguration} for the index. + * @param descriptor {@link NewIndexDescriptor} describing the index. * @param providerDescriptor provider of this index. * @param indexUserDescription user description of this index. * @param flipper {@link FlippableIndexProxy} to call after a successful population. @@ -76,15 +74,14 @@ public IndexPopulationJob( IndexStoreView storeView, */ public void addPopulator( IndexPopulator populator, long indexId, - IndexDescriptor descriptor, - IndexConfiguration config, + NewIndexDescriptor descriptor, SchemaIndexProvider.Descriptor providerDescriptor, String indexUserDescription , FlippableIndexProxy flipper, FailedIndexProxyFactory failedIndexProxyFactory ) { assert storeScan == null : "Population have already started, too late to add populators at this point"; - this.multiPopulator.addPopulator( populator, indexId, descriptor, providerDescriptor, config, flipper, + this.multiPopulator.addPopulator( populator, indexId, descriptor, providerDescriptor, flipper, failedIndexProxyFactory, indexUserDescription ); } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/IndexProxy.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/IndexProxy.java index b6263d20ebf7..a3ac4f5cc227 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/IndexProxy.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/IndexProxy.java @@ -30,13 +30,12 @@ import org.neo4j.kernel.api.exceptions.index.IndexPopulationFailedKernelException; import org.neo4j.kernel.api.exceptions.schema.UniquePropertyValueValidationException; import org.neo4j.kernel.api.index.IndexAccessor; -import org.neo4j.kernel.api.index.IndexConfiguration; -import org.neo4j.kernel.api.schema.IndexDescriptor; import org.neo4j.kernel.api.index.IndexPopulator; import org.neo4j.kernel.api.index.IndexUpdater; import org.neo4j.kernel.api.index.InternalIndexState; import org.neo4j.kernel.api.index.PropertyAccessor; import org.neo4j.kernel.api.index.SchemaIndexProvider; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; import org.neo4j.storageengine.api.schema.IndexReader; import org.neo4j.storageengine.api.schema.PopulationProgress; @@ -77,7 +76,7 @@ public interface IndexProxy */ Future close() throws IOException; - IndexDescriptor getDescriptor(); + NewIndexDescriptor getDescriptor(); SchemaIndexProvider.Descriptor getProviderDescriptor(); @@ -110,8 +109,6 @@ public interface IndexProxy ResourceIterator snapshotFiles() throws IOException; - IndexConfiguration config(); - default void verifyDeferredConstraints( PropertyAccessor accessor ) throws IndexEntryConflictException, IOException { throw new IllegalStateException( this.toString() ); diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/IndexProxyCreator.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/IndexProxyCreator.java index 53475aa04b9c..3a829677bd2f 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/IndexProxyCreator.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/IndexProxyCreator.java @@ -23,10 +23,9 @@ import org.neo4j.kernel.api.TokenNameLookup; import org.neo4j.kernel.api.index.IndexAccessor; -import org.neo4j.kernel.api.index.IndexConfiguration; -import org.neo4j.kernel.api.schema.IndexDescriptor; import org.neo4j.kernel.api.index.IndexPopulator; import org.neo4j.kernel.api.index.SchemaIndexProvider; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; import org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig; import org.neo4j.logging.LogProvider; @@ -57,9 +56,8 @@ public IndexProxyCreator( IndexSamplingConfig samplingConfig, } public IndexProxy createPopulatingIndexProxy( final long ruleId, - final IndexDescriptor descriptor, + final NewIndexDescriptor descriptor, final SchemaIndexProvider.Descriptor providerDescriptor, - IndexConfiguration config, final boolean flipToTentative, final IndexingService.Monitor monitor, final IndexPopulationJob populationJob ) throws IOException @@ -68,12 +66,10 @@ public IndexProxy createPopulatingIndexProxy( final long ruleId, // TODO: This is here because there is a circular dependency from PopulatingIndexProxy to FlippableIndexProxy final String indexUserDescription = indexUserDescription( descriptor, providerDescriptor ); - IndexPopulator populator = populatorFromProvider( providerDescriptor, ruleId, descriptor, config, - samplingConfig ); + IndexPopulator populator = populatorFromProvider( providerDescriptor, ruleId, descriptor, samplingConfig ); FailedIndexProxyFactory failureDelegateFactory = new FailedPopulatingIndexProxyFactory( descriptor, - config, providerDescriptor, populator, indexUserDescription, @@ -82,9 +78,9 @@ public IndexProxy createPopulatingIndexProxy( final long ruleId, ); PopulatingIndexProxy populatingIndex = - new PopulatingIndexProxy( descriptor, config, providerDescriptor, populationJob ); + new PopulatingIndexProxy( descriptor, providerDescriptor, populationJob ); - populationJob.addPopulator( populator, ruleId, descriptor, config, providerDescriptor, indexUserDescription, + populationJob.addPopulator( populator, ruleId, descriptor, providerDescriptor, indexUserDescription, flipper, failureDelegateFactory ); flipper.flipTo( populatingIndex ); @@ -92,10 +88,13 @@ public IndexProxy createPopulatingIndexProxy( final long ruleId, // Prepare for flipping to online mode flipper.setFlipTarget( () -> { monitor.populationCompleteOn( descriptor ); - OnlineIndexProxy onlineProxy = new OnlineIndexProxy(ruleId, - descriptor, config, onlineAccessorFromProvider( providerDescriptor, ruleId, - descriptor, config, samplingConfig ), storeView, providerDescriptor, true - ); + OnlineIndexProxy onlineProxy = + new OnlineIndexProxy( + ruleId, + descriptor, + onlineAccessorFromProvider( providerDescriptor, ruleId, descriptor, samplingConfig ), + storeView, + providerDescriptor, true ); if ( flipToTentative ) { return new TentativeConstraintIndexProxy( flipper, onlineProxy ); @@ -106,28 +105,24 @@ descriptor, config, onlineAccessorFromProvider( providerDescriptor, ruleId, return new ContractCheckingIndexProxy( flipper, false ); } - public IndexProxy createRecoveringIndexProxy( IndexDescriptor descriptor, - SchemaIndexProvider.Descriptor providerDescriptor, - boolean constraint ) + public IndexProxy createRecoveringIndexProxy( NewIndexDescriptor descriptor, + SchemaIndexProvider.Descriptor providerDescriptor ) { - IndexConfiguration configuration = IndexConfiguration.of( constraint ); - IndexProxy proxy = new RecoveringIndexProxy( descriptor, providerDescriptor, configuration ); + IndexProxy proxy = new RecoveringIndexProxy( descriptor, providerDescriptor ); return new ContractCheckingIndexProxy( proxy, true ); } public IndexProxy createOnlineIndexProxy( long ruleId, - IndexDescriptor descriptor, - SchemaIndexProvider.Descriptor providerDescriptor, - boolean unique ) + NewIndexDescriptor descriptor, + SchemaIndexProvider.Descriptor providerDescriptor ) { // TODO Hook in version verification/migration calls to the SchemaIndexProvider here try { - IndexConfiguration config = IndexConfiguration.of( unique ); IndexAccessor onlineAccessor = - onlineAccessorFromProvider( providerDescriptor, ruleId, descriptor, config, samplingConfig ); + onlineAccessorFromProvider( providerDescriptor, ruleId, descriptor, samplingConfig ); IndexProxy proxy; - proxy = new OnlineIndexProxy( ruleId, descriptor, config, onlineAccessor, storeView, providerDescriptor, false ); + proxy = new OnlineIndexProxy( ruleId, descriptor, onlineAccessor, storeView, providerDescriptor, false ); proxy = new ContractCheckingIndexProxy( proxy, true ); return proxy; } @@ -136,24 +131,21 @@ public IndexProxy createOnlineIndexProxy( long ruleId, logProvider.getLog( getClass() ).error( "Failed to open index: " + ruleId + " (" + descriptor.userDescription( tokenNameLookup ) + "), requesting re-population.", e ); - return createRecoveringIndexProxy( descriptor, providerDescriptor, unique ); + return createRecoveringIndexProxy( descriptor, providerDescriptor ); } } public IndexProxy createFailedIndexProxy( long ruleId, - IndexDescriptor descriptor, + NewIndexDescriptor descriptor, SchemaIndexProvider.Descriptor providerDescriptor, - boolean unique, IndexPopulationFailure populationFailure ) { - IndexConfiguration config = IndexConfiguration.of( unique ); IndexPopulator indexPopulator = - populatorFromProvider( providerDescriptor, ruleId, descriptor, config, samplingConfig ); - String indexUserDescription = indexUserDescription(descriptor, providerDescriptor); + populatorFromProvider( providerDescriptor, ruleId, descriptor, samplingConfig ); + String indexUserDescription = indexUserDescription( descriptor, providerDescriptor ); IndexProxy proxy; proxy = new FailedIndexProxy( descriptor, - config, providerDescriptor, indexUserDescription, indexPopulator, @@ -165,25 +157,25 @@ public IndexProxy createFailedIndexProxy( long ruleId, return proxy; } - private String indexUserDescription( final IndexDescriptor descriptor, + private String indexUserDescription( final NewIndexDescriptor descriptor, final SchemaIndexProvider.Descriptor providerDescriptor ) { - return format( "%s [provider: %s]", descriptor.userDescription( tokenNameLookup ), providerDescriptor.toString() ); + return format( "%s [provider: %s]", + descriptor.schema().userDescription( tokenNameLookup ), providerDescriptor.toString() ); } private IndexPopulator populatorFromProvider( SchemaIndexProvider.Descriptor providerDescriptor, long ruleId, - IndexDescriptor descriptor, IndexConfiguration indexConfig, - IndexSamplingConfig samplingConfig ) + NewIndexDescriptor descriptor, IndexSamplingConfig samplingConfig ) { SchemaIndexProvider indexProvider = providerMap.apply( providerDescriptor ); - return indexProvider.getPopulator( ruleId, descriptor, indexConfig, samplingConfig ); + return indexProvider.getPopulator( ruleId, descriptor, samplingConfig ); } - private IndexAccessor onlineAccessorFromProvider( SchemaIndexProvider.Descriptor providerDescriptor, long ruleId, - IndexDescriptor descriptor, IndexConfiguration indexConfig, IndexSamplingConfig samplingConfig ) - throws IOException + private IndexAccessor onlineAccessorFromProvider( SchemaIndexProvider.Descriptor providerDescriptor, + long ruleId, NewIndexDescriptor descriptor, + IndexSamplingConfig samplingConfig ) throws IOException { SchemaIndexProvider indexProvider = providerMap.apply( providerDescriptor ); - return indexProvider.getOnlineAccessor( ruleId, descriptor, indexConfig, samplingConfig ); + return indexProvider.getOnlineAccessor( ruleId, descriptor, samplingConfig ); } } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/IndexingService.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/IndexingService.java index e6d8b6bff11d..a8c316a7fd1e 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/IndexingService.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/IndexingService.java @@ -41,8 +41,7 @@ import org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException; import org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException; import org.neo4j.kernel.api.exceptions.index.IndexPopulationFailedKernelException; -import org.neo4j.kernel.api.exceptions.schema.UniquePropertyValueValidationException; -import org.neo4j.kernel.api.index.IndexConfiguration; +import org.neo4j.kernel.api.exceptions.schema.ConstraintVerificationFailedKernelException; import org.neo4j.kernel.api.index.IndexEntryUpdate; import org.neo4j.kernel.api.schema.IndexDescriptor; import org.neo4j.kernel.api.index.IndexUpdater; @@ -51,6 +50,7 @@ import org.neo4j.kernel.api.index.SchemaIndexProvider; import org.neo4j.kernel.api.index.SchemaIndexProvider.Descriptor; import org.neo4j.kernel.api.schema_new.index.IndexBoundary; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; import org.neo4j.kernel.impl.api.index.sampling.IndexSamplingController; import org.neo4j.kernel.impl.api.index.sampling.IndexSamplingMode; import org.neo4j.kernel.impl.store.UnderlyingStorageException; @@ -118,11 +118,11 @@ public interface Monitor void appliedRecoveredData( Iterable updates ); - void populationCompleteOn( IndexDescriptor descriptor ); + void populationCompleteOn( NewIndexDescriptor descriptor ); void indexPopulationScanComplete(); - void awaitingPopulationOfRecoveredIndex( long indexId, IndexDescriptor descriptor ); + void awaitingPopulationOfRecoveredIndex( long indexId, NewIndexDescriptor descriptor ); } public static class MonitorAdapter implements Monitor @@ -138,7 +138,7 @@ public void applyingRecoveredData( PrimitiveLongSet recoveredNodeIds ) } @Override - public void populationCompleteOn( IndexDescriptor descriptor ) + public void populationCompleteOn( NewIndexDescriptor descriptor ) { // Do nothing } @@ -148,7 +148,7 @@ public void indexPopulationScanComplete() } @Override - public void awaitingPopulationOfRecoveredIndex( long indexId, IndexDescriptor descriptor ) + public void awaitingPopulationOfRecoveredIndex( long indexId, NewIndexDescriptor descriptor ) { // Do nothing } } @@ -198,38 +198,37 @@ public void init() IndexProxy indexProxy; long indexId = indexRule.getId(); - IndexDescriptor descriptor = IndexBoundary.map( indexRule.getIndexDescriptor() ); + NewIndexDescriptor descriptor = indexRule.getIndexDescriptor(); SchemaIndexProvider.Descriptor providerDescriptor = indexRule.getProviderDescriptor(); SchemaIndexProvider provider = providerMap.apply( providerDescriptor ); InternalIndexState initialState = provider.getInitialState( indexId ); log.info( indexStateInfo( "init", indexId, initialState, descriptor ) ); - boolean constraint = indexRule.canSupportUniqueConstraint(); + boolean constraintIndex = indexRule.canSupportUniqueConstraint(); switch ( initialState ) { case ONLINE: indexProxy = - indexProxyCreator.createOnlineIndexProxy( indexId, descriptor, providerDescriptor, constraint ); + indexProxyCreator.createOnlineIndexProxy( indexId, descriptor, providerDescriptor ); break; case POPULATING: // The database was shut down during population, or a crash has occurred, or some other sad thing. - if ( constraint && indexRule.getOwningConstraint() == null ) + if ( constraintIndex && indexRule.getOwningConstraint() == null ) { // don't bother rebuilding if we are going to throw the index away anyhow indexProxy = indexProxyCreator.createFailedIndexProxy( - indexId, descriptor, providerDescriptor, constraint, + indexId, descriptor, providerDescriptor, failure( "Constraint for index was not committed." ) ); } else { - indexProxy = indexProxyCreator - .createRecoveringIndexProxy( descriptor, providerDescriptor, constraint ); + indexProxy = indexProxyCreator.createRecoveringIndexProxy( descriptor, providerDescriptor ); } break; case FAILED: IndexPopulationFailure failure = failure( provider.getPopulationFailure( indexId ) ); indexProxy = indexProxyCreator - .createFailedIndexProxy( indexId, descriptor, providerDescriptor, constraint, failure ); + .createFailedIndexProxy( indexId, descriptor, providerDescriptor, failure ); break; default: throw new IllegalArgumentException( "" + initialState ); @@ -254,7 +253,7 @@ public void start() throws Exception // Find all indexes that are not already online, do not require rebuilding, and create them indexMap.foreachIndexProxy( ( indexId, proxy ) -> { InternalIndexState state = proxy.getState(); - IndexDescriptor descriptor = proxy.getDescriptor(); + NewIndexDescriptor descriptor = proxy.getDescriptor(); log.info( indexStateInfo( "start", indexId, state, descriptor ) ); switch ( state ) { @@ -263,8 +262,8 @@ public void start() throws Exception break; case POPULATING: // Remember for rebuilding - rebuildingDescriptors.put( indexId, new RebuildingIndexDescriptor( - descriptor, proxy.getProviderDescriptor(), proxy.config() ) ); + rebuildingDescriptors.put( indexId, + new RebuildingIndexDescriptor( descriptor, proxy.getProviderDescriptor() ) ); break; case FAILED: // Don't do anything, the user needs to drop the index and re-create @@ -290,7 +289,6 @@ public void start() throws Exception indexId, descriptor.getIndexDescriptor(), descriptor.getProviderDescriptor(), - descriptor.getConfiguration(), false, // never pass through a tentative online state during recovery monitor, populationJob ); @@ -311,7 +309,7 @@ public void start() throws Exception // This is why we now go and wait for those indexes to be fully populated. for ( Map.Entry entry : rebuildingDescriptors.entrySet() ) { - if ( !entry.getValue().getConfiguration().isUnique() ) + if ( entry.getValue().getIndexDescriptor().type() != NewIndexDescriptor.Type.UNIQUE ) { // It's not a uniqueness constraint, so don't wait for it to be rebuilt continue; @@ -483,20 +481,19 @@ public void createIndexes( IndexRule... rules ) throws IOException indexMapRef.setIndexMap( indexMap ); continue; } - final IndexDescriptor descriptor = IndexBoundary.map( rule.getIndexDescriptor() ); + final NewIndexDescriptor descriptor = rule.getIndexDescriptor(); SchemaIndexProvider.Descriptor providerDescriptor = rule.getProviderDescriptor(); - boolean constraint = rule.canSupportUniqueConstraint(); + boolean flipToTentative = rule.canSupportUniqueConstraint(); if ( state == State.RUNNING ) { populationJob = populationJob == null ? newIndexPopulationJob() : populationJob; index = indexProxyCreator.createPopulatingIndexProxy( - ruleId, descriptor, providerDescriptor, IndexConfiguration.of( constraint ), constraint, - monitor, populationJob ); + ruleId, descriptor, providerDescriptor, flipToTentative, monitor, populationJob ); index.start(); } else { - index = indexProxyCreator.createRecoveringIndexProxy( descriptor, providerDescriptor, constraint ); + index = indexProxyCreator.createRecoveringIndexProxy( descriptor, providerDescriptor ); } indexMap.putIndexProxy( rule.getId(), index ); @@ -733,10 +730,10 @@ private void startIndexPopulation( IndexPopulationJob job ) scheduler.schedule( indexPopulation, job ); } - private String indexStateInfo( String tag, Long indexId, InternalIndexState state, IndexDescriptor descriptor ) + private String indexStateInfo( String tag, Long indexId, InternalIndexState state, NewIndexDescriptor descriptor ) { return format( "IndexingService.%s: index %d on %s is %s", tag, indexId, - descriptor.userDescription( tokenNameLookup ), state.name() ); + descriptor.schema().userDescription( tokenNameLookup ), state.name() ); } public IndexSamplingController getSamplingController() diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/MultipleIndexPopulator.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/MultipleIndexPopulator.java index 20f294cda341..f1a3292a4378 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/MultipleIndexPopulator.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/MultipleIndexPopulator.java @@ -76,7 +76,7 @@ * Usage of this class should be something like: *
    *
  1. Instantiation.
  2. - *
  3. One or more calls to {@link #addPopulator(IndexPopulator, long, IndexDescriptor, Descriptor, IndexConfiguration, + *
  4. One or more calls to {@link #addPopulator(IndexPopulator, long, NewIndexDescriptor, Descriptor, * FlippableIndexProxy, FailedIndexProxyFactory, String)}.
  5. *
  6. Call to {@link #create()} to create data structures and files to start accepting updates.
  7. *
  8. Call to {@link #indexAllNodes()} (blocking call).
  9. @@ -114,23 +114,23 @@ public MultipleIndexPopulator( IndexStoreView storeView, LogProvider logProvider public IndexPopulation addPopulator( IndexPopulator populator, long indexId, - IndexDescriptor descriptor, - Descriptor providerDescriptor, IndexConfiguration config, + NewIndexDescriptor descriptor, + Descriptor providerDescriptor, FlippableIndexProxy flipper, FailedIndexProxyFactory failedIndexProxyFactory, String indexUserDescription ) { - IndexPopulation population = createPopulation( populator, indexId, descriptor, config, providerDescriptor, flipper, + IndexPopulation population = createPopulation( populator, indexId, descriptor, providerDescriptor, flipper, failedIndexProxyFactory, indexUserDescription ); populations.add( population ); return population; } - protected IndexPopulation createPopulation( IndexPopulator populator, long indexId, IndexDescriptor descriptor, - IndexConfiguration config, Descriptor providerDescriptor, FlippableIndexProxy flipper, + protected IndexPopulation createPopulation( IndexPopulator populator, long indexId, NewIndexDescriptor descriptor, + Descriptor providerDescriptor, FlippableIndexProxy flipper, FailedIndexProxyFactory failedIndexProxyFactory, String indexUserDescription ) { - return new IndexPopulation( populator, indexId, descriptor, config, providerDescriptor, flipper, failedIndexProxyFactory, + return new IndexPopulation( populator, indexId, descriptor, providerDescriptor, flipper, failedIndexProxyFactory, indexUserDescription ); } @@ -450,7 +450,6 @@ public class IndexPopulation public final IndexPopulator populator; final long indexId; final NewIndexDescriptor descriptor; - final IndexConfiguration config; final SchemaIndexProvider.Descriptor providerDescriptor; final IndexCountsRemover indexCountsRemover; final FlippableIndexProxy flipper; @@ -460,8 +459,7 @@ public class IndexPopulation IndexPopulation( IndexPopulator populator, long indexId, - IndexDescriptor descriptor, - IndexConfiguration config, + NewIndexDescriptor descriptor, Descriptor providerDescriptor, FlippableIndexProxy flipper, FailedIndexProxyFactory failedIndexProxyFactory, @@ -469,8 +467,7 @@ public class IndexPopulation { this.populator = populator; this.indexId = indexId; - this.descriptor = IndexBoundary.map( descriptor ); - this.config = config; + this.descriptor = descriptor; this.providerDescriptor = providerDescriptor; this.flipper = flipper; this.failedIndexProxyFactory = failedIndexProxyFactory; @@ -480,7 +477,7 @@ public class IndexPopulation private void flipToFailed( Throwable t ) { - flipper.flipTo( new FailedIndexProxy( IndexBoundary.map( descriptor ), config, + flipper.flipTo( new FailedIndexProxy( descriptor, providerDescriptor, indexUserDescription, populator, failure( t ), indexCountsRemover, logProvider ) ); } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/OnlineIndexProxy.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/OnlineIndexProxy.java index abae41d5dbd5..9211aa777cde 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/OnlineIndexProxy.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/OnlineIndexProxy.java @@ -27,12 +27,11 @@ import org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException; import org.neo4j.kernel.api.exceptions.index.IndexPopulationFailedKernelException; import org.neo4j.kernel.api.index.IndexAccessor; -import org.neo4j.kernel.api.index.IndexConfiguration; -import org.neo4j.kernel.api.schema.IndexDescriptor; import org.neo4j.kernel.api.index.IndexUpdater; import org.neo4j.kernel.api.index.InternalIndexState; import org.neo4j.kernel.api.index.PropertyAccessor; import org.neo4j.kernel.api.index.SchemaIndexProvider; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; import org.neo4j.storageengine.api.schema.IndexReader; import org.neo4j.storageengine.api.schema.PopulationProgress; import org.neo4j.kernel.impl.api.index.updater.UpdateCountingIndexUpdater; @@ -42,11 +41,10 @@ public class OnlineIndexProxy implements IndexProxy { private final long indexId; - private final IndexDescriptor descriptor; + private final NewIndexDescriptor descriptor; final IndexAccessor accessor; private final IndexStoreView storeView; private final SchemaIndexProvider.Descriptor providerDescriptor; - private final IndexConfiguration configuration; private final IndexCountsRemover indexCountsRemover; // About this flag: there are two online "modes", you might say... @@ -75,7 +73,7 @@ public class OnlineIndexProxy implements IndexProxy // slightly more costly, but shouldn't make that big of a difference hopefully. private final boolean forcedIdempotentMode; - public OnlineIndexProxy( long indexId, IndexDescriptor descriptor, IndexConfiguration configuration, + public OnlineIndexProxy( long indexId, NewIndexDescriptor descriptor, IndexAccessor accessor, IndexStoreView storeView, SchemaIndexProvider.Descriptor providerDescriptor, boolean forcedIdempotentMode ) { @@ -84,7 +82,6 @@ public OnlineIndexProxy( long indexId, IndexDescriptor descriptor, IndexConfigur this.storeView = storeView; this.providerDescriptor = providerDescriptor; this.accessor = accessor; - this.configuration = configuration; this.forcedIdempotentMode = forcedIdempotentMode; this.indexCountsRemover = new IndexCountsRemover( storeView, indexId ); } @@ -114,7 +111,7 @@ public Future drop() throws IOException } @Override - public IndexDescriptor getDescriptor() + public NewIndexDescriptor getDescriptor() { return descriptor; } @@ -192,12 +189,6 @@ public ResourceIterator snapshotFiles() throws IOException return accessor.snapshotFiles(); } - @Override - public IndexConfiguration config() - { - return configuration; - } - @Override public String toString() { diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/PopulatingIndexProxy.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/PopulatingIndexProxy.java index 7dd9dbb5a45b..6e995573c414 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/PopulatingIndexProxy.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/PopulatingIndexProxy.java @@ -35,6 +35,7 @@ import org.neo4j.kernel.api.index.IndexUpdater; import org.neo4j.kernel.api.index.InternalIndexState; import org.neo4j.kernel.api.index.SchemaIndexProvider; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; import org.neo4j.storageengine.api.schema.IndexReader; import org.neo4j.storageengine.api.schema.PopulationProgress; @@ -42,18 +43,15 @@ public class PopulatingIndexProxy implements IndexProxy { - private final IndexDescriptor descriptor; + private final NewIndexDescriptor descriptor; private final SchemaIndexProvider.Descriptor providerDescriptor; - private final IndexConfiguration configuration; private final IndexPopulationJob job; - public PopulatingIndexProxy( IndexDescriptor descriptor, - IndexConfiguration configuration, + public PopulatingIndexProxy( NewIndexDescriptor descriptor, SchemaIndexProvider.Descriptor providerDescriptor, IndexPopulationJob job ) { this.descriptor = descriptor; - this.configuration = configuration; this.providerDescriptor = providerDescriptor; this.job = job; } @@ -97,7 +95,7 @@ public Future drop() } @Override - public IndexDescriptor getDescriptor() + public NewIndexDescriptor getDescriptor() { return descriptor; } @@ -175,12 +173,6 @@ public PopulationProgress getIndexPopulationProgress() return job.getPopulationProgress(); } - @Override - public IndexConfiguration config() - { - return configuration; - } - @Override public String toString() { diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/RebuildingIndexDescriptor.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/RebuildingIndexDescriptor.java index 1397ad34c668..cace60e453ea 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/RebuildingIndexDescriptor.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/RebuildingIndexDescriptor.java @@ -19,29 +19,25 @@ */ package org.neo4j.kernel.impl.api.index; -import org.neo4j.kernel.api.index.IndexConfiguration; -import org.neo4j.kernel.api.schema.IndexDescriptor; import org.neo4j.kernel.api.index.SchemaIndexProvider; import org.neo4j.kernel.api.index.SchemaIndexProvider.Descriptor; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; /** * Small class for holding a bunch of information about an index that we need to rebuild during recovery. */ public class RebuildingIndexDescriptor { - private final IndexDescriptor indexDescriptor; + private final NewIndexDescriptor indexDescriptor; private final Descriptor providerDescriptor; - private final IndexConfiguration configuration; - RebuildingIndexDescriptor( IndexDescriptor indexDescriptor, SchemaIndexProvider.Descriptor providerDescriptor, - IndexConfiguration configuration ) + RebuildingIndexDescriptor( NewIndexDescriptor indexDescriptor, SchemaIndexProvider.Descriptor providerDescriptor ) { this.indexDescriptor = indexDescriptor; this.providerDescriptor = providerDescriptor; - this.configuration = configuration; } - public IndexDescriptor getIndexDescriptor() + public NewIndexDescriptor getIndexDescriptor() { return indexDescriptor; } @@ -50,9 +46,4 @@ public Descriptor getProviderDescriptor() { return providerDescriptor; } - - public IndexConfiguration getConfiguration() - { - return configuration; - } } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/RecoveringIndexProxy.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/RecoveringIndexProxy.java index 6bf0fc0420a4..e85593658918 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/RecoveringIndexProxy.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/RecoveringIndexProxy.java @@ -28,16 +28,16 @@ import org.neo4j.kernel.api.schema.IndexDescriptor; import org.neo4j.kernel.api.index.InternalIndexState; import org.neo4j.kernel.api.index.SchemaIndexProvider; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; import org.neo4j.storageengine.api.schema.PopulationProgress; import static org.neo4j.helpers.FutureAdapter.VOID; public class RecoveringIndexProxy extends AbstractSwallowingIndexProxy { - public RecoveringIndexProxy( IndexDescriptor descriptor, SchemaIndexProvider.Descriptor providerDescriptor, - IndexConfiguration configuration ) + public RecoveringIndexProxy( NewIndexDescriptor descriptor, SchemaIndexProvider.Descriptor providerDescriptor ) { - super( descriptor, providerDescriptor, null, configuration ); + super( descriptor, providerDescriptor, null ); } @Override diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/TentativeConstraintIndexProxy.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/TentativeConstraintIndexProxy.java index 1e0a1e577f7f..ad05b5279441 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/TentativeConstraintIndexProxy.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/TentativeConstraintIndexProxy.java @@ -30,9 +30,7 @@ import org.neo4j.kernel.api.schema.IndexDescriptor; import org.neo4j.kernel.api.index.IndexUpdater; import org.neo4j.kernel.api.index.InternalIndexState; -import org.neo4j.kernel.api.exceptions.schema.ConstraintValidationException; -import org.neo4j.kernel.api.exceptions.schema.UniquePropertyValueValidationException; -import org.neo4j.kernel.api.schema_new.constaints.ConstraintDescriptorFactory; +import org.neo4j.kernel.api.schema_new.index.IndexBoundary; import org.neo4j.kernel.impl.api.index.updater.DelegatingIndexUpdater; import org.neo4j.storageengine.api.schema.IndexReader; @@ -141,12 +139,9 @@ public void validate() throws UniquePropertyValueValidationException { if ( !failures.isEmpty() ) { - IndexDescriptor descriptor = getDescriptor(); - throw new UniquePropertyValueValidationException( - ConstraintDescriptorFactory.uniqueForLabel( descriptor.getLabelId(), descriptor.getPropertyKeyId() ), - ConstraintValidationException.Phase.VERIFICATION, - new HashSet<>( failures ) - ); + throw new UniquenessConstraintVerificationFailedKernelException( + new UniquenessConstraint( IndexBoundary.map( getDescriptor() ).descriptor() ), + new HashSet<>( failures ) ); } } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/sampling/IndexSamplingController.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/sampling/IndexSamplingController.java index cfdf83814acd..16a483b29ec2 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/sampling/IndexSamplingController.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/sampling/IndexSamplingController.java @@ -27,6 +27,7 @@ import org.neo4j.kernel.api.schema.IndexDescriptor; import org.neo4j.kernel.api.index.InternalIndexState; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; import org.neo4j.kernel.impl.api.index.IndexMap; import org.neo4j.kernel.impl.api.index.IndexMapSnapshotProvider; import org.neo4j.kernel.impl.api.index.IndexProxy; @@ -106,7 +107,7 @@ public void recoverIndexSamples() public interface RecoveryCondition { - boolean test(long indexId, IndexDescriptor descriptor); + boolean test(long indexId, NewIndexDescriptor descriptor); } private void scheduleSampling( IndexSamplingMode mode, IndexMap indexMap ) diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/sampling/IndexSamplingControllerFactory.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/sampling/IndexSamplingControllerFactory.java index e07f94c3d8a9..e619f81c2fe6 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/sampling/IndexSamplingControllerFactory.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/sampling/IndexSamplingControllerFactory.java @@ -22,7 +22,7 @@ import java.util.function.Predicate; import org.neo4j.kernel.api.TokenNameLookup; -import org.neo4j.kernel.api.schema.IndexDescriptor; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; import org.neo4j.kernel.impl.api.index.IndexMapSnapshotProvider; import org.neo4j.kernel.impl.api.index.IndexStoreView; import org.neo4j.kernel.impl.util.JobScheduler; @@ -92,12 +92,13 @@ private IndexSamplingController.RecoveryCondition createIndexRecoveryCondition( private final DoubleLongRegister register = newDoubleLongRegister(); @Override - public boolean test( long indexId, IndexDescriptor descriptor ) + public boolean test( long indexId, NewIndexDescriptor descriptor ) { boolean result = storeView.indexSample( indexId, register ).readSecond() == 0; if ( result ) { - log.warn( "Recovering index sampling for index %s", descriptor.userDescription( tokenNameLookup ) ); + log.warn( "Recovering index sampling for index %s", + descriptor.schema().userDescription( tokenNameLookup ) ); } return result; } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/storemigration/legacystore/v21/propertydeduplication/IndexLookup.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/storemigration/legacystore/v21/propertydeduplication/IndexLookup.java index c7d3104309b0..0b267a5376e2 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/storemigration/legacystore/v21/propertydeduplication/IndexLookup.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/storemigration/legacystore/v21/propertydeduplication/IndexLookup.java @@ -111,10 +111,8 @@ private IndexReader getIndexReader( IndexRule rule ) throws IOException IndexReader reader = readerCache.get( rule ); if ( reader == null ) { - IndexConfiguration indexConfig = IndexConfiguration.of( rule ); IndexAccessor accessor = schemaIndexProvider.getOnlineAccessor( - rule.getId(), IndexBoundary.map( rule.getIndexDescriptor() ), - indexConfig, samplingConfig ); + rule.getId(), rule.getIndexDescriptor(), samplingConfig ); indexAccessors.add( accessor ); reader = accessor.newReader(); readerCache.put( rule, reader ); diff --git a/community/kernel/src/main/java/org/neo4j/unsafe/batchinsert/internal/BatchInserterImpl.java b/community/kernel/src/main/java/org/neo4j/unsafe/batchinsert/internal/BatchInserterImpl.java index 45ad85d16540..410db4f42711 100644 --- a/community/kernel/src/main/java/org/neo4j/unsafe/batchinsert/internal/BatchInserterImpl.java +++ b/community/kernel/src/main/java/org/neo4j/unsafe/batchinsert/internal/BatchInserterImpl.java @@ -57,7 +57,6 @@ import org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException; import org.neo4j.kernel.api.exceptions.schema.AlreadyConstrainedException; import org.neo4j.kernel.api.exceptions.schema.CreateConstraintFailureException; -import org.neo4j.kernel.api.index.IndexConfiguration; import org.neo4j.kernel.api.index.IndexEntryUpdate; import org.neo4j.kernel.api.index.IndexPopulator; import org.neo4j.kernel.api.index.InternalIndexState; @@ -72,7 +71,6 @@ import org.neo4j.kernel.api.schema_new.SchemaDescriptorFactory; import org.neo4j.kernel.api.schema_new.constaints.ConstraintDescriptor; import org.neo4j.kernel.api.schema_new.constaints.ConstraintDescriptorFactory; -import org.neo4j.kernel.api.schema_new.index.IndexBoundary; import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptorFactory; import org.neo4j.kernel.configuration.Config; @@ -453,10 +451,7 @@ private void repopulateAllIndexes() throws IOException, IndexEntryConflictExcept IndexRule rule = rules[i]; descriptors[i] = rule.getIndexDescriptor(); populators[i] = schemaIndexProviders.apply( rule.getProviderDescriptor() ) - .getPopulator( rule.getId(), - IndexBoundary.map( descriptors[i] ), - IndexConfiguration.of( rule ), - new IndexSamplingConfig( config ) ); + .getPopulator( rule.getId(), descriptors[i], new IndexSamplingConfig( config ) ); populators[i].create(); } diff --git a/community/kernel/src/test/java/org/neo4j/kernel/api/index/IndexAccessorCompatibility.java b/community/kernel/src/test/java/org/neo4j/kernel/api/index/IndexAccessorCompatibility.java index 8cbeed00a94d..7d0f3aa6d79d 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/api/index/IndexAccessorCompatibility.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/api/index/IndexAccessorCompatibility.java @@ -32,6 +32,7 @@ import org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException; import org.neo4j.kernel.api.schema_new.IndexQuery; import org.neo4j.kernel.api.schema_new.index.IndexBoundary; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; import org.neo4j.kernel.configuration.Config; import org.neo4j.kernel.impl.api.index.IndexUpdateMode; import org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig; @@ -48,24 +49,21 @@ public abstract class IndexAccessorCompatibility extends IndexProviderCompatibil { protected IndexAccessor accessor; - private boolean isUnique = true; - - public IndexAccessorCompatibility( IndexProviderCompatibilityTestSuite testSuite, boolean isUnique ) + public IndexAccessorCompatibility( IndexProviderCompatibilityTestSuite testSuite, + NewIndexDescriptor descriptor, boolean isUnique ) { - super(testSuite); + super( testSuite, descriptor ); this.isUnique = isUnique; } @Before public void before() throws Exception { - IndexConfiguration indexConfig = IndexConfiguration.of( isUnique ); IndexSamplingConfig indexSamplingConfig = new IndexSamplingConfig( Config.empty() ); - IndexPopulator populator = indexProvider.getPopulator( 17, IndexBoundary.map( descriptor ), indexConfig, indexSamplingConfig ); + IndexPopulator populator = indexProvider.getPopulator( 17, descriptor, indexSamplingConfig ); populator.create(); populator.close( true ); - accessor = indexProvider.getOnlineAccessor( 17, IndexBoundary.map( descriptor ), - indexConfig, indexSamplingConfig ); + accessor = indexProvider.getOnlineAccessor( 17, descriptor, indexSamplingConfig ); } @After diff --git a/community/kernel/src/test/java/org/neo4j/kernel/api/index/IndexProviderCompatibilityTestSuite.java b/community/kernel/src/test/java/org/neo4j/kernel/api/index/IndexProviderCompatibilityTestSuite.java index df1f95adb0d0..8cc4d6badcaa 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/api/index/IndexProviderCompatibilityTestSuite.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/api/index/IndexProviderCompatibilityTestSuite.java @@ -28,7 +28,6 @@ import org.neo4j.io.fs.FileSystemAbstraction; import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; -import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptorFactory; import org.neo4j.test.rule.TestDirectory; import org.neo4j.test.rule.fs.DefaultFileSystemRule; import org.neo4j.test.runner.ParameterizedSuiteRunner; @@ -56,7 +55,7 @@ public abstract static class Compatibility protected FileSystemAbstraction fs; protected final IndexProviderCompatibilityTestSuite testSuite; protected SchemaIndexProvider indexProvider; - protected NewIndexDescriptor descriptor = NewIndexDescriptorFactory.forLabel( 1, 2 ); + protected NewIndexDescriptor descriptor; @Before public void setup() @@ -66,9 +65,10 @@ public void setup() indexProvider = testSuite.createIndexProvider( fs, graphDbDir ); } - public Compatibility( IndexProviderCompatibilityTestSuite testSuite ) + public Compatibility( IndexProviderCompatibilityTestSuite testSuite, NewIndexDescriptor descriptor ) { this.testSuite = testSuite; + this.descriptor = descriptor; } } } diff --git a/community/kernel/src/test/java/org/neo4j/kernel/api/index/NonUniqueIndexAccessorCompatibility.java b/community/kernel/src/test/java/org/neo4j/kernel/api/index/NonUniqueIndexAccessorCompatibility.java index 7dcc1ca90767..6d8297aee07b 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/api/index/NonUniqueIndexAccessorCompatibility.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/api/index/NonUniqueIndexAccessorCompatibility.java @@ -46,11 +46,9 @@ " errors or warnings in some IDEs about test classes needing a public zero-arg constructor." ) public class NonUniqueIndexAccessorCompatibility extends IndexAccessorCompatibility { - private static final NewIndexDescriptor index = NewIndexDescriptorFactory.forLabel( 1000, 100 ); - public NonUniqueIndexAccessorCompatibility( IndexProviderCompatibilityTestSuite testSuite ) { - super( testSuite, false ); + super( testSuite, NewIndexDescriptorFactory.forLabel( 1000, 100 ), false ); } @Test @@ -63,8 +61,8 @@ public void closingAnOnlineIndexUpdaterMustNotThrowEvenIfItHasBeenFedConflicting // the exact-match filtering we do on index seeks in StateHandlingStatementOperations. updateAndCommit( asList( - IndexEntryUpdate.add( 1L, index, "a" ), - IndexEntryUpdate.add( 2L, index, "a" ) ) ); + IndexEntryUpdate.add( 1L, descriptor, "a" ), + IndexEntryUpdate.add( 2L, descriptor, "a" ) ) ); assertThat( query( exact( 1, "a" ) ), equalTo( asList( 1L, 2L ) ) ); } @@ -73,35 +71,23 @@ public void closingAnOnlineIndexUpdaterMustNotThrowEvenIfItHasBeenFedConflicting public void testIndexSeekAndScan() throws Exception { updateAndCommit( asList( - IndexEntryUpdate.add( 1L, index, "a" ), - IndexEntryUpdate.add( 2L, index, "a" ), - IndexEntryUpdate.add( 3L, index, "b" ) ) ); - - assertThat( query( exact( 1, "a" ) ), equalTo( asList( 1L, 2L ) ) ); - assertThat( query( exists( 1 ) ), equalTo( asList( 1L, 2L, 3L ) ) ); - } - - @Test - public void testIndexSeekAndScanWithQuery() throws Exception - { - updateAndCommit( asList( - IndexEntryUpdate.add( 1L, index, "a" ), - IndexEntryUpdate.add( 2L, index, "a" ), - IndexEntryUpdate.add( 3L, index, "b" ) ) ); + IndexEntryUpdate.add( 1L, descriptor, "a" ), + IndexEntryUpdate.add( 2L, descriptor, "a" ), + IndexEntryUpdate.add( 3L, descriptor, "b" ) ) ); assertThat( query( exact( 1, "a" ) ), equalTo( asList( 1L, 2L ) ) ); assertThat( query( exists( 1 ) ), equalTo( asList( 1L, 2L, 3L ) ) ); } @Test - public void testIndexRangeSeekByNumberWithDuplicatesWithQuery() throws Exception + public void testIndexRangeSeekByNumberWithDuplicates() throws Exception { updateAndCommit( asList( - IndexEntryUpdate.add( 1L, index, -5 ), - IndexEntryUpdate.add( 2L, index, -5 ), - IndexEntryUpdate.add( 3L, index, 0 ), - IndexEntryUpdate.add( 4L, index, 5 ), - IndexEntryUpdate.add( 5L, index, 5 ) ) ); + IndexEntryUpdate.add( 1L, descriptor, -5 ), + IndexEntryUpdate.add( 2L, descriptor, -5 ), + IndexEntryUpdate.add( 3L, descriptor, 0 ), + IndexEntryUpdate.add( 4L, descriptor, 5 ), + IndexEntryUpdate.add( 5L, descriptor, 5 ) ) ); assertThat( query( range( 1, -5, true, 5, true ) ), equalTo( asList( 1L, 2L, 3L, 4L, 5L ) ) ); assertThat( query( range( 1, -3, true, -1, true ) ), equalTo( EMPTY_LIST ) ); @@ -111,14 +97,14 @@ public void testIndexRangeSeekByNumberWithDuplicatesWithQuery() throws Exception } @Test - public void testIndexRangeSeekByStringWithDuplicatesWithIndexQuery() throws Exception + public void testIndexRangeSeekByStringWithDuplicates() throws Exception { updateAndCommit( asList( - IndexEntryUpdate.add( 1L, index, "Anna" ), - IndexEntryUpdate.add( 2L, index, "Anna" ), - IndexEntryUpdate.add( 3L, index, "Bob" ), - IndexEntryUpdate.add( 4L, index, "William" ), - IndexEntryUpdate.add( 5L, index, "William" ) ) ); + IndexEntryUpdate.add( 1L, descriptor, "Anna" ), + IndexEntryUpdate.add( 2L, descriptor, "Anna" ), + IndexEntryUpdate.add( 3L, descriptor, "Bob" ), + IndexEntryUpdate.add( 4L, descriptor, "William" ), + IndexEntryUpdate.add( 5L, descriptor, "William" ) ) ); assertThat( query( range( 1, "Anna", false, "William", false ) ), equalTo( singletonList( 3L ) ) ); assertThat( query( range( 1, "Arabella", false, "Bob", false ) ), equalTo( EMPTY_LIST ) ); @@ -131,25 +117,11 @@ public void testIndexRangeSeekByStringWithDuplicatesWithIndexQuery() throws Exce public void testIndexRangeSeekByPrefixWithDuplicates() throws Exception { updateAndCommit( asList( - IndexEntryUpdate.add( 1L, index, "a" ), - IndexEntryUpdate.add( 2L, index, "A" ), - IndexEntryUpdate.add( 3L, index, "apa" ), - IndexEntryUpdate.add( 4L, index, "apa" ), - IndexEntryUpdate.add( 5L, index, "apa" ) ) ); - - assertThat( query( stringPrefix( 1, "a" ) ), equalTo( asList( 1L, 3L, 4L, 5L ) ) ); - assertThat( query( stringPrefix( 1, "apa" ) ), equalTo( asList( 3L, 4L, 5L ) ) ); - } - - @Test - public void testIndexRangeSeekByPrefixWithDuplicatesWithIndexQuery() throws Exception - { - updateAndCommit( asList( - IndexEntryUpdate.add( 1L, index, "a" ), - IndexEntryUpdate.add( 2L, index, "A" ), - IndexEntryUpdate.add( 3L, index, "apa" ), - IndexEntryUpdate.add( 4L, index, "apa" ), - IndexEntryUpdate.add( 5L, index, "apa" ) ) ); + IndexEntryUpdate.add( 1L, descriptor, "a" ), + IndexEntryUpdate.add( 2L, descriptor, "A" ), + IndexEntryUpdate.add( 3L, descriptor, "apa" ), + IndexEntryUpdate.add( 4L, descriptor, "apa" ), + IndexEntryUpdate.add( 5L, descriptor, "apa" ) ) ); assertThat( query( stringPrefix( 1, "a" ) ), equalTo( asList( 1L, 3L, 4L, 5L ) ) ); assertThat( query( stringPrefix( 1, "apa" ) ), equalTo( asList( 3L, 4L, 5L ) ) ); @@ -159,26 +131,11 @@ public void testIndexRangeSeekByPrefixWithDuplicatesWithIndexQuery() throws Exce public void testIndexFullSearchWithDuplicates() throws Exception { updateAndCommit( asList( - IndexEntryUpdate.add( 1L, index, "a" ), - IndexEntryUpdate.add( 2L, index, "A" ), - IndexEntryUpdate.add( 3L, index, "apa" ), - IndexEntryUpdate.add( 4L, index, "apa" ), - IndexEntryUpdate.add( 5L, index, "apalong" ) ) ); - - assertThat( query( stringContains( 1, "a" ) ), equalTo( asList( 1L, 3L, 4L, 5L ) ) ); - assertThat( query( stringContains( 1, "apa" ) ), equalTo( asList( 3L, 4L, 5L ) ) ); - assertThat( query( stringContains( 1, "apa*" ) ), equalTo( Collections.emptyList() ) ); - } - - @Test - public void testIndexFullSearchWithDuplicatesWithIndexQuery() throws Exception - { - updateAndCommit( asList( - IndexEntryUpdate.add( 1L, index, "a" ), - IndexEntryUpdate.add( 2L, index, "A" ), - IndexEntryUpdate.add( 3L, index, "apa" ), - IndexEntryUpdate.add( 4L, index, "apa" ), - IndexEntryUpdate.add( 5L, index, "apalong" ) ) ); + IndexEntryUpdate.add( 1L, descriptor, "a" ), + IndexEntryUpdate.add( 2L, descriptor, "A" ), + IndexEntryUpdate.add( 3L, descriptor, "apa" ), + IndexEntryUpdate.add( 4L, descriptor, "apa" ), + IndexEntryUpdate.add( 5L, descriptor, "apalong" ) ) ); assertThat( query( stringContains( 1, "a" ) ), equalTo( asList( 1L, 3L, 4L, 5L ) ) ); assertThat( query( stringContains( 1, "apa" ) ), equalTo( asList( 3L, 4L, 5L ) ) ); @@ -189,29 +146,12 @@ public void testIndexFullSearchWithDuplicatesWithIndexQuery() throws Exception public void testIndexEndsWithWithDuplicated() throws Exception { updateAndCommit( asList( - IndexEntryUpdate.add( 1L, index, "a" ), - IndexEntryUpdate.add( 2L, index, "A" ), - IndexEntryUpdate.add( 3L, index, "apa" ), - IndexEntryUpdate.add( 4L, index, "apa" ), - IndexEntryUpdate.add( 5L, index, "longapa" ), - IndexEntryUpdate.add( 6L, index, "apalong" ) ) ); - - assertThat( query( stringSuffix( 1, "a" ) ), equalTo( asList( 1L, 3L, 4L, 5L ) ) ); - assertThat( query( stringSuffix( 1, "apa" ) ), equalTo( asList( 3L, 4L, 5L ) ) ); - assertThat( query( stringSuffix( 1, "apa*" ) ), equalTo( Collections.emptyList() ) ); - assertThat( query( stringSuffix( 1, "" ) ), equalTo( asList( 1L, 2L, 3L, 4L, 5L, 6L ) ) ); - } - - @Test - public void testIndexEndsWithWithDuplicatedWithIndexQuery() throws Exception - { - updateAndCommit( asList( - IndexEntryUpdate.add( 1L, index, "a" ), - IndexEntryUpdate.add( 2L, index, "A" ), - IndexEntryUpdate.add( 3L, index, "apa" ), - IndexEntryUpdate.add( 4L, index, "apa" ), - IndexEntryUpdate.add( 5L, index, "longapa" ), - IndexEntryUpdate.add( 6L, index, "apalong" ) ) ); + IndexEntryUpdate.add( 1L, descriptor, "a" ), + IndexEntryUpdate.add( 2L, descriptor, "A" ), + IndexEntryUpdate.add( 3L, descriptor, "apa" ), + IndexEntryUpdate.add( 4L, descriptor, "apa" ), + IndexEntryUpdate.add( 5L, descriptor, "longapa" ), + IndexEntryUpdate.add( 6L, descriptor, "apalong" ) ) ); assertThat( query( stringSuffix( 1, "a" ) ), equalTo( asList( 1L, 3L, 4L, 5L ) ) ); assertThat( query( stringSuffix( 1, "apa" ) ), equalTo( asList( 3L, 4L, 5L ) ) ); diff --git a/community/kernel/src/test/java/org/neo4j/kernel/api/index/NonUniqueIndexPopulatorCompatibility.java b/community/kernel/src/test/java/org/neo4j/kernel/api/index/NonUniqueIndexPopulatorCompatibility.java index c84e983c5744..5495785b0592 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/api/index/NonUniqueIndexPopulatorCompatibility.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/api/index/NonUniqueIndexPopulatorCompatibility.java @@ -29,6 +29,8 @@ import org.neo4j.kernel.api.properties.Property; import org.neo4j.kernel.api.schema_new.IndexQuery; import org.neo4j.kernel.api.schema_new.index.IndexBoundary; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptorFactory; import org.neo4j.kernel.configuration.Config; import org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig; import org.neo4j.storageengine.api.schema.IndexReader; @@ -48,7 +50,7 @@ public class NonUniqueIndexPopulatorCompatibility extends IndexProviderCompatibi { public NonUniqueIndexPopulatorCompatibility( IndexProviderCompatibilityTestSuite testSuite ) { - super( testSuite ); + super( testSuite, NewIndexDescriptorFactory.forLabel( 1, 2 ) ); } @Test @@ -57,15 +59,14 @@ public void shouldProvidePopulatorThatAcceptsDuplicateEntries() throws Exception // when IndexConfiguration config = IndexConfiguration.NON_UNIQUE; IndexSamplingConfig indexSamplingConfig = new IndexSamplingConfig( Config.empty() ); - IndexPopulator populator = indexProvider.getPopulator( 17, IndexBoundary.map(descriptor), config, indexSamplingConfig ); + IndexPopulator populator = indexProvider.getPopulator( 17, descriptor, indexSamplingConfig ); populator.create(); populator.add( Arrays.asList( IndexEntryUpdate.add( 1, descriptor, "value1" ), IndexEntryUpdate.add( 2, descriptor, "value1" ) ) ); populator.close( true ); // then - IndexAccessor accessor = indexProvider.getOnlineAccessor( 17, IndexBoundary.map( descriptor ), - config, indexSamplingConfig ); + IndexAccessor accessor = indexProvider.getOnlineAccessor( 17, descriptor, indexSamplingConfig ); try ( IndexReader reader = accessor.newReader() ) { PrimitiveLongIterator nodes = reader.query( IndexQuery.exact( 1, "value1" ) ); @@ -80,7 +81,7 @@ public void shouldStorePopulationFailedForRetrievalFromProviderLater() throws Ex // GIVEN IndexConfiguration config = IndexConfiguration.NON_UNIQUE; IndexSamplingConfig indexSamplingConfig = new IndexSamplingConfig( Config.empty() ); - IndexPopulator populator = indexProvider.getPopulator( 17, IndexBoundary.map(descriptor), config, indexSamplingConfig ); + IndexPopulator populator = indexProvider.getPopulator( 17, descriptor, indexSamplingConfig ); String failure = "The contrived failure"; populator.create(); @@ -97,7 +98,7 @@ public void shouldReportInitialStateAsFailedIfPopulationFailed() throws Exceptio // GIVEN IndexConfiguration config = IndexConfiguration.NON_UNIQUE; IndexSamplingConfig indexSamplingConfig = new IndexSamplingConfig( Config.empty() ); - IndexPopulator populator = indexProvider.getPopulator( 17, IndexBoundary.map(descriptor), config, indexSamplingConfig ); + IndexPopulator populator = indexProvider.getPopulator( 17, descriptor, indexSamplingConfig ); String failure = "The contrived failure"; populator.create(); @@ -114,7 +115,7 @@ public void shouldBeAbleToDropAClosedIndexPopulator() throws Exception // GIVEN IndexConfiguration config = IndexConfiguration.NON_UNIQUE; IndexSamplingConfig indexSamplingConfig = new IndexSamplingConfig( Config.empty() ); - IndexPopulator populator = indexProvider.getPopulator( 17, IndexBoundary.map(descriptor), config, indexSamplingConfig ); + IndexPopulator populator = indexProvider.getPopulator( 17, descriptor, indexSamplingConfig ); populator.close( false ); // WHEN @@ -127,9 +128,8 @@ public void shouldBeAbleToDropAClosedIndexPopulator() throws Exception public void shouldApplyUpdatesIdempotently() throws Exception { // GIVEN - IndexConfiguration config = IndexConfiguration.NON_UNIQUE; IndexSamplingConfig indexSamplingConfig = new IndexSamplingConfig( Config.empty() ); - IndexPopulator populator = indexProvider.getPopulator( 17, IndexBoundary.map(descriptor), config, indexSamplingConfig ); + IndexPopulator populator = indexProvider.getPopulator( 17, descriptor, indexSamplingConfig ); populator.create(); populator.configureSampling( true ); long nodeId = 1; @@ -148,8 +148,7 @@ public void shouldApplyUpdatesIdempotently() throws Exception populator.close( true ); // then - IndexAccessor accessor = indexProvider.getOnlineAccessor( 17, IndexBoundary.map( descriptor ), - IndexConfiguration.NON_UNIQUE, indexSamplingConfig ); + IndexAccessor accessor = indexProvider.getOnlineAccessor( 17, descriptor, indexSamplingConfig ); try ( IndexReader reader = accessor.newReader() ) { int propertyKeyId = descriptor.schema().getPropertyId(); diff --git a/community/kernel/src/test/java/org/neo4j/kernel/api/index/UniqueConstraintCompatibility.java b/community/kernel/src/test/java/org/neo4j/kernel/api/index/UniqueConstraintCompatibility.java index 3c7e4f6e0313..c82f64a456b4 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/api/index/UniqueConstraintCompatibility.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/api/index/UniqueConstraintCompatibility.java @@ -44,6 +44,8 @@ import org.neo4j.graphdb.Node; import org.neo4j.graphdb.Transaction; import org.neo4j.kernel.api.KernelTransaction; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptorFactory; import org.neo4j.kernel.extension.KernelExtensionFactory; import org.neo4j.kernel.impl.core.ThreadToStatementContextBridge; import org.neo4j.kernel.impl.locking.Lock; @@ -69,7 +71,7 @@ public class UniqueConstraintCompatibility extends IndexProviderCompatibilityTes { public UniqueConstraintCompatibility( IndexProviderCompatibilityTestSuite testSuite ) { - super( testSuite ); + super( testSuite, NewIndexDescriptorFactory.uniqueForLabel( 1, 2 ) ); } /* diff --git a/community/kernel/src/test/java/org/neo4j/kernel/api/index/UniqueIndexAccessorCompatibility.java b/community/kernel/src/test/java/org/neo4j/kernel/api/index/UniqueIndexAccessorCompatibility.java index 3f1f4e16fd6e..b95080260f7d 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/api/index/UniqueIndexAccessorCompatibility.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/api/index/UniqueIndexAccessorCompatibility.java @@ -38,11 +38,9 @@ " errors or warnings in some IDEs about test classes needing a public zero-arg constructor." ) public class UniqueIndexAccessorCompatibility extends IndexAccessorCompatibility { - private static final NewIndexDescriptor index = NewIndexDescriptorFactory.uniqueForLabel( 1000, 100 ); - public UniqueIndexAccessorCompatibility( IndexProviderCompatibilityTestSuite testSuite ) { - super( testSuite, true ); + super( testSuite, NewIndexDescriptorFactory.uniqueForLabel( 1000, 100 ), true ); } @Test @@ -55,8 +53,8 @@ public void closingAnOnlineIndexUpdaterMustNotThrowEvenIfItHasBeenFedConflicting // the exact-match filtering we do on index seeks in StateHandlingStatementOperations. updateAndCommit( asList( - IndexEntryUpdate.add( 1L, index, "a" ), - IndexEntryUpdate.add( 2L, index, "a" ) ) ); + IndexEntryUpdate.add( 1L, descriptor, "a" ), + IndexEntryUpdate.add( 2L, descriptor, "a" ) ) ); assertThat( query( exact( 1, "a" ) ), equalTo( asList( 1L, 2L ) ) ); } @@ -65,9 +63,9 @@ public void closingAnOnlineIndexUpdaterMustNotThrowEvenIfItHasBeenFedConflicting public void testIndexSeekAndScan() throws Exception { updateAndCommit( asList( - IndexEntryUpdate.add( 1L, index, "a" ), - IndexEntryUpdate.add( 2L, index, "b" ), - IndexEntryUpdate.add( 3L, index, "c" ) ) ); + IndexEntryUpdate.add( 1L, descriptor, "a" ), + IndexEntryUpdate.add( 2L, descriptor, "b" ), + IndexEntryUpdate.add( 3L, descriptor, "c" ) ) ); assertThat( query( exact( 1, "a" ) ), equalTo( asList( 1L ) ) ); assertThat( query( IndexQuery.exists( 1 ) ), equalTo( asList( 1L, 2L, 3L ) ) ); diff --git a/community/kernel/src/test/java/org/neo4j/kernel/api/index/UniqueIndexPopulatorCompatibility.java b/community/kernel/src/test/java/org/neo4j/kernel/api/index/UniqueIndexPopulatorCompatibility.java index a4792a6e482e..7afb1afc4e96 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/api/index/UniqueIndexPopulatorCompatibility.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/api/index/UniqueIndexPopulatorCompatibility.java @@ -24,8 +24,8 @@ import java.util.Arrays; -import org.neo4j.kernel.api.schema_new.index.IndexBoundary; -import org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptorFactory; import org.neo4j.kernel.configuration.Config; import org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig; @@ -44,7 +44,7 @@ public class UniqueIndexPopulatorCompatibility extends IndexProviderCompatibilit { public UniqueIndexPopulatorCompatibility( IndexProviderCompatibilityTestSuite testSuite ) { - super( testSuite ); + super( testSuite, NewIndexDescriptorFactory.uniqueForLabel( 1, 2 ) ); } /** @@ -58,10 +58,8 @@ public void shouldProvidePopulatorThatEnforcesUniqueConstraints() throws Excepti int nodeId1 = 1; int nodeId2 = 2; - IndexConfiguration indexConfig = IndexConfiguration.UNIQUE; IndexSamplingConfig indexSamplingConfig = new IndexSamplingConfig( Config.empty() ); - IndexPopulator populator = - indexProvider.getPopulator( 17, IndexBoundary.map( descriptor ), indexConfig, indexSamplingConfig ); + IndexPopulator populator = indexProvider.getPopulator( 17, descriptor, indexSamplingConfig ); populator.create(); populator.add( Arrays.asList( IndexEntryUpdate.add( nodeId1, descriptor, value ), IndexEntryUpdate.add( nodeId2, descriptor, value ) ) ); diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/BatchingMultipleIndexPopulatorTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/BatchingMultipleIndexPopulatorTest.java index 32f8e008a2bc..8896d7058866 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/BatchingMultipleIndexPopulatorTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/BatchingMultipleIndexPopulatorTest.java @@ -30,13 +30,11 @@ import org.neo4j.helpers.collection.Visitor; import org.neo4j.kernel.api.exceptions.index.IndexPopulationFailedKernelException; -import org.neo4j.kernel.api.index.IndexConfiguration; +import org.neo4j.kernel.api.index.IndexEntryUpdate; import org.neo4j.kernel.api.index.IndexPopulator; import org.neo4j.kernel.api.index.IndexUpdater; -import org.neo4j.kernel.api.index.IndexEntryUpdate; import org.neo4j.kernel.api.index.NodeUpdates; import org.neo4j.kernel.api.index.SchemaIndexProvider; -import org.neo4j.kernel.api.schema_new.index.IndexBoundary; import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptorFactory; import org.neo4j.kernel.impl.locking.LockService; @@ -321,10 +319,9 @@ private static IndexPopulator addPopulator( BatchingMultipleIndexPopulator batch flipper.setFlipTarget( indexProxyFactory ); batchingPopulator.addPopulator( - populator, descriptor.schema().getLabelId(), IndexBoundary.map(descriptor), + populator, descriptor.schema().getLabelId(), descriptor, new SchemaIndexProvider.Descriptor( "foo", "1" ), - IndexConfiguration.NON_UNIQUE, flipper, - failedIndexProxyFactory, "testIndex" ); + flipper, failedIndexProxyFactory, "testIndex" ); return populator; } diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/ControlledPopulationSchemaIndexProvider.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/ControlledPopulationSchemaIndexProvider.java index 7f238e3b0cdc..386a80eb5226 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/ControlledPopulationSchemaIndexProvider.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/ControlledPopulationSchemaIndexProvider.java @@ -26,11 +26,10 @@ import org.neo4j.io.fs.FileSystemAbstraction; import org.neo4j.io.pagecache.PageCache; import org.neo4j.kernel.api.index.IndexAccessor; -import org.neo4j.kernel.api.index.IndexConfiguration; -import org.neo4j.kernel.api.schema.IndexDescriptor; import org.neo4j.kernel.api.index.IndexPopulator; import org.neo4j.kernel.api.index.InternalIndexState; import org.neo4j.kernel.api.index.SchemaIndexProvider; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; import org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig; import org.neo4j.kernel.impl.api.scan.LabelScanStoreProvider; import org.neo4j.kernel.impl.storemigration.StoreMigrationParticipant; @@ -89,16 +88,15 @@ public void awaitFullyPopulated() } @Override - public IndexPopulator getPopulator( long indexId, IndexDescriptor descriptor, IndexConfiguration indexConfig, - IndexSamplingConfig samplingConfig ) + public IndexPopulator getPopulator( long indexId, NewIndexDescriptor descriptor, IndexSamplingConfig samplingConfig ) { populatorCallCount.incrementAndGet(); return mockedPopulator; } @Override - public IndexAccessor getOnlineAccessor( long indexId, IndexDescriptor descriptor, - IndexConfiguration indexConfig, IndexSamplingConfig samplingConfig ) + public IndexAccessor getOnlineAccessor( long indexId, NewIndexDescriptor indexConfig, + IndexSamplingConfig samplingConfig ) { writerCallCount.incrementAndGet(); writerLatch.countDown(); diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/FailedIndexProxyTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/FailedIndexProxyTest.java index 0551707274c6..58aeaf17bbd8 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/FailedIndexProxyTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/FailedIndexProxyTest.java @@ -28,6 +28,7 @@ import org.neo4j.kernel.api.schema.IndexDescriptorFactory; import org.neo4j.kernel.api.index.IndexPopulator; import org.neo4j.kernel.api.index.SchemaIndexProvider; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptorFactory; import org.neo4j.logging.AssertableLogProvider; import org.neo4j.logging.NullLogProvider; @@ -38,8 +39,6 @@ public class FailedIndexProxyTest { - private final IndexDescriptor descriptor = IndexDescriptorFactory.of( 1, 2 ); - private final IndexConfiguration config = IndexConfiguration.NON_UNIQUE; private final SchemaIndexProvider.Descriptor providerDescriptor = mock( SchemaIndexProvider.Descriptor.class ); private final String userDescription = "description"; private final IndexPopulator indexPopulator = mock( IndexPopulator.class ); @@ -50,7 +49,8 @@ public class FailedIndexProxyTest public void shouldRemoveIndexCountsWhenTheIndexItselfIsDropped() throws IOException { // given - FailedIndexProxy index = new FailedIndexProxy( descriptor, config, providerDescriptor, userDescription, + FailedIndexProxy index = new FailedIndexProxy( + NewIndexDescriptorFactory.forLabel( 1, 2 ), providerDescriptor, userDescription, indexPopulator, indexPopulationFailure, indexCountsRemover, NullLogProvider.getInstance() ); // when @@ -69,7 +69,7 @@ public void shouldLogReasonForDroppingIndex() throws IOException AssertableLogProvider logProvider = new AssertableLogProvider(); // when - new FailedIndexProxy( IndexDescriptorFactory.of( 0, 0 ), config, + new FailedIndexProxy( NewIndexDescriptorFactory.forLabel( 0, 0 ), new SchemaIndexProvider.Descriptor( "foo", "bar" ), "foo", mock( IndexPopulator.class ), IndexPopulationFailure.failure( "it broke" ), indexCountsRemover, logProvider ).drop(); diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/IndexCRUDIT.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/IndexCRUDIT.java index 4f7f96fc6b1f..710effd5bee1 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/IndexCRUDIT.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/IndexCRUDIT.java @@ -41,9 +41,7 @@ import org.neo4j.kernel.api.ReadOperations; import org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException; import org.neo4j.kernel.api.index.IndexAccessor; -import org.neo4j.kernel.api.index.IndexConfiguration; import org.neo4j.kernel.api.index.IndexEntryUpdate; -import org.neo4j.kernel.api.schema.IndexDescriptor; import org.neo4j.kernel.api.index.IndexPopulator; import org.neo4j.kernel.api.index.IndexUpdater; import org.neo4j.kernel.api.index.PropertyAccessor; @@ -80,7 +78,7 @@ public void addingANodeWithPropertyShouldGetIndexed() throws Exception { // Given String indexProperty = "indexProperty"; - GatheringIndexWriter writer = newWriter( indexProperty ); + GatheringIndexWriter writer = newWriter(); createIndex( db, myLabel, indexProperty ); // When @@ -110,7 +108,7 @@ public void addingALabelToPreExistingNodeShouldGetIndexed() throws Exception { // GIVEN String indexProperty = "indexProperty"; - GatheringIndexWriter writer = newWriter( indexProperty ); + GatheringIndexWriter writer = newWriter(); createIndex( db, myLabel, indexProperty ); // WHEN @@ -180,18 +178,16 @@ public void before() throws Exception ctxSupplier = db.getDependencyResolver().resolveDependency( ThreadToStatementContextBridge.class ); } - private GatheringIndexWriter newWriter( String propertyKey ) throws IOException + private GatheringIndexWriter newWriter() throws IOException { - GatheringIndexWriter writer = new GatheringIndexWriter( propertyKey ); + GatheringIndexWriter writer = new GatheringIndexWriter(); when( mockedIndexProvider.getPopulator( - anyLong(), any( IndexDescriptor.class ), any( IndexConfiguration.class ), - any( IndexSamplingConfig.class ) ) - ).thenReturn( writer ); + anyLong(), any( NewIndexDescriptor.class ), any( IndexSamplingConfig.class ) ) + ).thenReturn( writer ); when( mockedIndexProvider.getProviderDescriptor() ).thenReturn( PROVIDER_DESCRIPTOR ); when( mockedIndexProvider.getOnlineAccessor( - anyLong(), any( IndexDescriptor.class ), any( IndexConfiguration.class ), - any( IndexSamplingConfig.class ) - ) ).thenReturn( writer ); + anyLong(), any( NewIndexDescriptor.class ), any( IndexSamplingConfig.class ) + ) ).thenReturn( writer ); when( mockedIndexProvider.compareTo( any( SchemaIndexProvider.class ) ) ) .thenReturn( 1 ); // always pretend to have highest priority return writer; @@ -206,14 +202,8 @@ public void after() throws Exception private class GatheringIndexWriter extends IndexAccessor.Adapter implements IndexPopulator { private final Set updatesCommitted = new HashSet<>(); - private final String propertyKey; private final Map> indexSamples = new HashMap<>(); - public GatheringIndexWriter( String propertyKey ) - { - this.propertyKey = propertyKey; - } - @Override public void create() { @@ -222,11 +212,7 @@ public void create() @Override public void add( Collection updates ) { - for ( IndexEntryUpdate update : updates ) - { - ReadOperations statement = ctxSupplier.get().readOperations(); - updatesCommitted.add( update ); - } + updatesCommitted.addAll( updates ); } @Override diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/IndexPopulationJobTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/IndexPopulationJobTest.java index e35afc025fd6..fa77f6a79c69 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/IndexPopulationJobTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/IndexPopulationJobTest.java @@ -47,10 +47,7 @@ import org.neo4j.kernel.api.Statement; import org.neo4j.kernel.api.exceptions.TransactionFailureException; import org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException; -import org.neo4j.kernel.api.index.IndexConfiguration; import org.neo4j.kernel.api.index.IndexEntryUpdate; -import org.neo4j.kernel.api.schema.IndexDescriptor; -import org.neo4j.kernel.api.schema.IndexDescriptorFactory; import org.neo4j.kernel.api.index.IndexPopulator; import org.neo4j.kernel.api.index.IndexUpdater; import org.neo4j.kernel.api.index.InternalIndexState; @@ -584,10 +581,9 @@ public void remove( PrimitiveLongSet nodeIds ) private IndexPopulator inMemoryPopulator( boolean constraint ) throws TransactionFailureException { - IndexConfiguration indexConfig = IndexConfiguration.of( constraint ); IndexSamplingConfig samplingConfig = new IndexSamplingConfig( Config.empty() ); - IndexDescriptor descriptor = indexDescriptor( FIRST, name ); - return new InMemoryIndexProvider().getPopulator( 21, descriptor, indexConfig, samplingConfig ); + NewIndexDescriptor descriptor = indexDescriptor( FIRST, name, constraint ); + return new InMemoryIndexProvider().getPopulator( 21, descriptor, samplingConfig ); } private IndexPopulationJob newIndexPopulationJob( IndexPopulator populator, @@ -613,25 +609,27 @@ private IndexPopulationJob newIndexPopulationJob( FailedIndexProxyFactory failur LogProvider logProvider, boolean constraint ) throws TransactionFailureException { - IndexDescriptor descriptor = indexDescriptor( FIRST, name ); + NewIndexDescriptor descriptor = indexDescriptor( FIRST, name, constraint ); long indexId = 0; flipper.setFlipTarget( mock( IndexProxyFactory.class ) ); MultipleIndexPopulator multiPopulator = new MultipleIndexPopulator( storeView, logProvider ); IndexPopulationJob job = new IndexPopulationJob( storeView, multiPopulator, NO_MONITOR, stateHolder::clear ); - job.addPopulator( populator, indexId, descriptor, IndexConfiguration.of( constraint ), PROVIDER_DESCRIPTOR, + job.addPopulator( populator, indexId, descriptor, PROVIDER_DESCRIPTOR, format( ":%s(%s)", FIRST.name(), name ), flipper, failureDelegateFactory ); return job; } - private IndexDescriptor indexDescriptor( Label label, String propertyKey ) throws TransactionFailureException + private NewIndexDescriptor indexDescriptor( Label label, String propertyKey, boolean constraint ) throws TransactionFailureException { try ( KernelTransaction tx = kernel.newTransaction( KernelTransaction.Type.implicit, AnonymousContext.read() ); Statement statement = tx.acquireStatement() ) { int labelId = statement.readOperations().labelGetForName( label.name() ); int propertyKeyId = statement.readOperations().propertyKeyGetForName( propertyKey ); - IndexDescriptor descriptor = IndexDescriptorFactory.of( labelId, propertyKeyId ); + NewIndexDescriptor descriptor = constraint ? + NewIndexDescriptorFactory.uniqueForLabel( labelId, propertyKeyId ) : + NewIndexDescriptorFactory.forLabel( labelId, propertyKeyId ); tx.success(); return descriptor; } diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/IndexProxyAdapter.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/IndexProxyAdapter.java index aabe0e8c6bb4..fa64e24883ad 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/IndexProxyAdapter.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/IndexProxyAdapter.java @@ -24,10 +24,10 @@ import org.neo4j.graphdb.ResourceIterator; import org.neo4j.kernel.api.index.IndexConfiguration; -import org.neo4j.kernel.api.schema.IndexDescriptor; import org.neo4j.kernel.api.index.IndexUpdater; import org.neo4j.kernel.api.index.InternalIndexState; import org.neo4j.kernel.api.index.SchemaIndexProvider; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; import org.neo4j.kernel.impl.api.index.updater.SwallowingIndexUpdater; import org.neo4j.storageengine.api.schema.IndexReader; import org.neo4j.storageengine.api.schema.PopulationProgress; @@ -77,7 +77,7 @@ public Future close() } @Override - public IndexDescriptor getDescriptor() + public NewIndexDescriptor getDescriptor() { return null; } @@ -116,12 +116,6 @@ public ResourceIterator snapshotFiles() return emptyIterator(); } - @Override - public IndexConfiguration config() - { - return null; - } - @Override public IndexPopulationFailure getPopulationFailure() throws IllegalStateException { diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/IndexRecoveryIT.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/IndexRecoveryIT.java index d20b034b128d..d79213370e0f 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/IndexRecoveryIT.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/IndexRecoveryIT.java @@ -96,8 +96,7 @@ public void shouldBeAbleToRecoverInTheMiddleOfPopulatingAnIndex() throws Excepti CountDownLatch latch = new CountDownLatch( 1 ); when( mockedIndexProvider - .getPopulator( anyLong(), any( IndexDescriptor.class ), any( IndexConfiguration.class ), - any( IndexSamplingConfig.class ) ) ) + .getPopulator( anyLong(), any( NewIndexDescriptor.class ), any( IndexSamplingConfig.class ) ) ) .thenReturn( indexPopulatorWithControlledCompletionTiming( latch ) ); createIndex( myLabel ); @@ -110,8 +109,7 @@ public void shouldBeAbleToRecoverInTheMiddleOfPopulatingAnIndex() throws Excepti when( mockedIndexProvider.getInitialState( anyLong() ) ).thenReturn( InternalIndexState.POPULATING ); latch = new CountDownLatch( 1 ); when( mockedIndexProvider - .getPopulator( anyLong(), any( IndexDescriptor.class ), any( IndexConfiguration.class ), - any( IndexSamplingConfig.class ) ) ) + .getPopulator( anyLong(), any( NewIndexDescriptor.class ), any( IndexSamplingConfig.class ) ) ) .thenReturn( indexPopulatorWithControlledCompletionTiming( latch ) ); startDb(); @@ -119,10 +117,9 @@ public void shouldBeAbleToRecoverInTheMiddleOfPopulatingAnIndex() throws Excepti assertThat( getIndexes( db, myLabel ), inTx( db, hasSize( 1 ) ) ); assertThat( getIndexes( db, myLabel ), inTx( db, haveState( db, Schema.IndexState.POPULATING ) ) ); verify( mockedIndexProvider, times( 2 ) ) - .getPopulator( anyLong(), any( IndexDescriptor.class ), any( IndexConfiguration.class ), - any( IndexSamplingConfig.class ) ); - verify( mockedIndexProvider, times( 0 ) ).getOnlineAccessor( anyLong(), any( IndexDescriptor.class ), - any( IndexConfiguration.class ), any( IndexSamplingConfig.class ) + .getPopulator( anyLong(), any( NewIndexDescriptor.class ), any( IndexSamplingConfig.class ) ); + verify( mockedIndexProvider, times( 0 ) ).getOnlineAccessor( + anyLong(), any( NewIndexDescriptor.class ), any( IndexSamplingConfig.class ) ); latch.countDown(); } @@ -135,8 +132,7 @@ public void shouldBeAbleToRecoverInTheMiddleOfPopulatingAnIndexWhereLogHasRotate CountDownLatch latch = new CountDownLatch( 1 ); when( mockedIndexProvider - .getPopulator( anyLong(), any( IndexDescriptor.class ), any( IndexConfiguration.class ), - any( IndexSamplingConfig.class ) ) ) + .getPopulator( anyLong(), any( NewIndexDescriptor.class ), any( IndexSamplingConfig.class ) ) ) .thenReturn( indexPopulatorWithControlledCompletionTiming( latch ) ); createIndex( myLabel ); rotateLogsAndCheckPoint(); @@ -147,8 +143,7 @@ public void shouldBeAbleToRecoverInTheMiddleOfPopulatingAnIndexWhereLogHasRotate killFuture.get(); latch = new CountDownLatch( 1 ); when( mockedIndexProvider - .getPopulator( anyLong(), any( IndexDescriptor.class ), any( IndexConfiguration.class ), - any( IndexSamplingConfig.class ) ) ) + .getPopulator( anyLong(), any( NewIndexDescriptor.class ), any( IndexSamplingConfig.class ) ) ) .thenReturn( indexPopulatorWithControlledCompletionTiming( latch ) ); when( mockedIndexProvider.getInitialState( anyLong() ) ).thenReturn( InternalIndexState.POPULATING ); @@ -159,10 +154,9 @@ public void shouldBeAbleToRecoverInTheMiddleOfPopulatingAnIndexWhereLogHasRotate assertThat( getIndexes( db, myLabel ), inTx( db, hasSize( 1 ) ) ); assertThat( getIndexes( db, myLabel ), inTx( db, haveState( db, Schema.IndexState.POPULATING ) ) ); verify( mockedIndexProvider, times( 2 ) ) - .getPopulator( anyLong(), any( IndexDescriptor.class ), any( IndexConfiguration.class ), - any( IndexSamplingConfig.class ) ); - verify( mockedIndexProvider, times( 0 ) ).getOnlineAccessor( anyLong(), any( IndexDescriptor.class ), - any( IndexConfiguration.class ), any( IndexSamplingConfig.class ) + .getPopulator( anyLong(), any( NewIndexDescriptor.class ), any( IndexSamplingConfig.class ) ); + verify( mockedIndexProvider, times( 0 ) ).getOnlineAccessor( + anyLong(), any( NewIndexDescriptor.class ), any( IndexSamplingConfig.class ) ); latch.countDown(); } @@ -175,14 +169,13 @@ public void shouldBeAbleToRecoverAndUpdateOnlineIndex() throws Exception IndexPopulator populator = mock( IndexPopulator.class ); when( mockedIndexProvider - .getPopulator( anyLong(), any( IndexDescriptor.class ), any( IndexConfiguration.class ), - any( IndexSamplingConfig.class ) ) ) + .getPopulator( anyLong(), any( NewIndexDescriptor.class ), any( IndexSamplingConfig.class ) ) ) .thenReturn( populator ); when( populator.sampleResult() ).thenReturn( new IndexSample() ); IndexAccessor mockedAccessor = mock( IndexAccessor.class ); when( mockedAccessor.newUpdater( any( IndexUpdateMode.class ) ) ).thenReturn( SwallowingIndexUpdater.INSTANCE ); - when( mockedIndexProvider.getOnlineAccessor( anyLong(), any( IndexDescriptor.class ), - any( IndexConfiguration.class ), any( IndexSamplingConfig.class ) ) + when( mockedIndexProvider.getOnlineAccessor( + anyLong(), any( NewIndexDescriptor.class ), any( IndexSamplingConfig.class ) ) ).thenReturn( mockedAccessor ); createIndexAndAwaitPopulation( myLabel ); // rotate logs @@ -194,8 +187,8 @@ public void shouldBeAbleToRecoverAndUpdateOnlineIndex() throws Exception killDb(); when( mockedIndexProvider.getInitialState( anyLong() ) ).thenReturn( InternalIndexState.ONLINE ); GatheringIndexWriter writer = new GatheringIndexWriter(); - when( mockedIndexProvider.getOnlineAccessor( anyLong(), any( IndexDescriptor.class ), - any( IndexConfiguration.class ), any( IndexSamplingConfig.class ) ) + when( mockedIndexProvider.getOnlineAccessor( + anyLong(), any( NewIndexDescriptor.class ), any( IndexSamplingConfig.class ) ) ).thenReturn( writer ); // When @@ -205,12 +198,10 @@ public void shouldBeAbleToRecoverAndUpdateOnlineIndex() throws Exception assertThat( getIndexes( db, myLabel ), inTx( db, hasSize( 1 ) ) ); assertThat( getIndexes( db, myLabel ), inTx( db, haveState( db, Schema.IndexState.ONLINE ) ) ); verify( mockedIndexProvider, times( 1 ) ) - .getPopulator( anyLong(), any( IndexDescriptor.class ), any( IndexConfiguration.class ), - any( IndexSamplingConfig.class ) ); + .getPopulator( anyLong(), any( NewIndexDescriptor.class ), any( IndexSamplingConfig.class ) ); int onlineAccessorInvocationCount = 2; // once when we create the index, and once when we restart the db verify( mockedIndexProvider, times( onlineAccessorInvocationCount ) ) - .getOnlineAccessor( anyLong(), any( IndexDescriptor.class ), - any( IndexConfiguration.class ), any( IndexSamplingConfig.class ) ); + .getOnlineAccessor( anyLong(), any( NewIndexDescriptor.class ), any( IndexSamplingConfig.class ) ); assertEquals( expectedUpdates, writer.batchedUpdates ); for ( IndexEntryUpdate update : writer.batchedUpdates ) { @@ -223,11 +214,10 @@ public void shouldKeepFailedIndexesAsFailedAfterRestart() throws Exception { // Given when( mockedIndexProvider - .getPopulator( anyLong(), any( IndexDescriptor.class ), any( IndexConfiguration.class ), - any( IndexSamplingConfig.class ) ) ) + .getPopulator( anyLong(), any( NewIndexDescriptor.class ), any( IndexSamplingConfig.class ) ) ) .thenReturn( mock( IndexPopulator.class ) ); - when( mockedIndexProvider.getOnlineAccessor( anyLong(), any( IndexDescriptor.class ), - any( IndexConfiguration.class ), any( IndexSamplingConfig.class ) ) + when( mockedIndexProvider.getOnlineAccessor( + anyLong(), any( NewIndexDescriptor.class ), any( IndexSamplingConfig.class ) ) ).thenReturn( mock( IndexAccessor.class ) ); startDb(); createIndex( myLabel ); @@ -244,8 +234,7 @@ public void shouldKeepFailedIndexesAsFailedAfterRestart() throws Exception assertThat( getIndexes( db, myLabel ), inTx( db, hasSize( 1 ) ) ); assertThat( getIndexes( db, myLabel ), inTx( db, haveState( db, Schema.IndexState.FAILED ) ) ); verify( mockedIndexProvider, times( 2 ) ) - .getPopulator( anyLong(), any( IndexDescriptor.class ), any( IndexConfiguration.class ), - any( IndexSamplingConfig.class ) ); + .getPopulator( anyLong(), any( NewIndexDescriptor.class ), any( IndexSamplingConfig.class ) ); } private GraphDatabaseAPI db; diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/IndexSamplingCancellationTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/IndexSamplingCancellationTest.java index 358cf73dac45..06169e429b10 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/IndexSamplingCancellationTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/IndexSamplingCancellationTest.java @@ -30,8 +30,7 @@ import org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException; import org.neo4j.kernel.api.index.DelegatingIndexReader; import org.neo4j.kernel.api.index.IndexAccessor; -import org.neo4j.kernel.api.index.IndexConfiguration; -import org.neo4j.kernel.api.schema.IndexDescriptor; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; import org.neo4j.kernel.impl.api.index.inmemory.InMemoryIndexProvider; import org.neo4j.kernel.impl.api.index.inmemory.InMemoryIndexProviderFactory; import org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig; @@ -132,8 +131,8 @@ private class TestInMemoryIndexProvider extends InMemoryIndexProvider } @Override - public IndexAccessor getOnlineAccessor( long indexId, IndexDescriptor descriptor, - IndexConfiguration indexConfig, IndexSamplingConfig samplingConfig ) + public IndexAccessor getOnlineAccessor( long indexId, NewIndexDescriptor indexConfig, + IndexSamplingConfig samplingConfig ) { return new DelegatingIndexAccessor( super.getOnlineAccessor( indexId, descriptor, indexConfig, samplingConfig ) ); } diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/IndexStatisticsTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/IndexStatisticsTest.java index 1e4338896384..1d8abd671eda 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/IndexStatisticsTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/IndexStatisticsTest.java @@ -45,13 +45,15 @@ import org.neo4j.graphdb.Transaction; import org.neo4j.graphdb.factory.GraphDatabaseBuilder; import org.neo4j.graphdb.factory.GraphDatabaseSettings; -import org.neo4j.kernel.api.schema.NodePropertyDescriptor; import org.neo4j.kernel.api.Statement; import org.neo4j.kernel.api.exceptions.EntityNotFoundException; import org.neo4j.kernel.api.exceptions.KernelException; import org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException; -import org.neo4j.kernel.api.schema.IndexDescriptor; import org.neo4j.kernel.api.properties.Property; +import org.neo4j.kernel.api.schema.IndexDescriptor; +import org.neo4j.kernel.api.schema.NodePropertyDescriptor; +import org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor; +import org.neo4j.kernel.api.schema_new.SchemaDescriptorFactory; import org.neo4j.kernel.api.schema_new.index.IndexBoundary; import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; import org.neo4j.kernel.impl.core.ThreadToStatementContextBridge; @@ -693,9 +695,9 @@ private static class IndexOnlineMonitor extends IndexingService.MonitorAdapter private final Set onlineIndexes = Collections.newSetFromMap( new ConcurrentHashMap<>() ); @Override - public void populationCompleteOn( IndexDescriptor descriptor ) + public void populationCompleteOn( NewIndexDescriptor descriptor ) { - onlineIndexes.add( descriptor ); + onlineIndexes.add( IndexBoundary.map( descriptor ) ); } public boolean isIndexOnline( IndexDescriptor descriptor ) diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/IndexUpdaterMapTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/IndexUpdaterMapTest.java index 34617138c6b2..a8756f014a1b 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/IndexUpdaterMapTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/IndexUpdaterMapTest.java @@ -27,6 +27,7 @@ import org.neo4j.kernel.api.index.IndexUpdater; import org.neo4j.kernel.api.schema.IndexDescriptor; import org.neo4j.kernel.api.schema.IndexDescriptorFactory; +import org.neo4j.kernel.api.schema_new.index.IndexBoundary; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; @@ -61,13 +62,13 @@ public void before() throws IOException indexProxy1 = mock( IndexProxy.class ); indexDescriptor1 = IndexDescriptorFactory.of( 2, 3 ); indexUpdater1 = mock( IndexUpdater.class ); - when( indexProxy1.getDescriptor() ).thenReturn( indexDescriptor1 ); + when( indexProxy1.getDescriptor() ).thenReturn( IndexBoundary.map( indexDescriptor1 ) ); when( indexProxy1.newUpdater( any( IndexUpdateMode.class ) ) ).thenReturn( indexUpdater1 ); indexProxy2 = mock( IndexProxy.class ); indexDescriptor2 = IndexDescriptorFactory.of( 5, 6 ); IndexUpdater indexUpdater2 = mock( IndexUpdater.class ); - when( indexProxy2.getDescriptor() ).thenReturn( indexDescriptor2 ); + when( indexProxy2.getDescriptor() ).thenReturn( IndexBoundary.map( indexDescriptor2 ) ); when( indexProxy2.newUpdater( any( IndexUpdateMode.class ) ) ).thenReturn( indexUpdater2 ); updaterMap = new IndexUpdaterMap( indexMap, IndexUpdateMode.ONLINE ); diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/IndexingServiceTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/IndexingServiceTest.java index 0d4a535fb52e..d073807c78d8 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/IndexingServiceTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/IndexingServiceTest.java @@ -59,15 +59,13 @@ import org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException; import org.neo4j.kernel.api.exceptions.index.IndexPopulationFailedKernelException; import org.neo4j.kernel.api.index.IndexAccessor; -import org.neo4j.kernel.api.index.IndexConfiguration; import org.neo4j.kernel.api.index.IndexEntryUpdate; -import org.neo4j.kernel.api.schema.IndexDescriptor; -import org.neo4j.kernel.api.schema.IndexDescriptorFactory; import org.neo4j.kernel.api.index.IndexPopulator; import org.neo4j.kernel.api.index.IndexUpdater; import org.neo4j.kernel.api.index.InternalIndexState; import org.neo4j.kernel.api.index.NodeUpdates; import org.neo4j.kernel.api.index.SchemaIndexProvider; +import org.neo4j.kernel.api.schema_new.index.IndexBoundary; import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptorFactory; import org.neo4j.kernel.configuration.Config; @@ -325,8 +323,7 @@ public void shouldLogIndexStateOnInit() throws Exception // given SchemaIndexProvider provider = mock( SchemaIndexProvider.class ); when( provider.getProviderDescriptor() ).thenReturn( PROVIDER_DESCRIPTOR ); - when( provider.getOnlineAccessor( anyLong(), any( IndexDescriptor.class ), any( IndexConfiguration.class ), - any( IndexSamplingConfig.class ) ) ) + when( provider.getOnlineAccessor( anyLong(), any( NewIndexDescriptor.class ), any( IndexSamplingConfig.class ) ) ) .thenReturn( mock( IndexAccessor.class ) ); SchemaIndexProviderMap providerMap = new DefaultSchemaIndexProviderMap( provider ); TokenNameLookup mockLookup = mock( TokenNameLookup.class ); @@ -525,17 +522,17 @@ public void shouldLogTriggerSamplingOnAnIndexes() throws Exception // given long indexId = 0; IndexSamplingMode mode = TRIGGER_REBUILD_ALL; - IndexDescriptor descriptor = IndexDescriptorFactory.of( 0, 1 ); + NewIndexDescriptor descriptor = NewIndexDescriptorFactory.forLabel( 0, 1 ); IndexingService indexingService = newIndexingServiceWithMockedDependencies( populator, accessor, withData(), - indexRule( indexId, descriptor.getLabelId(), descriptor.getPropertyKeyId(), PROVIDER_DESCRIPTOR ) ); + IndexRule.indexRule( indexId, descriptor, PROVIDER_DESCRIPTOR ) ); life.init(); life.start(); // when - indexingService.triggerIndexSampling( descriptor, mode ); + indexingService.triggerIndexSampling( IndexBoundary.map( descriptor ), mode ); // then - String userDescription = descriptor.userDescription( nameLookup ); + String userDescription = descriptor.schema().userDescription( nameLookup ); logProvider.assertAtLeastOnce( logMatch.info( "Manual trigger for sampling index " + userDescription + " [" + mode + "]" ) ); @@ -611,10 +608,10 @@ public void closingOfValidatedUpdatesShouldCloseUpdaters() throws Exception IndexUpdater updater2 = mock( IndexUpdater.class ); when( accessor2.newUpdater( any( IndexUpdateMode.class ) ) ).thenReturn( updater2 ); - when( indexProvider.getOnlineAccessor( eq( 1L ), any( IndexDescriptor.class ), - any( IndexConfiguration.class ), any( IndexSamplingConfig.class ) ) ).thenReturn( accessor1 ); - when( indexProvider.getOnlineAccessor( eq( 2L ), any( IndexDescriptor.class ), - any( IndexConfiguration.class ), any( IndexSamplingConfig.class ) ) ).thenReturn( accessor2 ); + when( indexProvider.getOnlineAccessor( eq( 1L ), any( NewIndexDescriptor.class ), + any( IndexSamplingConfig.class ) ) ).thenReturn( accessor1 ); + when( indexProvider.getOnlineAccessor( eq( 2L ), any( NewIndexDescriptor.class ), + any( IndexSamplingConfig.class ) ) ).thenReturn( accessor2 ); life.start(); @@ -801,7 +798,7 @@ public void shouldWaitForRecoveredUniquenessConstraintIndexesToBeFullyPopulated( IndexingService.Monitor monitor = new IndexingService.MonitorAdapter() { @Override - public void awaitingPopulationOfRecoveredIndex( long index, IndexDescriptor descriptor ) + public void awaitingPopulationOfRecoveredIndex( long index, NewIndexDescriptor descriptor ) { // When we see that we start to await the index to populate, notify the slow-as-heck // populator that it can actually go and complete its job. @@ -843,12 +840,12 @@ public void shouldCreateMultipleIndexesInOneCall() throws Exception indexing.createIndexes( indexRule1, indexRule2, indexRule3 ); // THEN - verify( indexProvider ).getPopulator( eq( 0L ), eq( IndexDescriptorFactory.of( 0, 0 ) ), - eq( IndexConfiguration.NON_UNIQUE ), any( IndexSamplingConfig.class ) ); - verify( indexProvider ).getPopulator( eq( 1L ), eq( IndexDescriptorFactory.of( 0, 1 ) ), - eq( IndexConfiguration.NON_UNIQUE ), any( IndexSamplingConfig.class ) ); - verify( indexProvider ).getPopulator( eq( 2L ), eq( IndexDescriptorFactory.of( 1, 0 ) ), - eq( IndexConfiguration.NON_UNIQUE ), any( IndexSamplingConfig.class ) ); + verify( indexProvider ).getPopulator( eq( 0L ), eq( NewIndexDescriptorFactory.forLabel( 0, 0 ) ), + any( IndexSamplingConfig.class ) ); + verify( indexProvider ).getPopulator( eq( 1L ), eq( NewIndexDescriptorFactory.forLabel( 0, 1 ) ), + any( IndexSamplingConfig.class ) ); + verify( indexProvider ).getPopulator( eq( 2L ), eq( NewIndexDescriptorFactory.forLabel( 1, 0 ) ), + any( IndexSamplingConfig.class ) ); waitForIndexesToComeOnline( indexing, 0, 1, 2 ); } @@ -864,8 +861,8 @@ public void shouldStoreIndexFailureWhenFailingToCreateOnlineAccessorAfterPopulat when( nameLookup.labelGetName( labelId ) ).thenReturn( "TheLabel" ); when( nameLookup.propertyKeyGetName( propertyKeyId ) ).thenReturn( "propertyKey" ); - when( indexProvider.getOnlineAccessor( eq( indexId ), any( IndexDescriptor.class ), - any( IndexConfiguration.class ), any( IndexSamplingConfig.class ) ) ) + when( indexProvider.getOnlineAccessor( + eq( indexId ), any( NewIndexDescriptor.class ), any( IndexSamplingConfig.class ) ) ) .thenThrow( exception ); life.start(); @@ -900,8 +897,8 @@ public void shouldStoreIndexFailureWhenFailingToCreateOnlineAccessorAfterRecover when( nameLookup.propertyKeyGetName( propertyKeyId ) ).thenReturn( "propertyKey" ); when( indexProvider.getInitialState( indexId ) ).thenReturn( POPULATING ); - when( indexProvider.getOnlineAccessor( eq( indexId ), any( IndexDescriptor.class ), - any( IndexConfiguration.class ), any( IndexSamplingConfig.class ) ) ) + when( indexProvider.getOnlineAccessor( + eq( indexId ), any( NewIndexDescriptor.class ), any( IndexSamplingConfig.class ) ) ) .thenThrow( exception ); life.start(); @@ -1022,11 +1019,11 @@ private IndexingService newIndexingServiceWithMockedDependencies( IndexPopulator { when( indexProvider.getInitialState( anyLong() ) ).thenReturn( ONLINE ); when( indexProvider.getProviderDescriptor() ).thenReturn( PROVIDER_DESCRIPTOR ); - when( indexProvider.getPopulator( anyLong(), any( IndexDescriptor.class ), any( IndexConfiguration.class ), + when( indexProvider.getPopulator( anyLong(), any( NewIndexDescriptor.class ), any( IndexSamplingConfig.class ) ) ).thenReturn( populator ); data.getsProcessedByStoreScanFrom( storeView ); - when( indexProvider.getOnlineAccessor( anyLong(), any( IndexDescriptor.class ), - any( IndexConfiguration.class ), any( IndexSamplingConfig.class ) ) ) + when( indexProvider.getOnlineAccessor( anyLong(), any( NewIndexDescriptor.class ), + any( IndexSamplingConfig.class ) ) ) .thenReturn( accessor ); when( indexProvider.snapshotMetaFiles() ).thenReturn( Iterators.emptyIterator() ); when( indexProvider.storeMigrationParticipant( any( FileSystemAbstraction.class ), any( PageCache.class ), diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/MultipleIndexPopulatorTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/MultipleIndexPopulatorTest.java index 5c68f2e32536..68674269b045 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/MultipleIndexPopulatorTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/MultipleIndexPopulatorTest.java @@ -41,6 +41,7 @@ import org.neo4j.kernel.api.index.IndexUpdater; import org.neo4j.kernel.api.index.PropertyAccessor; import org.neo4j.kernel.api.index.SchemaIndexProvider; +import org.neo4j.kernel.api.schema_new.index.IndexBoundary; import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptorFactory; import org.neo4j.kernel.impl.api.index.MultipleIndexPopulator.IndexPopulation; @@ -433,20 +434,13 @@ private IndexPopulation addPopulator( MultipleIndexPopulator multipleIndexPopula flippableIndexProxy, failedIndexProxyFactory ); } - private IndexPopulation addPopulator( MultipleIndexPopulator multipleIndexPopulator, IndexPopulator indexPopulator, - long indexId, IndexDescriptor descriptor ) - { - return addPopulator( multipleIndexPopulator, indexId, descriptor, indexPopulator, - mock( FlippableIndexProxy.class ), mock( FailedIndexProxyFactory.class ) ); - } - private IndexPopulation addPopulator(MultipleIndexPopulator multipleIndexPopulator, long indexId, IndexDescriptor descriptor, IndexPopulator indexPopulator, FlippableIndexProxy flippableIndexProxy, FailedIndexProxyFactory failedIndexProxyFactory ) { - return multipleIndexPopulator.addPopulator( indexPopulator, indexId, descriptor, - mock( SchemaIndexProvider.Descriptor.class ), IndexConfiguration.NON_UNIQUE, - flippableIndexProxy, failedIndexProxyFactory, "userIndexDescription" ); + return multipleIndexPopulator.addPopulator( indexPopulator, indexId, IndexBoundary.map( descriptor ), + mock( SchemaIndexProvider.Descriptor.class ), flippableIndexProxy, + failedIndexProxyFactory, "userIndexDescription" ); } private IndexPopulation addPopulator( IndexPopulator indexPopulator, int id ) diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/MultipleIndexPopulatorUpdatesTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/MultipleIndexPopulatorUpdatesTest.java index f9773de57750..3aeecc9c7a35 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/MultipleIndexPopulatorUpdatesTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/MultipleIndexPopulatorUpdatesTest.java @@ -115,7 +115,7 @@ public void updateForHigherNodeIgnoredWhenUsingFullNodeStoreScan() IndexUpdater indexUpdater = mock( IndexUpdater.class ); when( populator.newPopulatingUpdater( storeView ) ).thenReturn( indexUpdater ); - addPopulator( indexPopulator, populator, 1, IndexDescriptorFactory.of( 1, 1 ) ); + addPopulator( indexPopulator, populator, 1, NewIndexDescriptorFactory.forLabel( 1, 1 ) ); indexPopulator.create(); StoreScan storeScan = indexPopulator.indexAllNodes(); @@ -151,19 +151,18 @@ private IndexPopulator createIndexPopulator() } private MultipleIndexPopulator.IndexPopulation addPopulator( MultipleIndexPopulator multipleIndexPopulator, - IndexPopulator indexPopulator, long indexId, IndexDescriptor descriptor ) + IndexPopulator indexPopulator, long indexId, NewIndexDescriptor descriptor ) { - return addPopulator( multipleIndexPopulator, indexId, descriptor, indexPopulator, mock( FlippableIndexProxy.class ), - mock( FailedIndexProxyFactory.class ) ); + return addPopulator( multipleIndexPopulator, indexId, descriptor, indexPopulator, + mock( FlippableIndexProxy.class ), mock( FailedIndexProxyFactory.class ) ); } private MultipleIndexPopulator.IndexPopulation addPopulator( MultipleIndexPopulator multipleIndexPopulator, - long indexId, IndexDescriptor descriptor, - IndexPopulator indexPopulator, + long indexId, NewIndexDescriptor descriptor, IndexPopulator indexPopulator, FlippableIndexProxy flippableIndexProxy, FailedIndexProxyFactory failedIndexProxyFactory ) { return multipleIndexPopulator.addPopulator( indexPopulator, indexId, descriptor, - mock( SchemaIndexProvider.Descriptor.class ), IndexConfiguration.NON_UNIQUE, + mock( SchemaIndexProvider.Descriptor.class ), flippableIndexProxy, failedIndexProxyFactory, "userIndexDescription" ); } diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/OnlineIndexProxyTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/OnlineIndexProxyTest.java index 0953e84bf237..a32f37ba4f82 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/OnlineIndexProxyTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/OnlineIndexProxyTest.java @@ -25,9 +25,9 @@ import org.neo4j.kernel.api.index.IndexAccessor; import org.neo4j.kernel.api.index.IndexConfiguration; -import org.neo4j.kernel.api.schema.IndexDescriptor; -import org.neo4j.kernel.api.schema.IndexDescriptorFactory; import org.neo4j.kernel.api.index.SchemaIndexProvider; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptorFactory; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; @@ -36,8 +36,7 @@ public class OnlineIndexProxyTest { private final long indexId = 1; - private final IndexDescriptor descriptor = IndexDescriptorFactory.of( 1, 2 ); - private final IndexConfiguration config = IndexConfiguration.NON_UNIQUE; + private final NewIndexDescriptor descriptor = NewIndexDescriptorFactory.forLabel( 1, 2 ); private final SchemaIndexProvider.Descriptor providerDescriptor = mock( SchemaIndexProvider.Descriptor.class ); private final IndexAccessor accessor = mock( IndexAccessor.class ); private final IndexStoreView storeView = mock( IndexStoreView.class ); @@ -46,7 +45,7 @@ public class OnlineIndexProxyTest public void shouldRemoveIndexCountsWhenTheIndexItselfIsDropped() throws IOException { // given - OnlineIndexProxy index = new OnlineIndexProxy( indexId, descriptor, config, accessor, + OnlineIndexProxy index = new OnlineIndexProxy( indexId, descriptor, accessor, storeView, providerDescriptor, false ); // when diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/inmemory/InMemoryIndexProvider.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/inmemory/InMemoryIndexProvider.java index a8689b151dd6..9a9d1580e76f 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/inmemory/InMemoryIndexProvider.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/inmemory/InMemoryIndexProvider.java @@ -24,16 +24,17 @@ import org.neo4j.io.fs.FileSystemAbstraction; import org.neo4j.io.pagecache.PageCache; import org.neo4j.kernel.api.index.IndexAccessor; -import org.neo4j.kernel.api.index.IndexConfiguration; -import org.neo4j.kernel.api.schema.IndexDescriptor; import org.neo4j.kernel.api.index.IndexPopulator; import org.neo4j.kernel.api.index.InternalIndexState; import org.neo4j.kernel.api.index.SchemaIndexProvider; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; import org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig; import org.neo4j.kernel.impl.api.scan.LabelScanStoreProvider; import org.neo4j.kernel.impl.storemigration.StoreMigrationParticipant; import org.neo4j.kernel.impl.util.CopyOnWriteHashMap; +import static org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor.Type.UNIQUE; + public class InMemoryIndexProvider extends SchemaIndexProvider { private final Map indexes; @@ -69,26 +70,25 @@ public StoreMigrationParticipant storeMigrationParticipant( FileSystemAbstractio } @Override - public IndexPopulator getPopulator( long indexId, IndexDescriptor descriptor, IndexConfiguration config, - IndexSamplingConfig samplingConfig ) + public IndexPopulator getPopulator( long indexId, NewIndexDescriptor descriptor, IndexSamplingConfig samplingConfig ) { // TODO: Consider supporting composite indexes - InMemoryIndex index = config.isUnique() - ? new UniqueInMemoryIndex( descriptor.getPropertyKeyId() ) : new InMemoryIndex(); + InMemoryIndex index = descriptor.type() == UNIQUE + ? new UniqueInMemoryIndex( descriptor.schema().getPropertyId() ) : new InMemoryIndex(); indexes.put( indexId, index ); return index.getPopulator(); } @Override - public IndexAccessor getOnlineAccessor( long indexId, IndexDescriptor descriptor, - IndexConfiguration indexConfig, IndexSamplingConfig samplingConfig ) + public IndexAccessor getOnlineAccessor( long indexId, NewIndexDescriptor descriptor, + IndexSamplingConfig samplingConfig ) { InMemoryIndex index = indexes.get( indexId ); if ( index == null || index.getState() != InternalIndexState.ONLINE ) { throw new IllegalStateException( "Index " + indexId + " not online yet" ); } - if ( indexConfig.isUnique() && !(index instanceof UniqueInMemoryIndex) ) + if ( descriptor.type() == UNIQUE && !(index instanceof UniqueInMemoryIndex) ) { throw new IllegalStateException( String.format( "The index [%s] was not created as a unique index.", indexId ) diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/sampling/IndexSamplingControllerTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/sampling/IndexSamplingControllerTest.java index de1f3e1c904b..638edd75b376 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/sampling/IndexSamplingControllerTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/sampling/IndexSamplingControllerTest.java @@ -22,12 +22,12 @@ import org.junit.Test; import java.util.concurrent.atomic.AtomicInteger; -import java.util.function.Predicate; import org.neo4j.function.Predicates; -import org.neo4j.kernel.api.schema.NodePropertyDescriptor; -import org.neo4j.kernel.api.schema.IndexDescriptor; import org.neo4j.kernel.api.schema.IndexDescriptorFactory; +import org.neo4j.kernel.api.schema.NodePropertyDescriptor; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptorFactory; import org.neo4j.kernel.impl.api.index.IndexMap; import org.neo4j.kernel.impl.api.index.IndexMapSnapshotProvider; import org.neo4j.kernel.impl.api.index.IndexProxy; @@ -354,7 +354,7 @@ private static class Always implements IndexSamplingController.RecoveryCondition } @Override - public boolean test( long indexId, IndexDescriptor descriptor ) + public boolean test( long indexId, NewIndexDescriptor descriptor ) { return ans; } @@ -371,16 +371,16 @@ public boolean test( long indexId, IndexDescriptor descriptor ) private final long anotherIndexId = 3; private final IndexProxy indexProxy = mock( IndexProxy.class ); private final IndexProxy anotherIndexProxy = mock( IndexProxy.class ); - private final NodePropertyDescriptor descriptor = new NodePropertyDescriptor( 3, 4 ); - private final NodePropertyDescriptor anotherDescriptor = new NodePropertyDescriptor( 5, 6 ); + private final NewIndexDescriptor descriptor = NewIndexDescriptorFactory.forLabel( 3, 4 ); + private final NewIndexDescriptor anotherDescriptor = NewIndexDescriptorFactory.forLabel( 5, 6 ); private final IndexSamplingJob job = mock( IndexSamplingJob.class ); private final IndexSamplingJob anotherJob = mock( IndexSamplingJob.class ); { when( samplingConfig.backgroundSampling() ).thenReturn( true ); when( samplingConfig.jobLimit() ).thenReturn( 1 ); - when( indexProxy.getDescriptor() ).thenReturn( IndexDescriptorFactory.of( descriptor ) ); - when( anotherIndexProxy.getDescriptor() ).thenReturn( IndexDescriptorFactory.of( anotherDescriptor ) ); + when( indexProxy.getDescriptor() ).thenReturn( descriptor ); + when( anotherIndexProxy.getDescriptor() ).thenReturn( anotherDescriptor ); when( snapshotProvider.indexMapSnapshot() ).thenReturn( indexMap ); when( jobFactory.create( indexId, indexProxy ) ).thenReturn( job ); when( jobFactory.create( anotherIndexId, anotherIndexProxy ) ).thenReturn( anotherJob ); diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/sampling/OnlineIndexSamplingJobTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/sampling/OnlineIndexSamplingJobTest.java index bff60f1781fc..688542d40642 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/sampling/OnlineIndexSamplingJobTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/sampling/OnlineIndexSamplingJobTest.java @@ -26,6 +26,8 @@ import org.neo4j.kernel.api.index.IndexConfiguration; import org.neo4j.kernel.api.schema.IndexDescriptor; import org.neo4j.kernel.api.schema.IndexDescriptorFactory; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptorFactory; import org.neo4j.kernel.impl.api.index.IndexProxy; import org.neo4j.kernel.impl.api.index.IndexStoreView; import org.neo4j.logging.LogProvider; @@ -76,7 +78,7 @@ public void shouldSampleTheIndexButDoNotStoreTheValuesIfTheIndexIsNotOnline() private final long indexId = 1; private final IndexProxy indexProxy = mock( IndexProxy.class ); private final IndexStoreView indexStoreView = mock( IndexStoreView.class ); - private final IndexDescriptor indexDescriptor = IndexDescriptorFactory.of( 1, 2 ); + private final NewIndexDescriptor indexDescriptor = NewIndexDescriptorFactory.forLabel( 1, 2 ); private final IndexReader indexReader = mock( IndexReader.class ); private final IndexSampler indexSampler = mock( IndexSampler.class ); @@ -87,7 +89,6 @@ public void shouldSampleTheIndexButDoNotStoreTheValuesIfTheIndexIsNotOnline() public void setup() throws IndexNotFoundKernelException { when( indexProxy.getDescriptor() ).thenReturn( indexDescriptor ); - when( indexProxy.config() ).thenReturn( IndexConfiguration.NON_UNIQUE ); when( indexProxy.newReader() ).thenReturn( indexReader ); when( indexReader.createSampler() ).thenReturn( indexSampler ); when( indexSampler.sampleIndex() ).thenReturn( new IndexSample( indexSize, indexUniqueValues, indexSize ) ); diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/state/storeview/LabelScanViewNodeStoreScanTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/state/storeview/LabelScanViewNodeStoreScanTest.java index 4a0969e759ab..dd682ddc69e2 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/state/storeview/LabelScanViewNodeStoreScanTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/state/storeview/LabelScanViewNodeStoreScanTest.java @@ -39,6 +39,7 @@ import org.neo4j.kernel.api.index.SchemaIndexProvider; import org.neo4j.kernel.api.labelscan.LabelScanStore; import org.neo4j.kernel.api.labelscan.NodeLabelUpdate; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; import org.neo4j.kernel.impl.api.index.FailedIndexProxyFactory; import org.neo4j.kernel.impl.api.index.FlippableIndexProxy; import org.neo4j.kernel.impl.api.index.IndexStoreView; @@ -156,7 +157,7 @@ private void populateWithConcurrentUpdates( LabelScanViewNodeStoreScan getLabelScanViewStoreScan( int[] labelIds ) @@ -175,14 +176,12 @@ public LabelScanTestMultipleIndexPopulator( IndexStoreView storeView, @Override public IndexPopulation createPopulation( IndexPopulator populator, long indexId, - IndexDescriptor descriptor, IndexConfiguration config, - SchemaIndexProvider.Descriptor providerDescriptor, + NewIndexDescriptor descriptor, SchemaIndexProvider.Descriptor providerDescriptor, FlippableIndexProxy flipper, FailedIndexProxyFactory failedIndexProxyFactory, String indexUserDescription ) { - return super.createPopulation( populator, indexId, descriptor, config, providerDescriptor, flipper, - failedIndexProxyFactory, - indexUserDescription ); + return super.createPopulation( populator, indexId, descriptor, providerDescriptor, flipper, + failedIndexProxyFactory, indexUserDescription ); } } diff --git a/community/kernel/src/test/java/org/neo4j/unsafe/batchinsert/internal/BatchInsertTest.java b/community/kernel/src/test/java/org/neo4j/unsafe/batchinsert/internal/BatchInsertTest.java index 6dcb066fd360..6fa597e117d4 100644 --- a/community/kernel/src/test/java/org/neo4j/unsafe/batchinsert/internal/BatchInsertTest.java +++ b/community/kernel/src/test/java/org/neo4j/unsafe/batchinsert/internal/BatchInsertTest.java @@ -59,8 +59,6 @@ import org.neo4j.helpers.collection.MapUtil; import org.neo4j.helpers.collection.Pair; import org.neo4j.io.pagecache.IOLimiter; -import org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException; -import org.neo4j.kernel.api.index.IndexConfiguration; import org.neo4j.kernel.api.index.IndexEntryUpdate; import org.neo4j.kernel.api.index.IndexPopulator; import org.neo4j.kernel.api.index.PropertyAccessor; @@ -920,8 +918,8 @@ public void shouldRunIndexPopulationJobAtShutdown() throws Throwable SchemaIndexProvider provider = mock( SchemaIndexProvider.class ); when( provider.getProviderDescriptor() ).thenReturn( InMemoryIndexProviderFactory.PROVIDER_DESCRIPTOR ); - when( provider.getPopulator( anyLong(), any( IndexDescriptor.class ), - any( IndexConfiguration.class ), any( IndexSamplingConfig.class ) ) ).thenReturn( populator ); + when( provider.getPopulator( anyLong(), any( NewIndexDescriptor.class ), any( IndexSamplingConfig.class ) ) ) + .thenReturn( populator ); BatchInserter inserter = newBatchInserterWithSchemaIndexProvider( singleInstanceSchemaIndexProviderFactory( InMemoryIndexProviderFactory.KEY, provider ) ); @@ -936,8 +934,7 @@ public void shouldRunIndexPopulationJobAtShutdown() throws Throwable // THEN verify( provider ).init(); verify( provider ).start(); - verify( provider ).getPopulator( anyLong(), any( IndexDescriptor.class ), any( IndexConfiguration.class ), - any( IndexSamplingConfig.class ) ); + verify( provider ).getPopulator( anyLong(), any( NewIndexDescriptor.class ), any( IndexSamplingConfig.class ) ); verify( populator ).create(); verify( populator ).add( singletonList( IndexEntryUpdate.add( nodeId, internalIndex, "Jakewins" ) ) ); verify( populator ).verifyDeferredConstraints( any( PropertyAccessor.class ) ); @@ -955,8 +952,8 @@ public void shouldRunConstraintPopulationJobAtShutdown() throws Throwable SchemaIndexProvider provider = mock( SchemaIndexProvider.class ); when( provider.getProviderDescriptor() ).thenReturn( InMemoryIndexProviderFactory.PROVIDER_DESCRIPTOR ); - when( provider.getPopulator( anyLong(), any( IndexDescriptor.class ), any( IndexConfiguration.class ), - any( IndexSamplingConfig.class ) ) ).thenReturn( populator ); + when( provider.getPopulator( anyLong(), any( NewIndexDescriptor.class ), any( IndexSamplingConfig.class ) ) ) + .thenReturn( populator ); BatchInserter inserter = newBatchInserterWithSchemaIndexProvider( singleInstanceSchemaIndexProviderFactory( InMemoryIndexProviderFactory.KEY, provider ) ); @@ -971,8 +968,7 @@ public void shouldRunConstraintPopulationJobAtShutdown() throws Throwable // THEN verify( provider ).init(); verify( provider ).start(); - verify( provider ).getPopulator( anyLong(), any( IndexDescriptor.class ), any( IndexConfiguration.class ), - any( IndexSamplingConfig.class ) ); + verify( provider ).getPopulator( anyLong(), any( NewIndexDescriptor.class ), any( IndexSamplingConfig.class ) ); verify( populator ).create(); verify( populator ).add( singletonList( IndexEntryUpdate.add( nodeId, internalUniqueIndex, "Jakewins" ) ) ); @@ -993,8 +989,8 @@ public void shouldRepopulatePreexistingIndexed() throws Throwable SchemaIndexProvider provider = mock( SchemaIndexProvider.class ); when( provider.getProviderDescriptor() ).thenReturn( InMemoryIndexProviderFactory.PROVIDER_DESCRIPTOR ); - when( provider.getPopulator( anyLong(), any( IndexDescriptor.class ), any( IndexConfiguration.class ), - any( IndexSamplingConfig.class ) ) ).thenReturn( populator ); + when( provider.getPopulator( anyLong(), any( NewIndexDescriptor.class ), any( IndexSamplingConfig.class ) ) ) + .thenReturn( populator ); BatchInserter inserter = newBatchInserterWithSchemaIndexProvider( singleInstanceSchemaIndexProviderFactory( InMemoryIndexProviderFactory.KEY, provider ) ); @@ -1007,8 +1003,7 @@ public void shouldRepopulatePreexistingIndexed() throws Throwable // THEN verify( provider ).init(); verify( provider ).start(); - verify( provider ).getPopulator( anyLong(), any( IndexDescriptor.class ), any( IndexConfiguration.class ), - any( IndexSamplingConfig.class ) ); + verify( provider ).getPopulator( anyLong(), any( NewIndexDescriptor.class ), any( IndexSamplingConfig.class ) ); verify( populator ).create(); verify( populator ).add( singletonList( IndexEntryUpdate.add( jakewins, internalIndex, "Jakewins" ) ) ); verify( populator ).add( singletonList( IndexEntryUpdate.add( boggle, internalIndex, "b0ggl3" ) ) ); @@ -1428,8 +1423,8 @@ private long dbWithIndexAndSingleIndexedNode() throws Exception SchemaIndexProvider provider = mock( SchemaIndexProvider.class ); when( provider.getProviderDescriptor() ).thenReturn( InMemoryIndexProviderFactory.PROVIDER_DESCRIPTOR ); - when( provider.getPopulator( anyLong(), any( IndexDescriptor.class ), any( IndexConfiguration.class ), - any( IndexSamplingConfig.class ) ) ).thenReturn( populator ); + when( provider.getPopulator( anyLong(), any( NewIndexDescriptor.class ), any( IndexSamplingConfig.class ) ) ) + .thenReturn( populator ); BatchInserter inserter = newBatchInserterWithSchemaIndexProvider( singleInstanceSchemaIndexProviderFactory( InMemoryIndexProviderFactory.KEY, provider ) ); diff --git a/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/LuceneSchemaIndexProvider.java b/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/LuceneSchemaIndexProvider.java index 5c7df87a95a5..56317c438452 100644 --- a/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/LuceneSchemaIndexProvider.java +++ b/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/LuceneSchemaIndexProvider.java @@ -33,10 +33,11 @@ import org.neo4j.kernel.api.impl.schema.populator.UniqueLuceneIndexPopulator; import org.neo4j.kernel.api.index.IndexAccessor; import org.neo4j.kernel.api.index.IndexConfiguration; -import org.neo4j.kernel.api.schema.IndexDescriptor; import org.neo4j.kernel.api.index.IndexPopulator; import org.neo4j.kernel.api.index.InternalIndexState; import org.neo4j.kernel.api.index.SchemaIndexProvider; +import org.neo4j.kernel.api.schema_new.index.IndexBoundary; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; import org.neo4j.kernel.configuration.Config; import org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig; import org.neo4j.kernel.impl.api.scan.LabelScanStoreProvider; @@ -46,6 +47,8 @@ import org.neo4j.logging.Log; import org.neo4j.logging.LogProvider; +import static org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor.Type.UNIQUE; + public class LuceneSchemaIndexProvider extends SchemaIndexProvider { private final IndexStorageFactory indexStorageFactory; @@ -78,9 +81,11 @@ protected IndexStorageFactory buildIndexStorageFactory( FileSystemAbstraction fi } @Override - public IndexPopulator getPopulator( long indexId, IndexDescriptor descriptor, - IndexConfiguration indexConfiguration, IndexSamplingConfig samplingConfig ) + public IndexPopulator getPopulator( long indexId, NewIndexDescriptor descriptor, IndexSamplingConfig samplingConfig ) { + IndexConfiguration indexConfiguration = + descriptor.type() == UNIQUE ? + IndexConfiguration.UNIQUE : IndexConfiguration.NON_UNIQUE; SchemaIndex luceneIndex = LuceneSchemaIndexBuilder.create() .withFileSystem( fileSystem ) .withIndexConfig( indexConfiguration ) @@ -96,7 +101,7 @@ public IndexPopulator getPopulator( long indexId, IndexDescriptor descriptor, } if ( indexConfiguration.isUnique() ) { - return new UniqueLuceneIndexPopulator( luceneIndex, descriptor ); + return new UniqueLuceneIndexPopulator( luceneIndex, IndexBoundary.map( descriptor ) ); } else { @@ -105,9 +110,12 @@ public IndexPopulator getPopulator( long indexId, IndexDescriptor descriptor, } @Override - public IndexAccessor getOnlineAccessor( long indexId, IndexDescriptor descriptor, - IndexConfiguration indexConfiguration, IndexSamplingConfig samplingConfig ) throws IOException + public IndexAccessor getOnlineAccessor( long indexId, NewIndexDescriptor descriptor, + IndexSamplingConfig samplingConfig ) throws IOException { + IndexConfiguration indexConfiguration = + descriptor.type() == UNIQUE ? + IndexConfiguration.UNIQUE : IndexConfiguration.NON_UNIQUE; SchemaIndex luceneIndex = LuceneSchemaIndexBuilder.create() .withIndexConfig( indexConfiguration ) .withConfig( config ) diff --git a/community/lucene-index/src/test/java/org/neo4j/index/impl/lucene/legacy/NonUniqueIndexTests.java b/community/lucene-index/src/test/java/org/neo4j/index/impl/lucene/legacy/NonUniqueIndexTests.java index 8d36ab0e3be9..d31b35727395 100644 --- a/community/lucene-index/src/test/java/org/neo4j/index/impl/lucene/legacy/NonUniqueIndexTests.java +++ b/community/lucene-index/src/test/java/org/neo4j/index/impl/lucene/legacy/NonUniqueIndexTests.java @@ -40,6 +40,7 @@ import org.neo4j.kernel.api.index.SchemaIndexProvider; import org.neo4j.kernel.api.schema.IndexDescriptorFactory; import org.neo4j.kernel.api.schema_new.IndexQuery; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptorFactory; import org.neo4j.kernel.configuration.Config; import org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig; import org.neo4j.kernel.impl.factory.CommunityEditionModule; @@ -155,10 +156,9 @@ private List nodeIdsInIndex( int indexId, String value ) throws IOExceptio Config config = Config.empty(); SchemaIndexProvider indexProvider = new LuceneSchemaIndexProvider( fileSystemRule.get(), DirectoryFactory.PERSISTENT, directory.graphDbDir(), NullLogProvider.getInstance(), Config.empty(), OperationalMode.single ); - IndexConfiguration indexConfig = IndexConfiguration.NON_UNIQUE; IndexSamplingConfig samplingConfig = new IndexSamplingConfig( config ); - try ( IndexAccessor accessor = indexProvider.getOnlineAccessor( indexId, IndexDescriptorFactory.of( 1, 2 ), - indexConfig, samplingConfig ); + try ( IndexAccessor accessor = indexProvider.getOnlineAccessor( indexId, + NewIndexDescriptorFactory.forLabel( 0, 0 ), samplingConfig ); IndexReader reader = accessor.newReader() ) { return PrimitiveLongCollections.asList( reader.query( IndexQuery.exact( 1, value ) ) ); diff --git a/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/LuceneSchemaIndexPopulatorTest.java b/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/LuceneSchemaIndexPopulatorTest.java index 5ead1b051c83..a19c4622caca 100644 --- a/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/LuceneSchemaIndexPopulatorTest.java +++ b/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/LuceneSchemaIndexPopulatorTest.java @@ -87,9 +87,8 @@ public void before() throws Exception provider = new LuceneSchemaIndexProvider( fs.get(), directoryFactory, testDir.directory( "folder" ), NullLogProvider.getInstance(), Config.empty(), OperationalMode.single ); indexStoreView = mock( IndexStoreView.class ); - IndexConfiguration indexConfig = IndexConfiguration.NON_UNIQUE; IndexSamplingConfig samplingConfig = new IndexSamplingConfig( Config.empty() ); - indexPopulator = provider.getPopulator( indexId, IndexBoundary.map( index ), indexConfig, samplingConfig ); + indexPopulator = provider.getPopulator( indexId, index, samplingConfig ); indexPopulator.create(); indexPopulator.configureSampling( true ); } diff --git a/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/LuceneSchemaIndexProviderTest.java b/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/LuceneSchemaIndexProviderTest.java index a5008378d860..74c95787808f 100644 --- a/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/LuceneSchemaIndexProviderTest.java +++ b/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/LuceneSchemaIndexProviderTest.java @@ -33,6 +33,8 @@ import org.neo4j.kernel.api.index.IndexAccessor; import org.neo4j.kernel.api.index.IndexConfiguration; import org.neo4j.kernel.api.schema.IndexDescriptorFactory; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptorFactory; import org.neo4j.kernel.configuration.Config; import org.neo4j.kernel.configuration.Settings; import org.neo4j.kernel.impl.api.index.IndexUpdateMode; @@ -56,8 +58,10 @@ public class LuceneSchemaIndexProviderTest @Rule public final TestDirectory testDir = TestDirectory.testDirectory( getClass() ); - protected File graphDbDir; - protected FileSystemAbstraction fs; + private File graphDbDir; + private FileSystemAbstraction fs; + private static final NewIndexDescriptor descriptor = NewIndexDescriptorFactory.forLabel( 1, 1 ); + @Before public void setup() @@ -74,9 +78,8 @@ public void shouldFailToInvokePopulatorInReadOnlyMode() throws Exception new DirectoryFactory.InMemoryDirectoryFactory(), fs, graphDbDir ); expectedException.expect( UnsupportedOperationException.class ); - readOnlyIndexProvider.getPopulator( 1L, IndexDescriptorFactory.of( 1, 1 ), - IndexConfiguration.NON_UNIQUE, - new IndexSamplingConfig( readOnlyConfig ) ); + readOnlyIndexProvider.getPopulator( 1L, descriptor, new IndexSamplingConfig( + readOnlyConfig ) ); } @Test @@ -118,8 +121,7 @@ private void createEmptySchemaIndex( DirectoryFactory directoryFactory ) throws private IndexAccessor getIndexAccessor( Config readOnlyConfig, LuceneSchemaIndexProvider indexProvider ) throws IOException { - return indexProvider.getOnlineAccessor( 1L, IndexDescriptorFactory.of( 1, 2 ), - IndexConfiguration.NON_UNIQUE, new IndexSamplingConfig( readOnlyConfig ) ); + return indexProvider.getOnlineAccessor( 1L, descriptor, new IndexSamplingConfig( readOnlyConfig ) ); } private LuceneSchemaIndexProvider getLuceneSchemaIndexProvider( Config config, DirectoryFactory directoryFactory, diff --git a/enterprise/ha/src/test/java/org/neo4j/kernel/api/SchemaIndexHaIT.java b/enterprise/ha/src/test/java/org/neo4j/kernel/api/SchemaIndexHaIT.java index 4cd936866739..b2823b5f19f4 100644 --- a/enterprise/ha/src/test/java/org/neo4j/kernel/api/SchemaIndexHaIT.java +++ b/enterprise/ha/src/test/java/org/neo4j/kernel/api/SchemaIndexHaIT.java @@ -51,14 +51,13 @@ import org.neo4j.kernel.api.impl.index.storage.DirectoryFactory; import org.neo4j.kernel.api.impl.schema.LuceneSchemaIndexProvider; import org.neo4j.kernel.api.index.IndexAccessor; -import org.neo4j.kernel.api.index.IndexConfiguration; import org.neo4j.kernel.api.index.IndexEntryUpdate; -import org.neo4j.kernel.api.schema.IndexDescriptor; import org.neo4j.kernel.api.index.IndexPopulator; import org.neo4j.kernel.api.index.IndexUpdater; import org.neo4j.kernel.api.index.InternalIndexState; import org.neo4j.kernel.api.index.PropertyAccessor; import org.neo4j.kernel.api.index.SchemaIndexProvider; +import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor; import org.neo4j.kernel.configuration.Config; import org.neo4j.kernel.extension.KernelExtensionFactory; import org.neo4j.kernel.ha.HighlyAvailableGraphDatabase; @@ -504,18 +503,18 @@ private static class ControlledSchemaIndexProvider extends SchemaIndexProvider } @Override - public IndexPopulator getPopulator( long indexId, IndexDescriptor descriptor, IndexConfiguration config, + public IndexPopulator getPopulator( long indexId, NewIndexDescriptor descriptor, IndexSamplingConfig samplingConfig ) { - IndexPopulator populator = delegate.getPopulator( indexId, descriptor, config, samplingConfig ); + IndexPopulator populator = delegate.getPopulator( indexId, descriptor, samplingConfig ); return new ControlledIndexPopulator( populator, latch ); } @Override - public IndexAccessor getOnlineAccessor( long indexId, IndexDescriptor descriptor, - IndexConfiguration config, IndexSamplingConfig samplingConfig ) throws IOException + public IndexAccessor getOnlineAccessor( long indexId, NewIndexDescriptor descriptor, + IndexSamplingConfig samplingConfig ) throws IOException { - return delegate.getOnlineAccessor(indexId, descriptor, config, samplingConfig ); + return delegate.getOnlineAccessor(indexId, descriptor, samplingConfig ); } @Override