diff --git a/community/kernel-api/src/main/java/org/neo4j/internal/kernel/api/IndexReference.java b/community/kernel-api/src/main/java/org/neo4j/internal/kernel/api/IndexReference.java index b8992f520e50..a1232a598043 100644 --- a/community/kernel-api/src/main/java/org/neo4j/internal/kernel/api/IndexReference.java +++ b/community/kernel-api/src/main/java/org/neo4j/internal/kernel/api/IndexReference.java @@ -34,6 +34,42 @@ */ public interface IndexReference extends IndexCapability { + /** + * Sorts indexes by type, returning first GENERAL indexes, followed by UNIQUE. Implementation is not suitable in + * hot path. + * + * @param indexes Indexes to sort + * @return sorted indexes + */ + static Iterator sortByType( Iterator indexes ) + { + List materialized = Iterators.asList( indexes ); + return Iterators.concat( + Iterators.filter( i -> !i.isUnique(), materialized.iterator() ), + Iterators.filter( IndexReference::isUnique, materialized.iterator() ) ); + + } + + boolean isUnique(); + + int label(); + + int[] properties(); + + String providerKey(); + + String providerVersion(); + + /** + * @param tokenNameLookup used for looking up names for token ids. + * @return a user friendly description of what this index indexes. + */ + default String userDescription( TokenNameLookup tokenNameLookup ) + { + String type = isUnique() ? "UNIQUE" : "GENERAL"; + return format( "Index( %s, %s )", type, SchemaUtil.niceProperties( tokenNameLookup, properties() ) ); + } + IndexReference NO_INDEX = new IndexReference() { @Override @@ -78,40 +114,4 @@ public String providerVersion() return null; } }; - - /** - * Sorts indexes by type, returning first GENERAL indexes, followed by UNIQUE. Implementation is not suitable in - * hot path. - * - * @param indexes Indexes to sort - * @return sorted indexes - */ - static Iterator sortByType( Iterator indexes ) - { - List materialized = Iterators.asList( indexes ); - return Iterators.concat( - Iterators.filter( i -> !i.isUnique(), materialized.iterator() ), - Iterators.filter( IndexReference::isUnique, materialized.iterator() ) ); - - } - - boolean isUnique(); - - int label(); - - int[] properties(); - - String providerKey(); - - String providerVersion(); - - /** - * @param tokenNameLookup used for looking up names for token ids. - * @return a user friendly description of what this index indexes. - */ - default String userDescription( TokenNameLookup tokenNameLookup ) - { - String type = isUnique() ? "UNIQUE" : "GENERAL"; - return format( "Index( %s, %s )", type, SchemaUtil.niceProperties( tokenNameLookup, properties() ) ); - } } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/state/ConstraintIndexCreator.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/state/ConstraintIndexCreator.java index 1a2e8966c5c1..edc6c0a0b05b 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/state/ConstraintIndexCreator.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/state/ConstraintIndexCreator.java @@ -173,8 +173,7 @@ public long createUniquenessConstraintIndex( KernelTransactionImplementation tra } } - private boolean indexStillExists( SchemaRead schemaRead, SchemaDescriptor descriptor, - IndexReference index ) + private boolean indexStillExists( SchemaRead schemaRead, SchemaDescriptor descriptor, IndexReference index ) { IndexReference existingIndex = schemaRead.index( descriptor.keyId(), descriptor.getPropertyIds() ); return existingIndex != IndexReference.NO_INDEX && existingIndex.equals( index ); diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/store/SchemaCache.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/store/SchemaCache.java index 70c395869000..4809c60bc4c9 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/store/SchemaCache.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/store/SchemaCache.java @@ -190,8 +190,7 @@ private static class SchemaCacheState private final Map,Object> dependantState; private final MutableIntObjectMap> indexByProperty; - SchemaCacheState( ConstraintSemantics constraintSemantics, Iterable rules, - IndexProviderMap indexProviderMap ) + SchemaCacheState( ConstraintSemantics constraintSemantics, Iterable rules, IndexProviderMap indexProviderMap ) { this.constraintSemantics = constraintSemantics; this.indexProviderMap = indexProviderMap; diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/NativeSchemaIndex.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/NativeSchemaIndex.java index 9602e27c5bf9..6712cf894688 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/NativeSchemaIndex.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/NativeSchemaIndex.java @@ -31,8 +31,8 @@ import org.neo4j.io.pagecache.PageCache; import org.neo4j.io.pagecache.PageCursor; import org.neo4j.kernel.api.index.IndexProvider; -import org.neo4j.kernel.api.schema.index.StoreIndexDescriptor; import org.neo4j.kernel.api.schema.index.IndexDescriptor; +import org.neo4j.kernel.api.schema.index.StoreIndexDescriptor; import static org.neo4j.helpers.Format.duration; import static org.neo4j.helpers.collection.MapUtil.map; diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/newapi/Operations.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/newapi/Operations.java index c639d37d19a4..ce434e2c5d36 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/newapi/Operations.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/newapi/Operations.java @@ -888,10 +888,7 @@ public IndexReference indexCreate( SchemaDescriptor descriptor, assertIndexDoesNotExist( SchemaKernelException.OperationContext.INDEX_CREATION, descriptor ); IndexProvider.Descriptor providerDescriptor = ktx.indexProviderForOrDefault( provider ); - IndexDescriptor index = - IndexDescriptorFactory.forSchema( descriptor, - name, - providerDescriptor ); + IndexDescriptor index = IndexDescriptorFactory.forSchema( descriptor, name, providerDescriptor ); ktx.txState().indexDoAdd( index ); return index; } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/storageengine/impl/recordstorage/RecordStorageReader.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/storageengine/impl/recordstorage/RecordStorageReader.java index 1de7f615636d..a09faf73c4fd 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/storageengine/impl/recordstorage/RecordStorageReader.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/storageengine/impl/recordstorage/RecordStorageReader.java @@ -307,8 +307,7 @@ public Long indexGetOwningUniquenessConstraintId( IndexDescriptor index ) } @Override - public long indexGetCommittedId( IndexDescriptor index ) - throws SchemaRuleNotFoundException + public long indexGetCommittedId( IndexDescriptor index ) throws SchemaRuleNotFoundException { StoreIndexDescriptor storeIndexDescriptor = getStoreIndexDescriptor( index ); if ( storeIndexDescriptor == null ) 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 0c980888e283..87a020591e4d 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 @@ -469,10 +469,8 @@ private void validateRelationshipConstraintCanBeCreated( int relTypeId, int prop private void createIndex( int labelId, int[] propertyKeyIds ) { LabelSchemaDescriptor schema = SchemaDescriptorFactory.forLabel( labelId, propertyKeyIds ); - StoreIndexDescriptor schemaRule = - IndexDescriptorFactory - .forSchema( schema, Optional.empty(), indexProviderMap.getDefaultProvider().getProviderDescriptor() ) - .withId( schemaStore.nextId() ); + IndexProvider.Descriptor providerDescriptor = indexProviderMap.getDefaultProvider().getProviderDescriptor(); + StoreIndexDescriptor schemaRule = IndexDescriptorFactory.forSchema( schema, Optional.empty(), providerDescriptor ).withId( schemaStore.nextId() ); for ( DynamicRecord record : schemaStore.allocateFrom( schemaRule ) ) { @@ -609,18 +607,10 @@ private void createUniqueIndexAndOwningConstraint( LabelSchemaDescriptor schema, long indexId = schemaStore.nextId(); long constraintRuleId = schemaStore.nextId(); - StoreIndexDescriptor storeIndexDescriptor = - IndexDescriptorFactory.uniqueForSchema( - schema, - this.indexProviderMap.getDefaultProvider().getProviderDescriptor() - ).withIds( indexId, constraintRuleId ); - - ConstraintRule constraintRule = - ConstraintRule.constraintRule( - constraintRuleId, - constraintDescriptor, - indexId - ); + IndexProvider.Descriptor providerDescriptor = this.indexProviderMap.getDefaultProvider().getProviderDescriptor(); + StoreIndexDescriptor storeIndexDescriptor = IndexDescriptorFactory.uniqueForSchema( schema, providerDescriptor ).withIds( indexId, constraintRuleId ); + + ConstraintRule constraintRule = ConstraintRule.constraintRule( constraintRuleId, constraintDescriptor, indexId ); for ( DynamicRecord record : schemaStore.allocateFrom( constraintRule ) ) { diff --git a/community/kernel/src/test/java/org/neo4j/kernel/api/index/CompositeIndexAccessorCompatibility.java b/community/kernel/src/test/java/org/neo4j/kernel/api/index/CompositeIndexAccessorCompatibility.java index 75ed54264cac..b46085e5191a 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/api/index/CompositeIndexAccessorCompatibility.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/api/index/CompositeIndexAccessorCompatibility.java @@ -43,8 +43,7 @@ " errors or warnings in some IDEs about test classes needing a public zero-arg constructor." ) public abstract class CompositeIndexAccessorCompatibility extends IndexAccessorCompatibility { - public CompositeIndexAccessorCompatibility( - IndexProviderCompatibilityTestSuite testSuite, IndexDescriptor descriptor ) + public CompositeIndexAccessorCompatibility( IndexProviderCompatibilityTestSuite testSuite, IndexDescriptor descriptor ) { super( testSuite, descriptor ); } diff --git a/community/kernel/src/test/java/org/neo4j/kernel/api/index/CompositeIndexPopulatorCompatibility.java b/community/kernel/src/test/java/org/neo4j/kernel/api/index/CompositeIndexPopulatorCompatibility.java index 8ecbe207426e..1367561fa688 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/api/index/CompositeIndexPopulatorCompatibility.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/api/index/CompositeIndexPopulatorCompatibility.java @@ -49,8 +49,7 @@ " errors or warnings in some IDEs about test classes needing a public zero-arg constructor." ) public class CompositeIndexPopulatorCompatibility extends IndexProviderCompatibilityTestSuite.Compatibility { - public CompositeIndexPopulatorCompatibility( - IndexProviderCompatibilityTestSuite testSuite, IndexDescriptor descriptor ) + public CompositeIndexPopulatorCompatibility( IndexProviderCompatibilityTestSuite testSuite, IndexDescriptor descriptor ) { super( testSuite, descriptor ); } diff --git a/community/kernel/src/test/java/org/neo4j/kernel/api/index/SimpleIndexAccessorCompatibility.java b/community/kernel/src/test/java/org/neo4j/kernel/api/index/SimpleIndexAccessorCompatibility.java index fe2d11de631d..7efadc7fcce8 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/api/index/SimpleIndexAccessorCompatibility.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/api/index/SimpleIndexAccessorCompatibility.java @@ -66,8 +66,7 @@ " errors or warnings in some IDEs about test classes needing a public zero-arg constructor." ) public abstract class SimpleIndexAccessorCompatibility extends IndexAccessorCompatibility { - public SimpleIndexAccessorCompatibility( IndexProviderCompatibilityTestSuite testSuite, - IndexDescriptor descriptor ) + public SimpleIndexAccessorCompatibility( IndexProviderCompatibilityTestSuite testSuite, IndexDescriptor descriptor ) { super( testSuite, descriptor ); } diff --git a/community/kernel/src/test/java/org/neo4j/kernel/api/index/SimpleIndexPopulatorCompatibility.java b/community/kernel/src/test/java/org/neo4j/kernel/api/index/SimpleIndexPopulatorCompatibility.java index dbc32770dd0d..5f0c2c04430c 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/api/index/SimpleIndexPopulatorCompatibility.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/api/index/SimpleIndexPopulatorCompatibility.java @@ -63,8 +63,7 @@ " errors or warnings in some IDEs about test classes needing a public zero-arg constructor." ) public class SimpleIndexPopulatorCompatibility extends IndexProviderCompatibilityTestSuite.Compatibility { - public SimpleIndexPopulatorCompatibility( - IndexProviderCompatibilityTestSuite testSuite, IndexDescriptor descriptor ) + public SimpleIndexPopulatorCompatibility( IndexProviderCompatibilityTestSuite testSuite, IndexDescriptor descriptor ) { super( testSuite, descriptor ); } diff --git a/community/kernel/src/test/java/org/neo4j/kernel/builtinprocs/BuiltInProceduresTest.java b/community/kernel/src/test/java/org/neo4j/kernel/builtinprocs/BuiltInProceduresTest.java index e2048076f015..12579a6cc709 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/builtinprocs/BuiltInProceduresTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/builtinprocs/BuiltInProceduresTest.java @@ -414,8 +414,7 @@ private void givenIndex( String label, String propKey ) int labelId = token( label, labels ); int propId = token( propKey, propKeys ); - IndexReference index = - IndexDescriptorFactory.forSchema( forLabel( labelId, propId ), InMemoryIndexProviderFactory.PROVIDER_DESCRIPTOR ); + IndexReference index = IndexDescriptorFactory.forSchema( forLabel( labelId, propId ), InMemoryIndexProviderFactory.PROVIDER_DESCRIPTOR ); indexes.add( index ); } @@ -424,8 +423,7 @@ private void givenUniqueConstraint( String label, String propKey ) int labelId = token( label, labels ); int propId = token( propKey, propKeys ); - IndexReference index = - IndexDescriptorFactory.uniqueForSchema( forLabel( labelId, propId ), InMemoryIndexProviderFactory.PROVIDER_DESCRIPTOR ); + IndexReference index = IndexDescriptorFactory.uniqueForSchema( forLabel( labelId, propId ), InMemoryIndexProviderFactory.PROVIDER_DESCRIPTOR ); uniqueIndexes.add( index ); constraints.add( ConstraintDescriptorFactory.uniqueForLabel( labelId, propId ) ); } 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 2c29fe9abf25..e9067906d1f7 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 @@ -33,10 +33,8 @@ import org.neo4j.kernel.api.exceptions.index.IndexPopulationFailedKernelException; import org.neo4j.kernel.api.index.IndexEntryUpdate; import org.neo4j.kernel.api.index.IndexPopulator; -import org.neo4j.kernel.api.index.IndexProvider; import org.neo4j.kernel.api.index.IndexUpdater; import org.neo4j.kernel.api.schema.index.IndexDescriptor; -import org.neo4j.kernel.api.schema.index.StoreIndexDescriptor; import org.neo4j.kernel.api.schema.index.TestIndexDescriptorFactory; import org.neo4j.kernel.impl.locking.LockService; import org.neo4j.kernel.impl.store.NeoStores; diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/LocalDateTimeUniqueSchemaIndexAccessorTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/LocalDateTimeUniqueSchemaIndexAccessorTest.java index 59b7d100fce0..9fcb53a1be32 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/LocalDateTimeUniqueSchemaIndexAccessorTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/LocalDateTimeUniqueSchemaIndexAccessorTest.java @@ -40,7 +40,6 @@ NativeSchemaIndexAccessor makeAccessor @Override protected LayoutTestUtil createLayoutTestUtil() { - return new UniqueLayoutTestUtil<>( new LocalDateTimeLayoutTestUtil( TestIndexDescriptorFactory - .uniqueForLabel( 42, 666 ) ) ); + return new UniqueLayoutTestUtil<>( new LocalDateTimeLayoutTestUtil( TestIndexDescriptorFactory.uniqueForLabel( 42, 666 ) ) ); } } diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/LocalTimeUniqueSchemaIndexPopulatorTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/LocalTimeUniqueSchemaIndexPopulatorTest.java index 08bbf3d371e4..a834cb50749f 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/LocalTimeUniqueSchemaIndexPopulatorTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/LocalTimeUniqueSchemaIndexPopulatorTest.java @@ -36,7 +36,6 @@ NativeSchemaIndexPopulator createPopulator @Override protected LayoutTestUtil createLayoutTestUtil() { - return new UniqueLayoutTestUtil<>( - new LocalTimeLayoutTestUtil( TestIndexDescriptorFactory.uniqueForLabel( 42, 666 ) ) ); + return new UniqueLayoutTestUtil<>( new LocalTimeLayoutTestUtil( TestIndexDescriptorFactory.uniqueForLabel( 42, 666 ) ) ); } } diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/NativeSchemaIndexAccessorTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/NativeSchemaIndexAccessorTest.java index f107f8450da8..8797f92317be 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/NativeSchemaIndexAccessorTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/NativeSchemaIndexAccessorTest.java @@ -206,8 +206,8 @@ public void shouldHandleRandomUpdates() throws Exception for ( int round = 0; round < rounds; round++ ) { // generate a batch of updates (add, change, remove) - IndexEntryUpdate[] batch = generateRandomUpdates( expectedData, newDataGenerator, - random.nextInt( 5, 20 ), (float) round / rounds * 2 ); + IndexEntryUpdate[] batch = + generateRandomUpdates( expectedData, newDataGenerator, random.nextInt( 5, 20 ), (float) round / rounds * 2 ); // apply to tree processAll( batch ); // apply to expectedData diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/NumberLayoutTestUtil.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/NumberLayoutTestUtil.java index 087851ba45d8..1845812db9ea 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/NumberLayoutTestUtil.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/NumberLayoutTestUtil.java @@ -26,14 +26,11 @@ import org.neo4j.internal.kernel.api.IndexQuery; import org.neo4j.kernel.api.index.IndexEntryUpdate; -import org.neo4j.kernel.api.schema.index.StoreIndexDescriptor; import org.neo4j.kernel.api.schema.index.IndexDescriptor; import org.neo4j.values.storable.NumberValue; import org.neo4j.values.storable.RandomValues; import org.neo4j.values.storable.Value; -import static org.neo4j.kernel.impl.api.index.TestIndexProviderDescriptor.PROVIDER_DESCRIPTOR; - abstract class NumberLayoutTestUtil extends LayoutTestUtil { private static final Number[] ALL_EXTREME_VALUES = new Number[] diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/SpatialLayoutTestUtil.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/SpatialLayoutTestUtil.java index bcfc79ba002d..c5856f9919ef 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/SpatialLayoutTestUtil.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/SpatialLayoutTestUtil.java @@ -28,7 +28,6 @@ import org.neo4j.index.internal.gbptree.Layout; import org.neo4j.internal.kernel.api.IndexQuery; import org.neo4j.kernel.api.index.IndexEntryUpdate; -import org.neo4j.kernel.api.schema.index.StoreIndexDescriptor; import org.neo4j.kernel.api.schema.index.IndexDescriptor; import org.neo4j.kernel.impl.index.schema.config.SpaceFillingCurveSettings; import org.neo4j.values.storable.CoordinateReferenceSystem; @@ -37,7 +36,6 @@ import org.neo4j.values.storable.Value; import org.neo4j.values.storable.Values; -import static org.neo4j.kernel.impl.api.index.TestIndexProviderDescriptor.PROVIDER_DESCRIPTOR; import static org.neo4j.values.storable.CoordinateReferenceSystem.WGS84; public class SpatialLayoutTestUtil extends LayoutTestUtil diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/SpatialNonUniqueSchemaIndexPopulatorTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/SpatialNonUniqueSchemaIndexPopulatorTest.java index fcb3671ebbfa..e099c38acb6c 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/SpatialNonUniqueSchemaIndexPopulatorTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/SpatialNonUniqueSchemaIndexPopulatorTest.java @@ -40,8 +40,7 @@ public class SpatialNonUniqueSchemaIndexPopulatorTest extends NativeNonUniqueSch NativeSchemaIndexPopulator createPopulator( IndexSamplingConfig samplingConfig ) { fileLayout = new SpatialIndexFiles.SpatialFileLayout( crs, settings, super.getIndexFile() ); - return new SpatialIndexPopulator.PartPopulator( pageCache, fs, fileLayout, monitor, indexDescriptor, samplingConfig, - new StandardConfiguration() ); + return new SpatialIndexPopulator.PartPopulator( pageCache, fs, fileLayout, monitor, indexDescriptor, samplingConfig, new StandardConfiguration() ); } @Override diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/SpatialUniqueSchemaIndexPopulatorTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/SpatialUniqueSchemaIndexPopulatorTest.java index f4f77f4de974..66a6af740901 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/SpatialUniqueSchemaIndexPopulatorTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/SpatialUniqueSchemaIndexPopulatorTest.java @@ -40,8 +40,7 @@ public class SpatialUniqueSchemaIndexPopulatorTest extends NativeUniqueSchemaInd NativeSchemaIndexPopulator createPopulator( IndexSamplingConfig samplingConfig ) { fileLayout = new SpatialIndexFiles.SpatialFileLayout( crs, settings, super.getIndexFile() ); - return new SpatialIndexPopulator.PartPopulator( pageCache, fs, fileLayout, monitor, indexDescriptor, samplingConfig, - new StandardConfiguration() ); + return new SpatialIndexPopulator.PartPopulator( pageCache, fs, fileLayout, monitor, indexDescriptor, samplingConfig, new StandardConfiguration() ); } @Override diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/TimeLayoutTestUtil.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/TimeLayoutTestUtil.java index d772c46483ed..0cad3806cca5 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/TimeLayoutTestUtil.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/TimeLayoutTestUtil.java @@ -29,15 +29,12 @@ import org.neo4j.index.internal.gbptree.Layout; import org.neo4j.internal.kernel.api.IndexQuery; import org.neo4j.kernel.api.index.IndexEntryUpdate; -import org.neo4j.kernel.api.schema.index.StoreIndexDescriptor; import org.neo4j.kernel.api.schema.index.IndexDescriptor; import org.neo4j.values.storable.RandomValues; import org.neo4j.values.storable.TimeValue; import org.neo4j.values.storable.Value; import org.neo4j.values.storable.Values; -import static org.neo4j.kernel.impl.api.index.TestIndexProviderDescriptor.PROVIDER_DESCRIPTOR; - public class TimeLayoutTestUtil extends LayoutTestUtil { static long MAX_NANOS_PER_DAY = 86399999999999L; diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/TimeNonUniqueSchemaIndexPopulatorTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/TimeNonUniqueSchemaIndexPopulatorTest.java index 42393f01996e..12b28276f871 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/TimeNonUniqueSchemaIndexPopulatorTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/TimeNonUniqueSchemaIndexPopulatorTest.java @@ -28,8 +28,7 @@ public class TimeNonUniqueSchemaIndexPopulatorTest extends NativeNonUniqueSchema @Override NativeSchemaIndexPopulator createPopulator( IndexSamplingConfig samplingConfig ) { - TemporalIndexFiles.FileLayout fileLayout = - new TemporalIndexFiles.FileLayout<>( getIndexFile(), layout, ValueGroup.ZONED_TIME ); + TemporalIndexFiles.FileLayout fileLayout = new TemporalIndexFiles.FileLayout<>( getIndexFile(), layout, ValueGroup.ZONED_TIME ); return new TemporalIndexPopulator.PartPopulator<>( pageCache, fs, fileLayout, monitor, indexDescriptor, samplingConfig ); } diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/TimeUniqueSchemaIndexAccessorTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/TimeUniqueSchemaIndexAccessorTest.java index a4640f7e5237..f7969bb012e7 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/TimeUniqueSchemaIndexAccessorTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/TimeUniqueSchemaIndexAccessorTest.java @@ -39,8 +39,7 @@ NativeSchemaIndexAccessor makeAccessorWith @Override protected LayoutTestUtil createLayoutTestUtil() { - return new UniqueLayoutTestUtil<>( - new TimeLayoutTestUtil( TestIndexDescriptorFactory.uniqueForLabel( 42, 666 ) ) ); + return new UniqueLayoutTestUtil<>( new TimeLayoutTestUtil( TestIndexDescriptorFactory.uniqueForLabel( 42, 666 ) ) ); } } diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/TimeUniqueSchemaIndexPopulatorTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/TimeUniqueSchemaIndexPopulatorTest.java index af014bef91cc..599e76ff318e 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/TimeUniqueSchemaIndexPopulatorTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/TimeUniqueSchemaIndexPopulatorTest.java @@ -28,15 +28,13 @@ public class TimeUniqueSchemaIndexPopulatorTest extends NativeUniqueSchemaIndexP @Override NativeSchemaIndexPopulator createPopulator( IndexSamplingConfig samplingConfig ) { - TemporalIndexFiles.FileLayout fileLayout = - new TemporalIndexFiles.FileLayout<>( getIndexFile(), layout, ValueGroup.ZONED_TIME ); + TemporalIndexFiles.FileLayout fileLayout = new TemporalIndexFiles.FileLayout<>( getIndexFile(), layout, ValueGroup.ZONED_TIME ); return new TemporalIndexPopulator.PartPopulator<>( pageCache, fs, fileLayout, monitor, indexDescriptor, samplingConfig ); } @Override protected LayoutTestUtil createLayoutTestUtil() { - return new UniqueLayoutTestUtil<>( - new TimeLayoutTestUtil( TestIndexDescriptorFactory.uniqueForLabel( 42, 666 ) ) ); + return new UniqueLayoutTestUtil<>( new TimeLayoutTestUtil( TestIndexDescriptorFactory.uniqueForLabel( 42, 666 ) ) ); } } diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/fusion/FusionIndexProviderTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/fusion/FusionIndexProviderTest.java index 6bedfa2eb5e4..5fa41bbc4aa2 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/fusion/FusionIndexProviderTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/fusion/FusionIndexProviderTest.java @@ -205,8 +205,7 @@ public void getPopulationFailureMustReportFailureWhenAnyFailed() } // then - assertThat( fusionIndexProvider.getPopulationFailure( AN_INDEX ), - containsString( failure ) ); + assertThat( fusionIndexProvider.getPopulationFailure( AN_INDEX ), containsString( failure ) ); } } diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/fusion/FusionIndexReaderTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/fusion/FusionIndexReaderTest.java index 3eb6f98f0b69..2ae3213cdb64 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/fusion/FusionIndexReaderTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/schema/fusion/FusionIndexReaderTest.java @@ -122,9 +122,9 @@ private void initiateMocks() throw new RuntimeException(); } } - fusionIndexReader = new FusionIndexReader( fusionVersion.slotSelector(), new LazyInstanceSelector<>( readers, throwingFactory() ), - TestIndexDescriptorFactory.forLabel( LABEL_KEY, PROP_KEY ) ); - } + fusionIndexReader = new FusionIndexReader( fusionVersion.slotSelector(), new LazyInstanceSelector<>( readers, throwingFactory() ), + TestIndexDescriptorFactory + .forLabel( LABEL_KEY, PROP_KEY ) );} private IntFunction throwingFactory() { diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/store/SchemaStorageTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/store/SchemaStorageTest.java index 1c3173605c2c..34d5537d07d8 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/store/SchemaStorageTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/store/SchemaStorageTest.java @@ -363,23 +363,20 @@ private StoreIndexDescriptor makeIndexRule( long ruleId, String label, String pr return forSchema( forLabel( labelId( label ), propId( propertyKey ) ), PROVIDER_DESCRIPTOR ).withId( ruleId ); } - private StoreIndexDescriptor makeIndexRuleForConstraint( long ruleId, String label, String propertyKey, - long constraintId ) + private StoreIndexDescriptor makeIndexRuleForConstraint( long ruleId, String label, String propertyKey, long constraintId ) { return uniqueForSchema( forLabel( labelId( label ), propId( propertyKey ) ), PROVIDER_DESCRIPTOR ).withIds( ruleId, constraintId ); } private ConstraintRule getUniquePropertyConstraintRule( long id, String label, String property ) { - return ConstraintRule.constraintRule( id, - ConstraintDescriptorFactory.uniqueForLabel( labelId( label ), propId( property ) ), 0L ); + return ConstraintRule.constraintRule( id, ConstraintDescriptorFactory.uniqueForLabel( labelId( label ), propId( property ) ), 0L ); } private ConstraintRule getRelationshipPropertyExistenceConstraintRule( long id, String type, String property ) { - return ConstraintRule.constraintRule( id, - ConstraintDescriptorFactory.existsForRelType( typeId( type ), propId( property ) ) ); + return ConstraintRule.constraintRule( id, ConstraintDescriptorFactory.existsForRelType( typeId( type ), propId( property ) ) ); } private static int labelId( String labelName ) diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/store/SchemaStoreTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/store/SchemaStoreTest.java index 9c5c4d99ebae..fd46ea296540 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/store/SchemaStoreTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/store/SchemaStoreTest.java @@ -36,7 +36,6 @@ import org.neo4j.kernel.api.schema.constaints.ConstraintDescriptorFactory; import org.neo4j.kernel.api.schema.index.IndexDescriptorFactory; import org.neo4j.kernel.api.schema.index.StoreIndexDescriptor; -import org.neo4j.kernel.api.schema.index.TestIndexDescriptorFactory; import org.neo4j.kernel.configuration.Config; import org.neo4j.kernel.impl.store.id.DefaultIdGeneratorFactory; import org.neo4j.kernel.impl.store.record.ConstraintRule; @@ -89,8 +88,7 @@ public void after() public void storeAndLoadSchemaRule() throws Exception { // GIVEN - StoreIndexDescriptor indexRule = forSchema( forLabel( 1, 4 ), - PROVIDER_DESCRIPTOR ).withId( store.nextId() ); + StoreIndexDescriptor indexRule = forSchema( forLabel( 1, 4 ), PROVIDER_DESCRIPTOR ).withId( store.nextId() ); // WHEN StoreIndexDescriptor readIndexRule = (StoreIndexDescriptor) SchemaRuleSerialization.deserialize( @@ -108,8 +106,7 @@ public void storeAndLoadCompositeSchemaRule() throws Exception { // GIVEN int[] propertyIds = {4, 5, 6, 7}; - StoreIndexDescriptor indexRule = forSchema( forLabel( 2, propertyIds ), - PROVIDER_DESCRIPTOR ).withId( store.nextId() ); + StoreIndexDescriptor indexRule = forSchema( forLabel( 2, propertyIds ), PROVIDER_DESCRIPTOR ).withId( store.nextId() ); // WHEN StoreIndexDescriptor readIndexRule = (StoreIndexDescriptor) SchemaRuleSerialization.deserialize( @@ -126,8 +123,7 @@ public void storeAndLoadCompositeSchemaRule() throws Exception public void storeAndLoad_Big_CompositeSchemaRule() throws Exception { // GIVEN - StoreIndexDescriptor indexRule = forSchema( forLabel( 2, IntStream.range( 1, 200).toArray() ), - PROVIDER_DESCRIPTOR ).withId( store.nextId() ); + StoreIndexDescriptor indexRule = forSchema( forLabel( 2, IntStream.range( 1, 200 ).toArray() ), PROVIDER_DESCRIPTOR ).withId( store.nextId() ); // WHEN StoreIndexDescriptor readIndexRule = (StoreIndexDescriptor) SchemaRuleSerialization.deserialize( @@ -176,28 +172,23 @@ private long storeRule( SchemaRule rule ) return Iterables.first( records ).getId(); } - private StoreIndexDescriptor indexRule( long ruleId, IndexProvider.Descriptor descriptor, - int labelId, int... propertyIds ) + private StoreIndexDescriptor indexRule( long ruleId, IndexProvider.Descriptor descriptor, int labelId, int... propertyIds ) { return IndexDescriptorFactory.forSchema( forLabel( labelId, propertyIds ), descriptor ).withId( ruleId ); } - private StoreIndexDescriptor uniqueIndexRule( long ruleId, long owningConstraint, - IndexProvider.Descriptor descriptor, int labelId, int... propertyIds ) + private StoreIndexDescriptor uniqueIndexRule( long ruleId, long owningConstraint, IndexProvider.Descriptor descriptor, int labelId, int... propertyIds ) { - return IndexDescriptorFactory.uniqueForSchema( forLabel( labelId, propertyIds ), descriptor ) - .withIds( ruleId, owningConstraint ); + return IndexDescriptorFactory.uniqueForSchema( forLabel( labelId, propertyIds ), descriptor ).withIds( ruleId, owningConstraint ); } private ConstraintRule constraintUniqueRule( long ruleId, long ownedIndexId, int labelId, int... propertyIds ) { - return ConstraintRule.constraintRule( ruleId, - ConstraintDescriptorFactory.uniqueForLabel( labelId, propertyIds ), ownedIndexId ); + return ConstraintRule.constraintRule( ruleId, ConstraintDescriptorFactory.uniqueForLabel( labelId, propertyIds ), ownedIndexId ); } private ConstraintRule constraintExistsRule( long ruleId, int labelId, int... propertyIds ) { - return ConstraintRule.constraintRule( ruleId, - ConstraintDescriptorFactory.existsForLabel( labelId, propertyIds ) ); + return ConstraintRule.constraintRule( ruleId, ConstraintDescriptorFactory.existsForLabel( labelId, propertyIds ) ); } } diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/store/record/SchemaRuleSerializationTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/store/record/SchemaRuleSerializationTest.java index cbe61f3c6f45..efef63dc7733 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/store/record/SchemaRuleSerializationTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/store/record/SchemaRuleSerializationTest.java @@ -51,8 +51,7 @@ public class SchemaRuleSerializationTest extends SchemaRuleTestBase StoreIndexDescriptor indexCompositeRegular = forLabel( LABEL_ID, PROPERTY_ID_1, PROPERTY_ID_2 ).withId( RULE_ID ); - StoreIndexDescriptor indexCompositeUnique = - uniqueForLabel( LABEL_ID, PROPERTY_ID_1, PROPERTY_ID_2 ).withIds( RULE_ID_2, RULE_ID ); + StoreIndexDescriptor indexCompositeUnique = uniqueForLabel( LABEL_ID, PROPERTY_ID_1, PROPERTY_ID_2 ).withIds( RULE_ID_2, RULE_ID ); StoreIndexDescriptor indexBigComposite = forLabel( LABEL_ID, IntStream.range(1, 200).toArray() ).withId( RULE_ID ); @@ -431,8 +430,7 @@ private void assertParseIndexRule( String serialized, String name ) throws Excep byte[] bytes = decodeBase64( serialized ); // WHEN - StoreIndexDescriptor - deserialized = assertIndexRule( SchemaRuleSerialization.deserialize( ruleId, ByteBuffer.wrap( bytes ) ) ); + StoreIndexDescriptor deserialized = assertIndexRule( SchemaRuleSerialization.deserialize( ruleId, ByteBuffer.wrap( bytes ) ) ); // THEN assertThat( deserialized.getId(), equalTo( ruleId ) ); @@ -453,8 +451,7 @@ private void assertParseUniqueIndexRule( String serialized, String name ) throws byte[] bytes = decodeBase64( serialized ); // WHEN - StoreIndexDescriptor - deserialized = assertIndexRule( SchemaRuleSerialization.deserialize( ruleId, ByteBuffer.wrap( bytes ) ) ); + StoreIndexDescriptor deserialized = assertIndexRule( SchemaRuleSerialization.deserialize( ruleId, ByteBuffer.wrap( bytes ) ) ); // THEN assertThat( deserialized.getId(), equalTo( ruleId ) ); diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/store/record/SchemaRuleTestBase.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/store/record/SchemaRuleTestBase.java index 40871562d180..317270f682d9 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/store/record/SchemaRuleTestBase.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/store/record/SchemaRuleTestBase.java @@ -38,11 +38,7 @@ abstract class SchemaRuleTestBase protected static final int PROPERTY_ID_1 = 30; protected static final int PROPERTY_ID_2 = 31; - protected static final IndexProvider.Descriptor PROVIDER_DESCRIPTOR = - new IndexProvider.Descriptor( "index-provider", "1.0" ); - - protected static final IndexProvider.Descriptor PROVIDER_DESCRIPTOR_2 = - new IndexProvider.Descriptor( "index-provider-2", "2.0" ); + protected static final IndexProvider.Descriptor PROVIDER_DESCRIPTOR = new IndexProvider.Descriptor( "index-provider", "1.0" ); protected void assertEquality( Object o1, Object o2 ) { diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/command/NeoStoreTransactionApplierTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/command/NeoStoreTransactionApplierTest.java index c504660146fc..8e588fec8016 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/command/NeoStoreTransactionApplierTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/command/NeoStoreTransactionApplierTest.java @@ -563,8 +563,7 @@ public void shouldApplyCreateIndexRuleSchemaRuleCommandToTheStore() throws Excep record.setCreated(); final Collection recordsAfter = singletonList( record ); final StoreIndexDescriptor rule = indexRule( 0, 1, 2, new IndexProvider.Descriptor( "K", "X.Y" ) ); - final Command.SchemaRuleCommand command = - new Command.SchemaRuleCommand( Collections.emptyList(), recordsAfter, rule ); + final Command.SchemaRuleCommand command = new Command.SchemaRuleCommand( Collections.emptyList(), recordsAfter, rule ); // when boolean result = apply( applier, command::handle, transactionToApply ); @@ -586,8 +585,7 @@ public void shouldApplyCreateIndexRuleSchemaRuleCommandToTheStoreInRecovery() th record.setCreated(); final Collection recordsAfter = singletonList( record ); final StoreIndexDescriptor rule = indexRule( 0, 1, 2, new IndexProvider.Descriptor( "K", "X.Y" ) ); - final Command.SchemaRuleCommand command = - new Command.SchemaRuleCommand( Collections.emptyList(), recordsAfter, rule ); + final Command.SchemaRuleCommand command = new Command.SchemaRuleCommand( Collections.emptyList(), recordsAfter, rule ); // when boolean result = apply( applier, command::handle, transactionToApply ); @@ -608,10 +606,8 @@ public void shouldApplyUpdateIndexRuleSchemaRuleCommandToTheStore() throws Excep final BatchTransactionApplier applier = newApplierFacade( newIndexApplier(), newApplier( false ) ); final DynamicRecord record = DynamicRecord.dynamicRecord( 21, true ); final Collection recordsAfter = singletonList( record ); - final StoreIndexDescriptor rule = - constraintIndexRule( 0, 1, 2, new IndexProvider.Descriptor( "K", "X.Y" ), 42L ); - final Command.SchemaRuleCommand command = - new Command.SchemaRuleCommand( Collections.emptyList(), recordsAfter, rule ); + final StoreIndexDescriptor rule = constraintIndexRule( 0, 1, 2, new IndexProvider.Descriptor( "K", "X.Y" ), 42L ); + final Command.SchemaRuleCommand command = new Command.SchemaRuleCommand( Collections.emptyList(), recordsAfter, rule ); // when boolean result = apply( applier, command::handle, transactionToApply ); @@ -631,10 +627,8 @@ public void shouldApplyUpdateIndexRuleSchemaRuleCommandToTheStoreInRecovery() th final BatchTransactionApplier applier = newApplierFacade( newIndexApplier(), newApplier( true ) ); final DynamicRecord record = DynamicRecord.dynamicRecord( 21, true ); final Collection recordsAfter = singletonList( record ); - final StoreIndexDescriptor rule = - constraintIndexRule( 0, 1, 2, new IndexProvider.Descriptor( "K", "X.Y" ), 42L ); - final Command.SchemaRuleCommand command = - new Command.SchemaRuleCommand( Collections.emptyList(), recordsAfter, rule ); + final StoreIndexDescriptor rule = constraintIndexRule( 0, 1, 2, new IndexProvider.Descriptor( "K", "X.Y" ), 42L ); + final Command.SchemaRuleCommand command = new Command.SchemaRuleCommand( Collections.emptyList(), recordsAfter, rule ); // when boolean result = apply( applier, command::handle, transactionToApply ); @@ -659,10 +653,8 @@ public void shouldApplyUpdateIndexRuleSchemaRuleCommandToTheStoreThrowingIndexPr final DynamicRecord record = DynamicRecord.dynamicRecord( 21, true ); final Collection recordsAfter = singletonList( record ); - final StoreIndexDescriptor rule = - constraintIndexRule( 0, 1, 2, new IndexProvider.Descriptor( "K", "X.Y" ), 42L ); - final Command.SchemaRuleCommand command = - new Command.SchemaRuleCommand( Collections.emptyList(), recordsAfter, rule ); + final StoreIndexDescriptor rule = constraintIndexRule( 0, 1, 2, new IndexProvider.Descriptor( "K", "X.Y" ), 42L ); + final Command.SchemaRuleCommand command = new Command.SchemaRuleCommand( Collections.emptyList(), recordsAfter, rule ); // when try @@ -688,8 +680,7 @@ public void shouldApplyDeleteIndexRuleSchemaRuleCommandToTheStore() throws Excep record.setInUse( false ); final Collection recordsAfter = singletonList( record ); final StoreIndexDescriptor rule = indexRule( 0, 1, 2, new IndexProvider.Descriptor( "K", "X.Y" ) ); - final Command.SchemaRuleCommand command = - new Command.SchemaRuleCommand( Collections.emptyList(), recordsAfter, rule ); + final Command.SchemaRuleCommand command = new Command.SchemaRuleCommand( Collections.emptyList(), recordsAfter, rule ); // when boolean result = apply( applier, command::handle, transactionToApply ); @@ -711,8 +702,7 @@ public void shouldApplyDeleteIndexRuleSchemaRuleCommandToTheStoreInRecovery() th record.setInUse( false ); final Collection recordsAfter = singletonList( record ); final StoreIndexDescriptor rule = indexRule( 0, 1, 2, new IndexProvider.Descriptor( "K", "X.Y" ) ); - final Command.SchemaRuleCommand command = - new Command.SchemaRuleCommand( Collections.emptyList(), recordsAfter, rule ); + final Command.SchemaRuleCommand command = new Command.SchemaRuleCommand( Collections.emptyList(), recordsAfter, rule ); // when boolean result = apply( applier, command::handle, transactionToApply ); @@ -735,8 +725,7 @@ public void shouldApplyCreateUniquenessConstraintRuleSchemaRuleCommandToTheStore record.setCreated(); final Collection recordsAfter = singletonList( record ); final ConstraintRule rule = uniquenessConstraintRule( 0L, 1, 2, 3L ); - final Command.SchemaRuleCommand command = - new Command.SchemaRuleCommand( Collections.emptyList(), recordsAfter, rule ); + final Command.SchemaRuleCommand command = new Command.SchemaRuleCommand( Collections.emptyList(), recordsAfter, rule ); // when boolean result = apply( applier, command::handle, transactionToApply ); @@ -758,8 +747,7 @@ public void shouldApplyCreateUniquenessConstraintRuleSchemaRuleCommandToTheStore record.setCreated(); final Collection recordsAfter = singletonList( record ); final ConstraintRule rule = uniquenessConstraintRule( 0L, 1, 2, 3L ); - final Command.SchemaRuleCommand command = - new Command.SchemaRuleCommand( Collections.emptyList(), recordsAfter, rule ); + final Command.SchemaRuleCommand command = new Command.SchemaRuleCommand( Collections.emptyList(), recordsAfter, rule ); // when boolean result = apply( applier, command::handle, transactionToApply ); @@ -781,8 +769,7 @@ public void shouldApplyUpdateUniquenessConstraintRuleSchemaRuleCommandToTheStore final DynamicRecord record = DynamicRecord.dynamicRecord( 21, true ); final Collection recordsAfter = singletonList( record ); final ConstraintRule rule = uniquenessConstraintRule( 0L, 1, 2, 3L ); - final Command.SchemaRuleCommand command = - new Command.SchemaRuleCommand( Collections.emptyList(), recordsAfter, rule ); + final Command.SchemaRuleCommand command = new Command.SchemaRuleCommand( Collections.emptyList(), recordsAfter, rule ); // when boolean result = apply( applier, command::handle, transactionToApply ); @@ -803,8 +790,7 @@ public void shouldApplyUpdateUniquenessConstraintRuleSchemaRuleCommandToTheStore final DynamicRecord record = DynamicRecord.dynamicRecord( 21, true ); final Collection recordsAfter = singletonList( record ); final ConstraintRule rule = uniquenessConstraintRule( 0L, 1, 2, 3L ); - final Command.SchemaRuleCommand command = - new Command.SchemaRuleCommand( Collections.emptyList(), recordsAfter, rule ); + final Command.SchemaRuleCommand command = new Command.SchemaRuleCommand( Collections.emptyList(), recordsAfter, rule ); // when boolean result = apply( applier, command::handle, transactionToApply ); @@ -827,8 +813,7 @@ public void shouldApplyDeleteUniquenessConstraintRuleSchemaRuleCommandToTheStore record.setInUse( false ); final Collection recordsAfter = singletonList( record ); final ConstraintRule rule = uniquenessConstraintRule( 0L, 1, 2, 3L ); - final Command.SchemaRuleCommand command = - new Command.SchemaRuleCommand( Collections.emptyList(), recordsAfter, rule ); + final Command.SchemaRuleCommand command = new Command.SchemaRuleCommand( Collections.emptyList(), recordsAfter, rule ); // when boolean result = apply( applier, command::handle, transactionToApply ); @@ -850,8 +835,7 @@ public void shouldApplyDeleteUniquenessConstraintRuleSchemaRuleCommandToTheStore record.setInUse( false ); final Collection recordsAfter = singletonList( record ); final ConstraintRule rule = uniquenessConstraintRule( 0L, 1, 2, 3L ); - final Command.SchemaRuleCommand command = - new Command.SchemaRuleCommand( Collections.emptyList(), recordsAfter, rule ); + final Command.SchemaRuleCommand command = new Command.SchemaRuleCommand( Collections.emptyList(), recordsAfter, rule ); // when boolean result = apply( applier, command::handle, transactionToApply ); @@ -930,25 +914,19 @@ private BatchTransactionApplier newIndexApplier() // SCHEMA RULE COMMAND - public static StoreIndexDescriptor indexRule( long id, int label, int propertyKeyId, - IndexProvider.Descriptor providerDescriptor ) + public static StoreIndexDescriptor indexRule( long id, int label, int propertyKeyId, IndexProvider.Descriptor providerDescriptor ) { - return IndexDescriptorFactory.forSchema( forLabel( label, propertyKeyId ), providerDescriptor ) - .withId( id ); + return IndexDescriptorFactory.forSchema( forLabel( label, propertyKeyId ), providerDescriptor ).withId( id ); } - private static StoreIndexDescriptor constraintIndexRule( long id, int label, int propertyKeyId, - IndexProvider.Descriptor providerDescriptor, Long owningConstraint ) + private static StoreIndexDescriptor constraintIndexRule( long id, int label, int propertyKeyId, IndexProvider.Descriptor providerDescriptor, + Long owningConstraint ) { - return IndexDescriptorFactory.uniqueForSchema( forLabel( label, propertyKeyId ), providerDescriptor ) - .withIds( id, owningConstraint ); + return IndexDescriptorFactory.uniqueForSchema( forLabel( label, propertyKeyId ), providerDescriptor ).withIds( id, owningConstraint ); } - private static ConstraintRule uniquenessConstraintRule( long id, int labelId, int propertyKeyId, - long ownedIndexRule ) + private static ConstraintRule uniquenessConstraintRule( long id, int labelId, int propertyKeyId, long ownedIndexRule ) { - return ConstraintRule.constraintRule( id, - ConstraintDescriptorFactory.uniqueForLabel( labelId, propertyKeyId ), - ownedIndexRule ); + return ConstraintRule.constraintRule( id, ConstraintDescriptorFactory.uniqueForLabel( labelId, propertyKeyId ), ownedIndexRule ); } } diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/util/dbstructure/DbStructureInvocationTracingAcceptanceTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/util/dbstructure/DbStructureInvocationTracingAcceptanceTest.java index c166aeced6c0..3a9cb1c75a86 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/util/dbstructure/DbStructureInvocationTracingAcceptanceTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/util/dbstructure/DbStructureInvocationTracingAcceptanceTest.java @@ -131,20 +131,14 @@ private void exerciseVisitor( Function visitor ) visitor.apply( null ).visitPropertyKey( 1, "age" ); visitor.apply( null ).visitRelationshipType( 0, "ACCEPTS" ); visitor.apply( null ).visitRelationshipType( 1, "REJECTS" ); - visitor.apply( null ).visitIndex( TestIndexDescriptorFactory.forLabel( 0, 1 ), - ":Person(age)", 0.5d, 1L ); - visitor.apply( null ) - .visitIndex( TestIndexDescriptorFactory.uniqueForLabel( 0, 0, 2 ), - ":Person(name, lastName)", 0.5d, 1L ); - visitor.apply( null ) - .visitUniqueConstraint( ConstraintDescriptorFactory.uniqueForLabel( 1, 0 ), ":Party(name)" ); - visitor.apply( null ).visitNodeKeyConstraint( - ConstraintDescriptorFactory.nodeKeyForLabel( 0, 1, 2 ), ":Person(name, lastName)" ); + visitor.apply( null ).visitIndex( TestIndexDescriptorFactory.forLabel( 0, 1 ), ":Person(age)", 0.5d, 1L ); + visitor.apply( null ).visitIndex( TestIndexDescriptorFactory.uniqueForLabel( 0, 0, 2 ), ":Person(name, lastName)", 0.5d, 1L ); + visitor.apply( null ).visitUniqueConstraint( ConstraintDescriptorFactory.uniqueForLabel( 1, 0 ), ":Party(name)" ); + visitor.apply( null ).visitNodeKeyConstraint( ConstraintDescriptorFactory.nodeKeyForLabel( 0, 1, 2 ), ":Person(name, lastName)" ); visitor.apply( null ).visitAllNodesCount( 55 ); visitor.apply( null ).visitNodeCount( 0, "Person", 50 ); visitor.apply( null ).visitNodeCount( 0, "Party", 5 ); - visitor.apply( null ).visitRelCount( 0, 1, -1, - "MATCH (:Person)-[:REJECTS]->() RETURN count(*)", 5 ); + visitor.apply( null ).visitRelCount( 0, 1, -1, "MATCH (:Person)-[:REJECTS]->() RETURN count(*)", 5 ); } private void assertCompiles( final String className, String source ) diff --git a/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/index/LuceneSchemaIndexUniquenessVerificationIT.java b/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/index/LuceneSchemaIndexUniquenessVerificationIT.java index 04dc6e1b562c..55f05e6a82c0 100644 --- a/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/index/LuceneSchemaIndexUniquenessVerificationIT.java +++ b/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/index/LuceneSchemaIndexUniquenessVerificationIT.java @@ -65,8 +65,7 @@ public class LuceneSchemaIndexUniquenessVerificationIT { private static final int DOCS_PER_PARTITION = ThreadLocalRandom.current().nextInt( 10, 100 ); private static final int PROPERTY_KEY_ID = 42; - private static final IndexDescriptor descriptor = TestIndexDescriptorFactory - .uniqueForLabel( 0, PROPERTY_KEY_ID ); + private static final IndexDescriptor descriptor = TestIndexDescriptorFactory.uniqueForLabel( 0, PROPERTY_KEY_ID ); @Rule public TestDirectory testDir = TestDirectory.testDirectory(); diff --git a/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/DatabaseCompositeIndexAccessorTest.java b/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/DatabaseCompositeIndexAccessorTest.java index b6f8054ed53e..679891d1d22c 100644 --- a/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/DatabaseCompositeIndexAccessorTest.java +++ b/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/DatabaseCompositeIndexAccessorTest.java @@ -68,8 +68,7 @@ public class DatabaseCompositeIndexAccessorTest { private static final int PROP_ID1 = 1; private static final int PROP_ID2 = 2; - private static final IndexDescriptor - DESCRIPTOR = TestIndexDescriptorFactory.forLabel( 0, PROP_ID1, PROP_ID2 ); + private static final IndexDescriptor DESCRIPTOR = TestIndexDescriptorFactory.forLabel( 0, PROP_ID1, PROP_ID2 ); private static final Config config = Config.defaults(); @Rule public final ThreadingRule threading = new ThreadingRule(); @@ -85,10 +84,8 @@ public class DatabaseCompositeIndexAccessorTest private final Object[] values = {"value1", "values2"}; private final Object[] values2 = {40, 42}; private DirectoryFactory.InMemoryDirectoryFactory dirFactory; - private static final IndexDescriptor SCHEMA_INDEX_DESCRIPTOR = TestIndexDescriptorFactory - .forLabel( 0, PROP_ID1, PROP_ID2 ); - private static final IndexDescriptor UNIQUE_SCHEMA_INDEX_DESCRIPTOR = TestIndexDescriptorFactory - .uniqueForLabel( 1, PROP_ID1, PROP_ID2 ); + private static final IndexDescriptor SCHEMA_INDEX_DESCRIPTOR = TestIndexDescriptorFactory.forLabel( 0, PROP_ID1, PROP_ID2 ); + private static final IndexDescriptor UNIQUE_SCHEMA_INDEX_DESCRIPTOR = TestIndexDescriptorFactory.uniqueForLabel( 1, PROP_ID1, PROP_ID2 ); @Parameterized.Parameters( name = "{0}" ) public static Collection[]> implementations() diff --git a/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/LuceneIndexProviderTest.java b/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/LuceneIndexProviderTest.java index 043f4e3760f0..bb271527f080 100644 --- a/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/LuceneIndexProviderTest.java +++ b/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/LuceneIndexProviderTest.java @@ -78,8 +78,7 @@ public void shouldFailToInvokePopulatorInReadOnlyMode() new DirectoryFactory.InMemoryDirectoryFactory(), fs, graphDbDir ); expectedException.expect( UnsupportedOperationException.class ); - readOnlyIndexProvider.getPopulator( descriptor, new IndexSamplingConfig( - readOnlyConfig ) ); + readOnlyIndexProvider.getPopulator( descriptor, new IndexSamplingConfig( readOnlyConfig ) ); } @Test diff --git a/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/populator/UniqueDatabaseIndexPopulatorTest.java b/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/populator/UniqueDatabaseIndexPopulatorTest.java index 7cb4c0cbabdb..ebbe7609159f 100644 --- a/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/populator/UniqueDatabaseIndexPopulatorTest.java +++ b/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/populator/UniqueDatabaseIndexPopulatorTest.java @@ -85,8 +85,7 @@ public class UniqueDatabaseIndexPopulatorTest private static final int PROPERTY_KEY_ID = 2; private final DirectoryFactory directoryFactory = new DirectoryFactory.InMemoryDirectoryFactory(); - private static final IndexDescriptor descriptor = TestIndexDescriptorFactory - .forLabel( LABEL_ID, PROPERTY_KEY_ID ); + private static final IndexDescriptor descriptor = TestIndexDescriptorFactory.forLabel( LABEL_ID, PROPERTY_KEY_ID ); private final PropertyAccessor propertyAccessor = mock( PropertyAccessor.class ); diff --git a/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/reader/SimpleIndexReaderTest.java b/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/reader/SimpleIndexReaderTest.java index e04cf2ebb295..789e526febd9 100644 --- a/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/reader/SimpleIndexReaderTest.java +++ b/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/reader/SimpleIndexReaderTest.java @@ -151,13 +151,11 @@ public void nonUuniqueIndexSamplerForNonUniqueIndex() private SimpleIndexReader getNonUniqueSimpleReader() { - return new SimpleIndexReader( partitionSearcher, TestIndexDescriptorFactory.forLabel( 0, 0 ), samplingConfig, - taskCoordinator ); + return new SimpleIndexReader( partitionSearcher, TestIndexDescriptorFactory.forLabel( 0, 0 ), samplingConfig, taskCoordinator ); } private SimpleIndexReader getUniqueSimpleReader() { - return new SimpleIndexReader( partitionSearcher, TestIndexDescriptorFactory.uniqueForLabel( 0, 0 ), - samplingConfig, taskCoordinator ); + return new SimpleIndexReader( partitionSearcher, TestIndexDescriptorFactory.uniqueForLabel( 0, 0 ), samplingConfig, taskCoordinator ); } } diff --git a/community/lucene-index/src/test/java/org/neo4j/kernel/impl/api/MultipleOpenCursorsTest.java b/community/lucene-index/src/test/java/org/neo4j/kernel/impl/api/MultipleOpenCursorsTest.java index e0bc37df31b0..dc004490ad70 100644 --- a/community/lucene-index/src/test/java/org/neo4j/kernel/impl/api/MultipleOpenCursorsTest.java +++ b/community/lucene-index/src/test/java/org/neo4j/kernel/impl/api/MultipleOpenCursorsTest.java @@ -822,14 +822,10 @@ void assertSameContent( List actual, List expected ) abstract void doCreateIndex( DatabaseRule db ); - NodeValueIndexCursor indexQuery( KernelTransaction ktx, IndexDescriptor indexDescriptor, - IndexQuery... indexQueries ) - - throws KernelException + NodeValueIndexCursor indexQuery( KernelTransaction ktx, IndexDescriptor indexDescriptor, IndexQuery... indexQueries ) throws KernelException { NodeValueIndexCursor cursor = ktx.cursors().allocateNodeValueIndexCursor(); - ktx.dataRead().nodeIndexSeek( indexDescriptor, - cursor, IndexOrder.NONE, indexQueries ); + ktx.dataRead().nodeIndexSeek( indexDescriptor, cursor, IndexOrder.NONE, indexQueries ); return cursor; } } diff --git a/community/lucene-index/src/test/java/org/neo4j/kernel/impl/api/index/IndexingServiceIntegrationTest.java b/community/lucene-index/src/test/java/org/neo4j/kernel/impl/api/index/IndexingServiceIntegrationTest.java index 0e91c778de0c..26a4c6b07d04 100644 --- a/community/lucene-index/src/test/java/org/neo4j/kernel/impl/api/index/IndexingServiceIntegrationTest.java +++ b/community/lucene-index/src/test/java/org/neo4j/kernel/impl/api/index/IndexingServiceIntegrationTest.java @@ -45,6 +45,7 @@ import org.neo4j.kernel.api.impl.schema.NativeLuceneFusionIndexProviderFactory10; import org.neo4j.kernel.api.impl.schema.NativeLuceneFusionIndexProviderFactory20; import org.neo4j.kernel.api.index.IndexProvider; +import org.neo4j.kernel.api.schema.index.StoreIndexDescriptor; import org.neo4j.kernel.api.schema.index.TestIndexDescriptorFactory; import org.neo4j.kernel.extension.KernelExtensionFactory; import org.neo4j.kernel.impl.api.index.inmemory.InMemoryIndexProviderFactory; @@ -54,7 +55,6 @@ import org.neo4j.kernel.impl.store.NeoStores; import org.neo4j.kernel.impl.store.SchemaStore; import org.neo4j.kernel.impl.store.UnderlyingStorageException; -import org.neo4j.kernel.api.schema.index.StoreIndexDescriptor; import org.neo4j.kernel.internal.GraphDatabaseAPI; import org.neo4j.storageengine.api.schema.PopulationProgress; import org.neo4j.test.TestGraphDatabaseFactory; @@ -200,8 +200,7 @@ public void failForceIndexesWhenOneOfTheIndexesIsBroken() throws Exception int indexLabel7 = labelTokenHolder.getIdByName( indexLabelPrefix + 7 ); int indexProperty7 = propertyKeyTokenHolder.getIdByName( indexPropertyPrefix + 7 ); - IndexProxy index = indexingService.getIndexProxy( TestIndexDescriptorFactory - .forLabel( indexLabel7, indexProperty7).schema() ); + IndexProxy index = indexingService.getIndexProxy( TestIndexDescriptorFactory.forLabel( indexLabel7, indexProperty7 ).schema() ); index.drop(); diff --git a/tools/src/main/java/org/neo4j/tools/dump/DumpCountsStore.java b/tools/src/main/java/org/neo4j/tools/dump/DumpCountsStore.java index 4bdfa6d14396..4ac25624c6e1 100644 --- a/tools/src/main/java/org/neo4j/tools/dump/DumpCountsStore.java +++ b/tools/src/main/java/org/neo4j/tools/dump/DumpCountsStore.java @@ -37,6 +37,7 @@ import org.neo4j.io.pagecache.tracing.cursor.context.EmptyVersionContextSupplier; import org.neo4j.kernel.api.StatementConstants; import org.neo4j.kernel.api.schema.index.IndexDescriptor; +import org.neo4j.kernel.api.schema.index.StoreIndexDescriptor; import org.neo4j.kernel.configuration.Config; import org.neo4j.kernel.impl.api.CountsVisitor; import org.neo4j.kernel.impl.core.RelationshipTypeToken; @@ -51,7 +52,6 @@ import org.neo4j.kernel.impl.store.kvstore.MetadataVisitor; import org.neo4j.kernel.impl.store.kvstore.ReadableBuffer; import org.neo4j.kernel.impl.store.kvstore.UnknownKey; -import org.neo4j.kernel.api.schema.index.StoreIndexDescriptor; import org.neo4j.kernel.lifecycle.Lifespan; import org.neo4j.logging.LogProvider; import org.neo4j.logging.NullLogProvider; @@ -129,8 +129,7 @@ public static void dumpCountsStore( FileSystemAbstraction fs, File path, PrintSt private final List propertyKeys; private DumpCountsStore( PrintStream out, Map indexes, List labels, - List relationshipTypes, - List propertyKeys ) + List relationshipTypes, List propertyKeys ) { this.out = out; this.indexes = indexes; diff --git a/tools/src/test/java/org/neo4j/tools/dump/DumpCountsStoreTest.java b/tools/src/test/java/org/neo4j/tools/dump/DumpCountsStoreTest.java index c2d0bcef04b5..fb21e635c11e 100644 --- a/tools/src/test/java/org/neo4j/tools/dump/DumpCountsStoreTest.java +++ b/tools/src/test/java/org/neo4j/tools/dump/DumpCountsStoreTest.java @@ -31,8 +31,8 @@ import java.util.Collections; import java.util.List; -import org.neo4j.kernel.api.index.IndexProvider; import org.neo4j.kernel.api.schema.index.IndexDescriptor; +import org.neo4j.kernel.api.schema.index.StoreIndexDescriptor; import org.neo4j.kernel.api.schema.index.TestIndexDescriptorFactory; import org.neo4j.kernel.impl.core.RelationshipTypeToken; import org.neo4j.kernel.impl.store.LabelTokenStore; @@ -45,7 +45,6 @@ import org.neo4j.kernel.impl.store.kvstore.Headers; import org.neo4j.kernel.impl.store.kvstore.ReadableBuffer; import org.neo4j.kernel.impl.store.kvstore.WritableBuffer; -import org.neo4j.kernel.api.schema.index.StoreIndexDescriptor; import org.neo4j.storageengine.api.Token; import org.neo4j.test.rule.SuppressOutput; @@ -73,8 +72,7 @@ public class DumpCountsStoreTest private static final String INDEX_PROPERTY = "indexProperty"; private static final long indexId = 0; - private static final IndexDescriptor descriptor = - TestIndexDescriptorFactory.forLabel( INDEX_LABEL_ID, INDEX_PROPERTY_KEY_ID ); + private static final IndexDescriptor descriptor = TestIndexDescriptorFactory.forLabel( INDEX_LABEL_ID, INDEX_PROPERTY_KEY_ID ); @Rule public SuppressOutput suppressOutput = SuppressOutput.suppressAll();