From 0cb8cb7e0c48e044b312e449790525365d5da119 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Finn=C3=A9?= Date: Tue, 5 Sep 2017 09:49:29 +0200 Subject: [PATCH] Updates uses of IndexEntryUpdate to use generics --- .../full/FullCheckIntegrationTest.java | 2 +- .../kernel/api/index/IndexEntryUpdate.java | 4 ++- .../kernel/api/index/IndexPopulator.java | 28 ++++++++++++++-- .../neo4j/kernel/api/index/IndexUpdater.java | 2 +- .../impl/api/index/IndexPopulationJob.java | 2 +- .../kernel/impl/api/index/IndexStoreView.java | 3 +- .../api/index/MultipleIndexPopulator.java | 16 ++++++---- .../impl/api/index/PopulatingIndexProxy.java | 4 +-- .../kernel/impl/api/index/StoreScan.java | 2 +- .../index/TentativeConstraintIndexProxy.java | 2 +- .../index/updater/DelegatingIndexUpdater.java | 2 +- .../index/updater/SwallowingIndexUpdater.java | 2 +- .../updater/UniquePropertyIndexUpdater.java | 6 ++-- .../updater/UpdateCountingIndexUpdater.java | 2 +- ...veNonUniqueSchemaNumberIndexPopulator.java | 2 +- .../NativeSchemaNumberIndexPopulator.java | 4 +-- .../NativeSchemaNumberIndexUpdater.java | 4 +-- ...ativeUniqueSchemaNumberIndexPopulator.java | 2 +- .../schema/fusion/FusionIndexPopulator.java | 2 +- .../schema/fusion/FusionIndexUpdater.java | 2 +- .../storeview/LabelScanViewNodeStoreScan.java | 2 +- .../state/storeview/NodeStoreScan.java | 2 +- .../storeview/StoreViewNodeStoreScan.java | 2 +- .../java/org/neo4j/kernel/RecoveryIT.java | 23 +++++++------ .../CompositeIndexAccessorCompatibility.java | 2 +- .../api/index/IndexAccessorCompatibility.java | 4 +-- .../api/index/IndexEntryUpdateTest.java | 32 +++++++++---------- .../BatchingMultipleIndexPopulatorTest.java | 14 ++++---- .../api/index/CollectingIndexUpdater.java | 4 +-- .../kernel/impl/api/index/IndexCRUDIT.java | 8 ++--- .../api/index/IndexPopulationJobTest.java | 22 ++++++------- .../impl/api/index/IndexRecoveryIT.java | 11 +++---- .../impl/api/index/IndexingServiceTest.java | 4 +-- .../api/index/MultipleIndexPopulatorTest.java | 14 ++++---- .../api/index/inmemory/InMemoryIndex.java | 6 ++-- .../index/inmemory/UniqueInMemoryIndex.java | 6 ++-- .../UpdateCapturingIndexAccessor.java | 6 ++-- .../UpdateCapturingIndexProvider.java | 8 ++--- .../inmemory/UpdateCapturingIndexUpdater.java | 6 ++-- .../transaction/state/NodeStoreScanTest.java | 10 +++--- .../api/impl/schema/LuceneIndexAccessor.java | 10 +++--- .../LuceneIndexPopulatingUpdater.java | 8 ++--- .../populator/LuceneIndexPopulator.java | 4 +-- ...NonUniqueLuceneIndexPopulatingUpdater.java | 6 ++-- .../NonUniqueLuceneIndexPopulator.java | 2 +- .../UniqueLuceneIndexPopulatingUpdater.java | 6 ++-- .../populator/UniqueLuceneIndexPopulator.java | 2 +- .../index/LuceneSchemaIndexPopulationIT.java | 8 ++--- .../schema/AccessUniqueDatabaseIndexTest.java | 12 +++---- .../DatabaseCompositeIndexAccessorTest.java | 12 +++---- .../schema/DatabaseIndexAccessorTest.java | 10 +++--- .../api/impl/schema/LuceneSchemaIndexIT.java | 11 +++---- .../LuceneSchemaIndexPopulatorTest.java | 10 +++--- .../NonUniqueDatabaseIndexPopulatorTest.java | 6 ++-- .../UniqueDatabaseIndexPopulatorTest.java | 2 +- ...ltiIndexPopulationConcurrentUpdatesIT.java | 18 +++++------ .../org/neo4j/kernel/api/SchemaIndexHaIT.java | 2 +- 57 files changed, 213 insertions(+), 195 deletions(-) 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 1665cb9204748..bbb05aee02b17 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 @@ -576,7 +576,7 @@ public void shouldReportNodesThatAreNotIndexed() throws Exception for ( long nodeId : indexedNodes ) { NodeUpdates updates = storeView.nodeAsUpdates( nodeId ); - for ( IndexEntryUpdate update : updates.forIndexKeys( asList( descriptor ) ) ) + for ( IndexEntryUpdate update : updates.forIndexKeys( asList( descriptor ) ) ) { updater.process( IndexEntryUpdate.remove( nodeId, descriptor, update.values() ) ); } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/api/index/IndexEntryUpdate.java b/community/kernel/src/main/java/org/neo4j/kernel/api/index/IndexEntryUpdate.java index ce12e9f48cf4b..93f1a2720151c 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/api/index/IndexEntryUpdate.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/api/index/IndexEntryUpdate.java @@ -32,6 +32,8 @@ * Subclasses of this represent events related to property changes due to property or label addition, deletion or * update. * This is of use in populating indexes that might be relevant to node label and property combinations. + * + * @param {@link LabelSchemaSupplier} specifying the schema */ public class IndexEntryUpdate { @@ -94,7 +96,7 @@ public boolean equals( Object o ) return false; } - IndexEntryUpdate that = (IndexEntryUpdate) o; + IndexEntryUpdate that = (IndexEntryUpdate) o; if ( entityId != that.entityId ) { diff --git a/community/kernel/src/main/java/org/neo4j/kernel/api/index/IndexPopulator.java b/community/kernel/src/main/java/org/neo4j/kernel/api/index/IndexPopulator.java index a7b4fbd381d6b..78153b6a2b01f 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/api/index/IndexPopulator.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/api/index/IndexPopulator.java @@ -35,11 +35,15 @@ public interface IndexPopulator { /** * Remove all data in the index and paves the way for populating an index. + * + * @throws IOException on I/O error. */ void create() throws IOException; /** * Closes and deletes this index. + * + * @throws IOException on I/O error. */ void drop() throws IOException; @@ -53,6 +57,10 @@ public interface IndexPopulator * @param updates batch of node property updates that needs to be inserted. Node ids will be retrieved using * {@link IndexEntryUpdate#getEntityId()} method and property values will be retrieved using * {@link IndexEntryUpdate#values()} method. + * @throws IndexEntryConflictException if this is a uniqueness index and any of the updates are detected + * to violate that constraint. Implementations may choose to not detect in this call, but instead do one efficient + * pass over the index in {@link #verifyDeferredConstraints(PropertyAccessor)}. + * @throws IOException on I/O error. */ void add( Collection> updates ) throws IndexEntryConflictException, IOException; @@ -89,6 +97,11 @@ void add( Collection> updates ) * has been removed and need to be removed from this index as well. Note that this removal needs to be * applied idempotently. * + * + * @param accessor accesses property data if implementation needs to be able look up property values while populating. + * @return an {@link IndexUpdater} which will funnel changes that happen concurrently with index population + * into the population and incorporating them as part of the index population. + * @throws IOException on I/O error. */ IndexUpdater newPopulatingUpdater( PropertyAccessor accessor ) throws IOException; @@ -97,6 +110,12 @@ void add( Collection> updates ) * If {@code populationCompletedSuccessfully} is {@code true} then it must mark this index * as {@link InternalIndexState#ONLINE} so that future invocations of its parent * {@link SchemaIndexProvider#getInitialState(long, IndexDescriptor)} also returns {@link InternalIndexState#ONLINE}. + * + * @param populationCompletedSuccessfully {@code true} if the index population was successful, where the index should + * be marked as {@link InternalIndexState#ONLINE}, otherwise {@code false} where index should be marked as + * {@link InternalIndexState#FAILED} and the failure, previously handed to this populator using {@link #markAsFailed(String)} + * should be stored and made available for later requests from {@link SchemaIndexProvider#getPopulationFailure(long)}. + * @throws IOException on I/O error. */ void close( boolean populationCompletedSuccessfully ) throws IOException; @@ -115,15 +134,19 @@ void add( Collection> updates ) * * @param update update to include in sample */ - void includeSample( IndexEntryUpdate update ); + void includeSample( IndexEntryUpdate update ); /** * Configure specific type of sampling that should be used during index population. * Depends from type of node scan that is used during index population + * * @param onlineSampling should online (sampling based on index population and updates) be used */ void configureSampling( boolean onlineSampling ); + /** + * @return {@link IndexSample} from samples collected by {@link #includeSample(IndexEntryUpdate)} calls. + */ IndexSample sampleResult(); class Adapter implements IndexPopulator @@ -144,6 +167,7 @@ public void add( Collection> updates ) throws Inde { } + @Override public IndexUpdater newPopulatingUpdater( PropertyAccessor accessor ) { return SwallowingIndexUpdater.INSTANCE; @@ -160,7 +184,7 @@ public void markAsFailed( String failure ) } @Override - public void includeSample( IndexEntryUpdate update ) + public void includeSample( IndexEntryUpdate update ) { } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/api/index/IndexUpdater.java b/community/kernel/src/main/java/org/neo4j/kernel/api/index/IndexUpdater.java index 3844ade564c75..fc88ca222ea8b 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/api/index/IndexUpdater.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/api/index/IndexUpdater.java @@ -33,7 +33,7 @@ */ public interface IndexUpdater extends AutoCloseable { - void process( IndexEntryUpdate update ) throws IOException, IndexEntryConflictException; + void process( IndexEntryUpdate update ) throws IOException, IndexEntryConflictException; @Override void close() throws IOException, IndexEntryConflictException; 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 c3c47fc3e8eef..ca12561859152 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 @@ -162,7 +162,7 @@ public Future cancel() * * @param update {@link IndexEntryUpdate} to queue. */ - public void update( IndexEntryUpdate update ) + public void update( IndexEntryUpdate update ) { multiPopulator.queue( update ); } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/IndexStoreView.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/IndexStoreView.java index 98f48cdfa331a..69719bc47afd9 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/IndexStoreView.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/IndexStoreView.java @@ -72,6 +72,7 @@ StoreScan visitNodes( void incrementIndexUpdates( long indexId, long updatesDelta ); + @SuppressWarnings( "rawtypes" ) StoreScan EMPTY_SCAN = new StoreScan() { @Override @@ -115,6 +116,7 @@ public Value getPropertyValue( long nodeId, int propertyKeyId ) throws EntityNot return Values.NO_VALUE; } + @SuppressWarnings( "unchecked" ) @Override public StoreScan visitNodes( int[] labelIds, IntPredicate propertyKeyIdFilter, Visitor propertyUpdateVisitor, @@ -151,6 +153,5 @@ public DoubleLongRegister indexSample( long indexId, DoubleLongRegister output ) public void incrementIndexUpdates( long indexId, long updatesDelta ) { } - }; } 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 5ccf377880c65..d91e2a0ed01e8 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 @@ -93,7 +93,7 @@ public class MultipleIndexPopulator implements IndexPopulator // Concurrency queue since multiple concurrent threads may enqueue updates into it. It is important for this queue // to have fast #size() method since it might be drained in batches - protected final Queue queue = new LinkedBlockingQueue<>(); + protected final Queue> queue = new LinkedBlockingQueue<>(); // Populators are added into this list. The same thread adding populators will later call #indexAllNodes. // Multiple concurrent threads might fail individual populations. @@ -187,13 +187,15 @@ public void run() throws IndexPopulationFailedKernelException * * @param update {@link IndexEntryUpdate} to queue. */ - public void queue( IndexEntryUpdate update ) + public void queue( IndexEntryUpdate update ) { queue.add( update ); } /** * Called if forced failure from the outside + * + * @param failure index population failure. */ public void fail( Throwable failure ) { @@ -279,7 +281,7 @@ public void markAsFailed( String failure ) throws IOException } @Override - public void includeSample( IndexEntryUpdate update ) + public void includeSample( IndexEntryUpdate update ) { throw new UnsupportedOperationException( "Multiple index populator can't perform index sampling." ); } @@ -383,7 +385,7 @@ private void populateFromQueueIfAvailable( long currentlyIndexedNodeId ) do { // no need to check for null as nobody else is emptying this queue - IndexEntryUpdate update = queue.poll(); + IndexEntryUpdate update = queue.poll(); storeScan.acceptUpdate( updater, update, currentlyIndexedNodeId ); } while ( !queue.isEmpty() ); @@ -421,7 +423,7 @@ public static class MultipleIndexUpdater implements IndexUpdater } @Override - public void process( IndexEntryUpdate update ) + public void process( IndexEntryUpdate update ) { Pair pair = populationsWithUpdaters.get( update.indexKey().schema() ); if ( pair != null ) @@ -510,7 +512,7 @@ private void flipToFailed( Throwable t ) populator, failure( t ), indexCountsRemover, logProvider ) ); } - private void onUpdate( IndexEntryUpdate update ) + private void onUpdate( IndexEntryUpdate update ) { populator.includeSample( update ); if ( batch( update ) ) @@ -602,7 +604,7 @@ public void stop() } @Override - public void acceptUpdate( MultipleIndexUpdater updater, IndexEntryUpdate update, long currentlyIndexedNodeId ) + public void acceptUpdate( MultipleIndexUpdater updater, IndexEntryUpdate update, long currentlyIndexedNodeId ) { delegate.acceptUpdate( updater, update, currentlyIndexedNodeId ); } 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 bf8fec26e4ed7..04323f8ff8fff 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 @@ -69,7 +69,7 @@ public IndexUpdater newUpdater( final IndexUpdateMode mode ) return new PopulatingIndexUpdater() { @Override - public void process( IndexEntryUpdate update ) throws IOException, IndexEntryConflictException + public void process( IndexEntryUpdate update ) throws IOException, IndexEntryConflictException { job.update( update ); } @@ -78,7 +78,7 @@ public void process( IndexEntryUpdate update ) throws IOException, IndexEntryCon return new PopulatingIndexUpdater() { @Override - public void process( IndexEntryUpdate update ) throws IOException, IndexEntryConflictException + public void process( IndexEntryUpdate update ) throws IOException, IndexEntryConflictException { throw new IllegalArgumentException( "Unsupported update mode: " + mode ); } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/StoreScan.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/StoreScan.java index 13cdacc24b158..0d2938ef80536 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/StoreScan.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/StoreScan.java @@ -30,7 +30,7 @@ public interface StoreScan void stop(); - void acceptUpdate( MultipleIndexPopulator.MultipleIndexUpdater updater, IndexEntryUpdate update, + void acceptUpdate( MultipleIndexPopulator.MultipleIndexUpdater updater, IndexEntryUpdate update, long currentlyIndexedNodeId ); PopulationProgress getProgress(); 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 84f2fd49bf70e..a777215ba29f8 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 @@ -76,7 +76,7 @@ public IndexUpdater newUpdater( IndexUpdateMode mode ) return new DelegatingIndexUpdater( target.accessor.newUpdater( mode ) ) { @Override - public void process( IndexEntryUpdate update ) + public void process( IndexEntryUpdate update ) throws IOException, IndexEntryConflictException { try diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/updater/DelegatingIndexUpdater.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/updater/DelegatingIndexUpdater.java index 03deecbb1e08f..059d54106d329 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/updater/DelegatingIndexUpdater.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/updater/DelegatingIndexUpdater.java @@ -35,7 +35,7 @@ public DelegatingIndexUpdater( IndexUpdater delegate ) } @Override - public void process( IndexEntryUpdate update ) throws IOException, IndexEntryConflictException + public void process( IndexEntryUpdate update ) throws IOException, IndexEntryConflictException { delegate.process( update ); } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/updater/SwallowingIndexUpdater.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/updater/SwallowingIndexUpdater.java index 221777e86159f..11f227048f744 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/updater/SwallowingIndexUpdater.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/updater/SwallowingIndexUpdater.java @@ -30,7 +30,7 @@ public final class SwallowingIndexUpdater implements IndexUpdater public static final IndexUpdater INSTANCE = new SwallowingIndexUpdater(); @Override - public void process( IndexEntryUpdate update ) + public void process( IndexEntryUpdate update ) { // intentionally swallow this update } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/updater/UniquePropertyIndexUpdater.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/updater/UniquePropertyIndexUpdater.java index ce5a485c51def..5cb62b2bbf451 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/updater/UniquePropertyIndexUpdater.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/updater/UniquePropertyIndexUpdater.java @@ -37,10 +37,10 @@ public abstract class UniquePropertyIndexUpdater implements IndexUpdater { private final Map> referenceCount = new HashMap<>(); - private final ArrayList updates = new ArrayList<>(); + private final ArrayList> updates = new ArrayList<>(); @Override - public void process( IndexEntryUpdate update ) + public void process( IndexEntryUpdate update ) { // build uniqueness verification state switch ( update.updateMode() ) @@ -70,7 +70,7 @@ public void close() throws IOException, IndexEntryConflictException flushUpdates( updates ); } - protected abstract void flushUpdates( Iterable updates ) + protected abstract void flushUpdates( Iterable> updates ) throws IOException, IndexEntryConflictException; private DiffSets propertyValueDiffSet( Object value ) diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/updater/UpdateCountingIndexUpdater.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/updater/UpdateCountingIndexUpdater.java index 66c2eb6ac41e2..529cb1c130c09 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/updater/UpdateCountingIndexUpdater.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/index/updater/UpdateCountingIndexUpdater.java @@ -41,7 +41,7 @@ public UpdateCountingIndexUpdater( IndexStoreView storeView, long indexId, Index } @Override - public void process( IndexEntryUpdate update ) throws IOException, IndexEntryConflictException + public void process( IndexEntryUpdate update ) throws IOException, IndexEntryConflictException { delegate.process( update ); updates++; diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/NativeNonUniqueSchemaNumberIndexPopulator.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/NativeNonUniqueSchemaNumberIndexPopulator.java index 5d62b43e94802..41216188c4af2 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/NativeNonUniqueSchemaNumberIndexPopulator.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/NativeNonUniqueSchemaNumberIndexPopulator.java @@ -50,7 +50,7 @@ class NativeNonUniqueSchemaNumberIndexPopulator update ) { if ( updateSampling ) { diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/NativeSchemaNumberIndexPopulator.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/NativeSchemaNumberIndexPopulator.java index 77614dcaa55eb..d724508a72cda 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/NativeSchemaNumberIndexPopulator.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/NativeSchemaNumberIndexPopulator.java @@ -127,7 +127,7 @@ public IndexUpdater newPopulatingUpdater( PropertyAccessor accessor ) throws IOE private final Collection> updates = new ArrayList<>(); @Override - public void process( IndexEntryUpdate update ) throws IOException, IndexEntryConflictException + public void process( IndexEntryUpdate update ) throws IOException, IndexEntryConflictException { assertOpen(); updates.add( update ); @@ -256,7 +256,7 @@ private static class IndexUpdateApply indexEntryUpdate ) throws Exception { NativeSchemaNumberIndexUpdater.processUpdate( treeKey, treeValue, indexEntryUpdate, writer, conflictDetectingValueMerger ); } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/NativeSchemaNumberIndexUpdater.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/NativeSchemaNumberIndexUpdater.java index 5b7e225597a0a..e5f4546a8bf5b 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/NativeSchemaNumberIndexUpdater.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/NativeSchemaNumberIndexUpdater.java @@ -59,7 +59,7 @@ NativeSchemaNumberIndexUpdater initialize( Writer writer, } @Override - public void process( IndexEntryUpdate update ) throws IOException, IndexEntryConflictException + public void process( IndexEntryUpdate update ) throws IOException, IndexEntryConflictException { assertOpen(); processUpdate( treeKey, treeValue, update, writer, conflictDetectingValueMerger ); @@ -84,7 +84,7 @@ private void assertOpen() } static void processUpdate( KEY treeKey, VALUE treeValue, - IndexEntryUpdate update, Writer writer, ConflictDetectingValueMerger conflictDetectingValueMerger ) + IndexEntryUpdate update, Writer writer, ConflictDetectingValueMerger conflictDetectingValueMerger ) throws IOException, IndexEntryConflictException { switch ( update.updateMode() ) diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/NativeUniqueSchemaNumberIndexPopulator.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/NativeUniqueSchemaNumberIndexPopulator.java index 2070b99ea72f9..604c9f6d24c6e 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/NativeUniqueSchemaNumberIndexPopulator.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/NativeUniqueSchemaNumberIndexPopulator.java @@ -43,7 +43,7 @@ class NativeUniqueSchemaNumberIndexPopulator update ) { sampler.increment( 1 ); } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/fusion/FusionIndexPopulator.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/fusion/FusionIndexPopulator.java index 137ae89ea6bcb..5521c31793e9b 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/fusion/FusionIndexPopulator.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/fusion/FusionIndexPopulator.java @@ -122,7 +122,7 @@ public void markAsFailed( String failure ) throws IOException } @Override - public void includeSample( IndexEntryUpdate update ) + public void includeSample( IndexEntryUpdate update ) { selector.select( nativePopulator, lucenePopulator, update.values() ).includeSample( update ); } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/fusion/FusionIndexUpdater.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/fusion/FusionIndexUpdater.java index eb2c931f38fcc..fece51f384a1b 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/fusion/FusionIndexUpdater.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/fusion/FusionIndexUpdater.java @@ -40,7 +40,7 @@ class FusionIndexUpdater implements IndexUpdater } @Override - public void process( IndexEntryUpdate update ) throws IOException, IndexEntryConflictException + public void process( IndexEntryUpdate update ) throws IOException, IndexEntryConflictException { switch ( update.updateMode() ) { diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/state/storeview/LabelScanViewNodeStoreScan.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/state/storeview/LabelScanViewNodeStoreScan.java index 3ecae47910763..6914f473e0ddb 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/state/storeview/LabelScanViewNodeStoreScan.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/state/storeview/LabelScanViewNodeStoreScan.java @@ -35,7 +35,7 @@ /** * Store scan view that will try to minimize amount of scanned nodes by using label scan store {@link LabelScanStore} * as a source of known labeled node ids. - * @param + * @param type of exception thrown on failure */ public class LabelScanViewNodeStoreScan extends StoreViewNodeStoreScan { diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/state/storeview/NodeStoreScan.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/state/storeview/NodeStoreScan.java index a7937d70158f7..21aac810fc386 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/state/storeview/NodeStoreScan.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/state/storeview/NodeStoreScan.java @@ -34,7 +34,7 @@ /** * Node scanner that will perform some sort of process over set of nodes * from nodeStore {@link NodeStore} based on node ids supplied by underlying store aware id iterator. - * @param + * @param type of exception thrown on failure */ public abstract class NodeStoreScan implements StoreScan { diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/state/storeview/StoreViewNodeStoreScan.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/state/storeview/StoreViewNodeStoreScan.java index 564ef0ba93ca0..88c7df2e127bc 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/state/storeview/StoreViewNodeStoreScan.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/state/storeview/StoreViewNodeStoreScan.java @@ -144,7 +144,7 @@ private static boolean containsAnyLabel( int[] labelIdFilter, long[] labels ) } @Override - public void acceptUpdate( MultipleIndexPopulator.MultipleIndexUpdater updater, IndexEntryUpdate update, + public void acceptUpdate( MultipleIndexPopulator.MultipleIndexUpdater updater, IndexEntryUpdate update, long currentlyIndexedNodeId ) { if ( update.getEntityId() <= currentlyIndexedNodeId ) diff --git a/community/kernel/src/test/java/org/neo4j/kernel/RecoveryIT.java b/community/kernel/src/test/java/org/neo4j/kernel/RecoveryIT.java index 92708cb1de021..bd121ef84b5a2 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/RecoveryIT.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/RecoveryIT.java @@ -267,7 +267,6 @@ public void recoveryShouldFixPartiallyAppliedSchemaIndexUpdates() } } - @SuppressWarnings( "rawtypes" ) @Test public void shouldSeeSameIndexUpdatesDuringRecoveryAsFromNormalIndexApplication() throws Exception { @@ -307,7 +306,7 @@ public void shouldSeeSameIndexUpdatesDuringRecoveryAsFromNormalIndexApplication( produceRandomNodePropertyAndLabelUpdates( db, random.intBetween( 20, 40 ), label, key1, key2 ); checkPoint( db ); InMemoryIndexProvider indexStateAtLastCheckPoint = indexProvider.snapshot(); - Map> updatesAtLastCheckPoint = updateCapturingIndexProvider.snapshot(); + Map>> updatesAtLastCheckPoint = updateCapturingIndexProvider.snapshot(); // when produceRandomNodePropertyAndLabelUpdates( db, random.intBetween( 40, 100 ), label, key1, key2 ); @@ -316,7 +315,7 @@ public void shouldSeeSameIndexUpdatesDuringRecoveryAsFromNormalIndexApplication( flush( db ); EphemeralFileSystemAbstraction crashedFs = fs.snapshot(); InMemoryIndexProvider indexStateAtCrash = indexProvider.snapshot(); - Map> updatesAtCrash = updateCapturingIndexProvider.snapshot(); + Map>> updatesAtCrash = updateCapturingIndexProvider.snapshot(); // Crash and start anew UpdateCapturingIndexProvider recoveredUpdateCapturingIndexProvider = @@ -329,7 +328,7 @@ public void shouldSeeSameIndexUpdatesDuringRecoveryAsFromNormalIndexApplication( .setKernelExtensions( asList( new InMemoryIndexProviderFactory( recoveredUpdateCapturingIndexProvider ) ) ) .newImpermanentDatabase( storeDir ); long lastCommittedTxIdAfterRecovered = lastCommittedTxId( db ); - Map> updatesAfterRecovery = recoveredUpdateCapturingIndexProvider.snapshot(); + Map>> updatesAfterRecovery = recoveredUpdateCapturingIndexProvider.snapshot(); // then assertEquals( lastCommittedTxIdBeforeRecovered, lastCommittedTxIdAfterRecovered ); @@ -610,8 +609,8 @@ private Label randomLabel() return Label.label( random.among( TOKENS ) ); } - private void assertSameUpdates( Map> updatesAtCrash, - Map> recoveredUpdatesSnapshot ) + private void assertSameUpdates( Map>> updatesAtCrash, + Map>> recoveredUpdatesSnapshot ) { // The UpdateCapturingIndexProvider just captures updates made to indexes. The order in this test // should be the same during online transaction application and during recovery since everything @@ -620,21 +619,21 @@ private void assertSameUpdates( Map> updatesAt // that updates for a particular transaction are the same during normal application and recovery, // regardless of ordering differences within the transaction. - Map>> crashUpdatesPerNode = splitPerNode( updatesAtCrash ); - Map>> recoveredUpdatesPerNode = splitPerNode( recoveredUpdatesSnapshot ); + Map>>> crashUpdatesPerNode = splitPerNode( updatesAtCrash ); + Map>>> recoveredUpdatesPerNode = splitPerNode( recoveredUpdatesSnapshot ); assertEquals( crashUpdatesPerNode, recoveredUpdatesPerNode ); } - private Map>> splitPerNode( Map> updates ) + private Map>>> splitPerNode( Map>> updates ) { - Map>> result = new HashMap<>(); + Map>>> result = new HashMap<>(); updates.forEach( ( indexId, indexUpdates ) -> result.put( indexId, splitPerNode( indexUpdates ) ) ); return result; } - private Map> splitPerNode( Collection updates ) + private Map>> splitPerNode( Collection> updates ) { - Map> perNode = new HashMap<>(); + Map>> perNode = new HashMap<>(); updates.forEach( update -> perNode.computeIfAbsent( update.getEntityId(), nodeId -> new ArrayList<>() ).add( update ) ); return perNode; } 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 9a1340fbefbd7..4f9f225088cac 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 @@ -133,7 +133,7 @@ public void closingAnOnlineIndexUpdaterMustNotThrowEvenIfItHasBeenFedConflicting } } - private static IndexEntryUpdate add( long nodeId, LabelSchemaDescriptor schema, Object value1, Object value2 ) + private static IndexEntryUpdate add( long nodeId, LabelSchemaDescriptor schema, Object value1, Object value2 ) { return IndexEntryUpdate.add( nodeId, schema, Values.of( value1 ), Values.of( value2 ) ); } 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 f9a38a675e85c..c0ce6a29fcc92 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 @@ -86,12 +86,12 @@ interface ReaderInteraction PrimitiveLongIterator results( IndexReader reader ) throws Exception; } - void updateAndCommit( List updates ) + void updateAndCommit( List> updates ) throws IOException, IndexEntryConflictException { try ( IndexUpdater updater = accessor.newUpdater( IndexUpdateMode.ONLINE ) ) { - for ( IndexEntryUpdate update : updates ) + for ( IndexEntryUpdate update : updates ) { updater.process( update ); } diff --git a/community/kernel/src/test/java/org/neo4j/kernel/api/index/IndexEntryUpdateTest.java b/community/kernel/src/test/java/org/neo4j/kernel/api/index/IndexEntryUpdateTest.java index 2bb5493726e1d..6151cedb5e114 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/api/index/IndexEntryUpdateTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/api/index/IndexEntryUpdateTest.java @@ -42,8 +42,8 @@ public class IndexEntryUpdateTest @Test public void indexEntryUpdatesShouldBeEqual() { - IndexEntryUpdate a = IndexEntryUpdate.add( 0, SchemaDescriptorFactory.forLabel( 3, 4 ), singleValue ); - IndexEntryUpdate b = IndexEntryUpdate.add( 0, SchemaDescriptorFactory.forLabel( 3, 4 ), singleValue ); + IndexEntryUpdate a = IndexEntryUpdate.add( 0, SchemaDescriptorFactory.forLabel( 3, 4 ), singleValue ); + IndexEntryUpdate b = IndexEntryUpdate.add( 0, SchemaDescriptorFactory.forLabel( 3, 4 ), singleValue ); assertThat( a, equalTo( b ) ); assertThat( a.hashCode(), equalTo( b.hashCode() ) ); } @@ -51,8 +51,8 @@ public void indexEntryUpdatesShouldBeEqual() @Test public void addShouldRetainValues() { - IndexEntryUpdate single = IndexEntryUpdate.add( 0, SchemaDescriptorFactory.forLabel( 3, 4 ), singleValue ); - IndexEntryUpdate multi = IndexEntryUpdate.add( 0, SchemaDescriptorFactory.forLabel( 3, 4, 5 ), multiValue ); + IndexEntryUpdate single = IndexEntryUpdate.add( 0, SchemaDescriptorFactory.forLabel( 3, 4 ), singleValue ); + IndexEntryUpdate multi = IndexEntryUpdate.add( 0, SchemaDescriptorFactory.forLabel( 3, 4, 5 ), multiValue ); assertThat( single, not( equalTo( multi ) ) ); assertThat( single.values(), equalTo( new Object[]{singleValue} ) ); assertThat( multi.values(), equalTo( multiValue ) ); @@ -61,8 +61,8 @@ public void addShouldRetainValues() @Test public void removeShouldRetainValues() { - IndexEntryUpdate single = IndexEntryUpdate.remove( 0, SchemaDescriptorFactory.forLabel( 3, 4 ), singleValue ); - IndexEntryUpdate multi = IndexEntryUpdate + IndexEntryUpdate single = IndexEntryUpdate.remove( 0, SchemaDescriptorFactory.forLabel( 3, 4 ), singleValue ); + IndexEntryUpdate multi = IndexEntryUpdate .remove( 0, SchemaDescriptorFactory.forLabel( 3, 4, 5 ), multiValue ); assertThat( single, not( equalTo( multi ) ) ); assertThat( single.values(), equalTo( new Object[]{singleValue} ) ); @@ -72,7 +72,7 @@ public void removeShouldRetainValues() @Test public void addShouldThrowIfAskedForChanged() throws Exception { - IndexEntryUpdate single = IndexEntryUpdate.add( 0, SchemaDescriptorFactory.forLabel( 3, 4 ), singleValue ); + IndexEntryUpdate single = IndexEntryUpdate.add( 0, SchemaDescriptorFactory.forLabel( 3, 4 ), singleValue ); thrown.expect( UnsupportedOperationException.class ); single.beforeValues(); } @@ -80,7 +80,7 @@ public void addShouldThrowIfAskedForChanged() throws Exception @Test public void removeShouldThrowIfAskedForChanged() throws Exception { - IndexEntryUpdate single = IndexEntryUpdate.remove( 0, SchemaDescriptorFactory.forLabel( 3, 4 ), singleValue ); + IndexEntryUpdate single = IndexEntryUpdate.remove( 0, SchemaDescriptorFactory.forLabel( 3, 4 ), singleValue ); thrown.expect( UnsupportedOperationException.class ); single.beforeValues(); } @@ -88,17 +88,17 @@ public void removeShouldThrowIfAskedForChanged() throws Exception @Test public void updatesShouldEqualRegardlessOfCreationMethod() { - IndexEntryUpdate singleAdd = IndexEntryUpdate.add( 0, SchemaDescriptorFactory.forLabel( 3, 4 ), singleValue ); + IndexEntryUpdate singleAdd = IndexEntryUpdate.add( 0, SchemaDescriptorFactory.forLabel( 3, 4 ), singleValue ); Value[] singleAsArray = {singleValue}; - IndexEntryUpdate multiAdd = IndexEntryUpdate + IndexEntryUpdate multiAdd = IndexEntryUpdate .add( 0, SchemaDescriptorFactory.forLabel( 3, 4 ), singleAsArray ); - IndexEntryUpdate singleRemove = IndexEntryUpdate + IndexEntryUpdate singleRemove = IndexEntryUpdate .remove( 0, SchemaDescriptorFactory.forLabel( 3, 4 ), singleValue ); - IndexEntryUpdate multiRemove = IndexEntryUpdate + IndexEntryUpdate multiRemove = IndexEntryUpdate .remove( 0, SchemaDescriptorFactory.forLabel( 3, 4 ), singleAsArray ); - IndexEntryUpdate singleChange = IndexEntryUpdate + IndexEntryUpdate singleChange = IndexEntryUpdate .change( 0, SchemaDescriptorFactory.forLabel( 3, 4 ), singleValue, singleValue ); - IndexEntryUpdate multiChange = IndexEntryUpdate + IndexEntryUpdate multiChange = IndexEntryUpdate .change( 0, SchemaDescriptorFactory.forLabel( 3, 4 ), singleAsArray, singleAsArray ); assertThat( singleAdd, equalTo( multiAdd ) ); assertThat( singleRemove, equalTo( multiRemove ) ); @@ -109,10 +109,10 @@ public void updatesShouldEqualRegardlessOfCreationMethod() public void changedShouldRetainValues() throws Exception { Value singleAfter = Values.of( "Hello" ); - IndexEntryUpdate singleChange = IndexEntryUpdate + IndexEntryUpdate singleChange = IndexEntryUpdate .change( 0, SchemaDescriptorFactory.forLabel( 3, 4 ), singleValue, singleAfter ); Value[] multiAfter = {Values.of( "Hello" ), Values.of( "Hi" )}; - IndexEntryUpdate multiChange = IndexEntryUpdate + IndexEntryUpdate multiChange = IndexEntryUpdate .change( 0, SchemaDescriptorFactory.forLabel( 3, 4, 5 ), multiValue, multiAfter ); assertThat( new Object[]{singleValue}, equalTo( singleChange.beforeValues() ) ); assertThat( new Object[]{singleAfter}, equalTo( singleChange.values() ) ); 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 f68e446e6e146..8d6174af90b3f 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 @@ -94,8 +94,8 @@ public void populateFromQueueDoesNothingIfThresholdNotReached() throws Exception IndexUpdater updater = mock( IndexUpdater.class ); when( populator.newPopulatingUpdater( any() ) ).thenReturn( updater ); - IndexEntryUpdate update1 = add( 1, index1.schema(), "foo" ); - IndexEntryUpdate update2 = add( 2, index1.schema(), "bar" ); + IndexEntryUpdate update1 = add( 1, index1.schema(), "foo" ); + IndexEntryUpdate update2 = add( 2, index1.schema(), "bar" ); batchingPopulator.queue( update1 ); batchingPopulator.queue( update2 ); @@ -128,9 +128,9 @@ public void populateFromQueuePopulatesWhenThresholdReached() throws Exception when( populator2.newPopulatingUpdater( any() ) ).thenReturn( updater2 ); batchingPopulator.indexAllNodes(); - IndexEntryUpdate update1 = add( 1, index1.schema(), "foo" ); - IndexEntryUpdate update2 = add( 2, index42.schema(), "bar" ); - IndexEntryUpdate update3 = add( 3, index1.schema(), "baz" ); + IndexEntryUpdate update1 = add( 1, index1.schema(), "foo" ); + IndexEntryUpdate update2 = add( 2, index42.schema(), "bar" ); + IndexEntryUpdate update3 = add( 3, index1.schema(), "baz" ); batchingPopulator.queue( update1 ); batchingPopulator.queue( update2 ); batchingPopulator.queue( update3 ); @@ -437,10 +437,9 @@ public void stop() } @Override - public void acceptUpdate( MultipleIndexPopulator.MultipleIndexUpdater updater, IndexEntryUpdate update, + public void acceptUpdate( MultipleIndexPopulator.MultipleIndexUpdater updater, IndexEntryUpdate update, long currentlyIndexedNodeId ) { - } @Override @@ -452,7 +451,6 @@ public PopulationProgress getProgress() @Override public void configure( Collection populations ) { - } } } diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/CollectingIndexUpdater.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/CollectingIndexUpdater.java index 4eb022f9a6bef..0c4b20185fd11 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/CollectingIndexUpdater.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/CollectingIndexUpdater.java @@ -26,10 +26,10 @@ public abstract class CollectingIndexUpdater implements IndexUpdater { - protected final ArrayList updates = new ArrayList<>(); + protected final ArrayList> updates = new ArrayList<>(); @Override - public void process( IndexEntryUpdate update ) + public void process( IndexEntryUpdate update ) { if ( null != update ) { 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 d27c9f56c5ebc..0c91e60ad264d 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 @@ -65,7 +65,6 @@ import static org.mockito.Matchers.anyLong; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import static org.neo4j.graphdb.DynamicLabel.label; import static org.neo4j.helpers.collection.Iterators.asSet; import static org.neo4j.helpers.collection.MapUtil.map; import static org.neo4j.kernel.impl.api.index.SchemaIndexTestHelper.singleInstanceSchemaIndexProviderFactory; @@ -150,7 +149,7 @@ public void addingALabelToPreExistingNodeShouldGetIndexed() throws Exception private final KernelExtensionFactory mockedIndexProviderFactory = singleInstanceSchemaIndexProviderFactory( "none", mockedIndexProvider ); private ThreadToStatementContextBridge ctxSupplier; - private final Label myLabel = label( "MYLABEL" ); + private final Label myLabel = Label.label( "MYLABEL" ); private Node createNode( Map properties, Label ... labels ) { @@ -166,7 +165,6 @@ private Node createNode( Map properties, Label ... labels ) } } - @SuppressWarnings( "deprecation" ) @Before public void before() throws Exception { @@ -203,7 +201,7 @@ public void after() throws Exception private class GatheringIndexWriter extends IndexAccessor.Adapter implements IndexPopulator { - private final Set updatesCommitted = new HashSet<>(); + private final Set> updatesCommitted = new HashSet<>(); private final Map> indexSamples = new HashMap<>(); @Override @@ -252,7 +250,7 @@ public void markAsFailed( String failure ) } @Override - public void includeSample( IndexEntryUpdate update ) + public void includeSample( IndexEntryUpdate update ) { addValueToSample( update.getEntityId(), update.values()[0] ); } 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 7c451df80b681..4d7d232695508 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 @@ -58,11 +58,11 @@ import org.neo4j.kernel.api.schema.index.IndexDescriptor; import org.neo4j.kernel.api.schema.index.IndexDescriptorFactory; import org.neo4j.kernel.api.security.AnonymousContext; +import org.neo4j.kernel.api.security.SecurityContext; import org.neo4j.kernel.configuration.Config; import org.neo4j.kernel.impl.api.DatabaseSchemaState; import org.neo4j.kernel.impl.api.index.inmemory.InMemoryIndexProvider; import org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig; -import org.neo4j.kernel.impl.coreapi.schema.InternalSchemaActions; import org.neo4j.kernel.internal.GraphDatabaseAPI; import org.neo4j.logging.AssertableLogProvider; import org.neo4j.logging.AssertableLogProvider.LogMatcherBuilder; @@ -115,8 +115,6 @@ public class IndexPopulationJobTest private KernelAPI kernel; private IndexStoreView indexStoreView; private DatabaseSchemaState stateHolder; - private final InternalSchemaActions actions = mock( InternalSchemaActions.class ); - private int labelId; @Before @@ -156,7 +154,7 @@ public void shouldPopulateIndexWithOneNode() throws Exception job.run(); // THEN - IndexEntryUpdate update = IndexEntryUpdate.add( nodeId, descriptor, Values.of( value ) ); + IndexEntryUpdate update = IndexEntryUpdate.add( nodeId, descriptor, Values.of( value ) ); verify( populator ).create(); verify( populator ).configureSampling( false ); @@ -203,8 +201,8 @@ public void shouldPopulateIndexWithASmallDataset() throws Exception job.run(); // THEN - IndexEntryUpdate update1 = add( node1, descriptor, Values.of( value ) ); - IndexEntryUpdate update2 = add( node4, descriptor, Values.of( value ) ); + IndexEntryUpdate update1 = add( node1, descriptor, Values.of( value ) ); + IndexEntryUpdate update2 = add( node4, descriptor, Values.of( value ) ); verify( populator ).create(); verify( populator ).configureSampling( false ); @@ -431,7 +429,7 @@ public void stop() } @Override - public void acceptUpdate( MultipleIndexPopulator.MultipleIndexUpdater updater, IndexEntryUpdate update, + public void acceptUpdate( MultipleIndexPopulator.MultipleIndexUpdater updater, IndexEntryUpdate update, long currentlyIndexedNodeId ) { // no-op @@ -470,7 +468,7 @@ private class NodeChangingWriter extends IndexPopulator.Adapter @Override public void add( Collection> updates ) { - for ( IndexEntryUpdate update : updates ) + for ( IndexEntryUpdate update : updates ) { add( update ); } @@ -491,7 +489,7 @@ public IndexUpdater newPopulatingUpdater( PropertyAccessor propertyAccessor ) return new IndexUpdater() { @Override - public void process( IndexEntryUpdate update ) throws IOException, IndexEntryConflictException + public void process( IndexEntryUpdate update ) throws IOException, IndexEntryConflictException { switch ( update.updateMode() ) { @@ -541,7 +539,7 @@ public void setJob( IndexPopulationJob job ) @Override public void add( Collection> updates ) { - for ( IndexEntryUpdate update : updates ) + for ( IndexEntryUpdate update : updates ) { add( update ); } @@ -562,7 +560,7 @@ public IndexUpdater newPopulatingUpdater( PropertyAccessor propertyAccessor ) return new IndexUpdater() { @Override - public void process( IndexEntryUpdate update ) throws IOException, IndexEntryConflictException + public void process( IndexEntryUpdate update ) throws IOException, IndexEntryConflictException { switch ( update.updateMode() ) { @@ -632,7 +630,7 @@ private IndexPopulationJob newIndexPopulationJob( FailedIndexProxyFactory failur private IndexDescriptor indexDescriptor( Label label, String propertyKey, boolean constraint ) throws TransactionFailureException, IllegalTokenNameException, TooManyLabelsException { - try ( KernelTransaction tx = kernel.newTransaction( KernelTransaction.Type.implicit, AnonymousContext.AUTH_DISABLED ); + try ( KernelTransaction tx = kernel.newTransaction( KernelTransaction.Type.implicit, SecurityContext.AUTH_DISABLED ); Statement statement = tx.acquireStatement() ) { int labelId = statement.tokenWriteOperations().labelGetOrCreateForName( label.name() ); 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 9c25ef93c26b1..bfde2f4542c92 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 @@ -178,7 +178,7 @@ public void shouldBeAbleToRecoverAndUpdateOnlineIndex() throws Exception // rotate logs rotateLogsAndCheckPoint(); // make updates - Set expectedUpdates = createSomeBananas( myLabel ); + Set> expectedUpdates = createSomeBananas( myLabel ); // And Given killDb(); @@ -254,7 +254,6 @@ public void setUp() .thenReturn( StoreMigrationParticipant.NOT_PARTICIPATING ); } - @SuppressWarnings( "deprecation" ) private void startDb() { if ( db != null ) @@ -329,9 +328,9 @@ private IndexDefinition createIndex( Label label ) } } - private Set createSomeBananas( Label label ) + private Set> createSomeBananas( Label label ) { - Set updates = new HashSet<>(); + Set> updates = new HashSet<>(); try ( Transaction tx = db.beginTx() ) { ThreadToStatementContextBridge ctxSupplier = db.getDependencyResolver().resolveDependency( @@ -355,8 +354,8 @@ private Set createSomeBananas( Label label ) public static class GatheringIndexWriter extends IndexAccessor.Adapter { - private final Set regularUpdates = new HashSet<>(); - private final Set batchedUpdates = new HashSet<>(); + private final Set> regularUpdates = new HashSet<>(); + private final Set> batchedUpdates = new HashSet<>(); @Override public IndexUpdater newUpdater( final IndexUpdateMode mode ) 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 57051660748fe..90a79e293d476 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 @@ -236,7 +236,7 @@ public void shouldDeliverUpdatesThatOccurDuringPopulationToPopulator() throws Ex IndexProxy proxy = indexingService.getIndexProxy( 0 ); assertEquals( InternalIndexState.POPULATING, proxy.getState() ); - IndexEntryUpdate value2 = add( 2, "value2" ); + IndexEntryUpdate value2 = add( 2, "value2" ); try ( IndexUpdater updater = proxy.newUpdater( IndexUpdateMode.ONLINE ) ) { updater.process( value2 ); @@ -1225,7 +1225,7 @@ public void stop() @Override public void acceptUpdate( MultipleIndexPopulator.MultipleIndexUpdater updater, - IndexEntryUpdate update, + IndexEntryUpdate update, long currentlyIndexedNodeId ) { // no-op 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 8ca0dbd9954f4..3595094436aa1 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 @@ -210,7 +210,7 @@ public void testFailByNonExistingPopulation() throws IOException @Test public void closeMultipleIndexPopulator() - throws IOException, IndexEntryConflictException + throws IOException { IndexPopulator indexPopulator1 = createIndexPopulator(); IndexPopulator indexPopulator2 = createIndexPopulator(); @@ -316,7 +316,7 @@ public void testMultiplePopulatorUpdater() IndexUpdater multipleIndexUpdater = multipleIndexPopulator.newPopulatingUpdater( mock( PropertyAccessor.class ) ); - IndexEntryUpdate propertyUpdate = createIndexEntryUpdate( index1 ); + IndexEntryUpdate propertyUpdate = createIndexEntryUpdate( index1 ); multipleIndexUpdater.process( propertyUpdate ); checkPopulatorFailure( indexPopulator2 ); @@ -335,7 +335,7 @@ public void testNonApplicableUpdaterDoNotUpdatePopulator() IndexUpdater multipleIndexUpdater = multipleIndexPopulator.newPopulatingUpdater( mock( PropertyAccessor.class ) ); - IndexEntryUpdate propertyUpdate = createIndexEntryUpdate( index1 ); + IndexEntryUpdate propertyUpdate = createIndexEntryUpdate( index1 ); multipleIndexUpdater.process( propertyUpdate ); verifyZeroInteractions( indexUpdater1 ); @@ -345,7 +345,7 @@ public void testNonApplicableUpdaterDoNotUpdatePopulator() public void testPropertyUpdateFailure() throws IOException, IndexEntryConflictException { - IndexEntryUpdate propertyUpdate = createIndexEntryUpdate( index1 ); + IndexEntryUpdate propertyUpdate = createIndexEntryUpdate( index1 ); IndexUpdater indexUpdater1 = mock( IndexUpdater.class ); IndexPopulator indexPopulator1 = createIndexPopulator( indexUpdater1 ); @@ -367,8 +367,8 @@ public void testMultiplePropertyUpdateFailures() throws IOException, IndexEntryConflictException { PropertyAccessor propertyAccessor = mock( PropertyAccessor.class ); - IndexEntryUpdate update1 = add( 1, index1, "foo" ); - IndexEntryUpdate update2 = add( 2, index1, "bar" ); + IndexEntryUpdate update1 = add( 1, index1, "foo" ); + IndexEntryUpdate update2 = add( 2, index1, "bar" ); IndexUpdater updater = mock( IndexUpdater.class ); IndexPopulator populator = createIndexPopulator( updater ); @@ -387,7 +387,7 @@ public void testMultiplePropertyUpdateFailures() checkPopulatorFailure( populator ); } - private IndexEntryUpdate createIndexEntryUpdate( LabelSchemaDescriptor schemaDescriptor ) + private IndexEntryUpdate createIndexEntryUpdate( LabelSchemaDescriptor schemaDescriptor ) { return add( 1, schemaDescriptor, "theValue" ); } diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/inmemory/InMemoryIndex.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/inmemory/InMemoryIndex.java index bbbbee7b70f5b..f569e74ecad59 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/inmemory/InMemoryIndex.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/inmemory/InMemoryIndex.java @@ -118,7 +118,7 @@ public void create() public void add( Collection> updates ) throws IndexEntryConflictException, IOException { - for ( IndexEntryUpdate update : updates ) + for ( IndexEntryUpdate update : updates ) { InMemoryIndex.this.add( update.getEntityId(), update.values(), false ); } @@ -159,7 +159,7 @@ public void markAsFailed( String failureString ) } @Override - public void includeSample( IndexEntryUpdate update ) + public void includeSample( IndexEntryUpdate update ) { } @@ -252,7 +252,7 @@ private InMemoryIndexUpdater( boolean applyIdempotently ) } @Override - public void process( IndexEntryUpdate update ) throws IOException, IndexEntryConflictException + public void process( IndexEntryUpdate update ) throws IOException, IndexEntryConflictException { switch ( update.updateMode() ) { diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/inmemory/UniqueInMemoryIndex.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/inmemory/UniqueInMemoryIndex.java index 5ea0e9be1b46b..e9ea0b0755557 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/inmemory/UniqueInMemoryIndex.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/inmemory/UniqueInMemoryIndex.java @@ -50,10 +50,10 @@ protected IndexUpdater newUpdater( final IndexUpdateMode mode, final boolean pop return new UniquePropertyIndexUpdater() { @Override - protected void flushUpdates( Iterable updates ) + protected void flushUpdates( Iterable> updates ) throws IOException, IndexEntryConflictException { - for ( IndexEntryUpdate update : updates ) + for ( IndexEntryUpdate update : updates ) { switch ( update.updateMode() ) { @@ -67,7 +67,7 @@ protected void flushUpdates( Iterable updates ) break; } } - for ( IndexEntryUpdate update : updates ) + for ( IndexEntryUpdate update : updates ) { switch ( update.updateMode() ) { diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/inmemory/UpdateCapturingIndexAccessor.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/inmemory/UpdateCapturingIndexAccessor.java index de1e7ee30c3ef..7c8dec2bcce5d 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/inmemory/UpdateCapturingIndexAccessor.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/inmemory/UpdateCapturingIndexAccessor.java @@ -37,9 +37,9 @@ public class UpdateCapturingIndexAccessor implements IndexAccessor { private final IndexAccessor actual; - private final Collection updates = new ArrayList<>(); + private final Collection> updates = new ArrayList<>(); - public UpdateCapturingIndexAccessor( IndexAccessor actual, Collection initialUpdates ) + public UpdateCapturingIndexAccessor( IndexAccessor actual, Collection> initialUpdates ) { this.actual = actual; if ( initialUpdates != null ) @@ -101,7 +101,7 @@ public void verifyDeferredConstraints( PropertyAccessor propertyAccessor ) throw actual.verifyDeferredConstraints( propertyAccessor ); } - public Collection snapshot() + public Collection> snapshot() { return new ArrayList<>( updates ); } diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/inmemory/UpdateCapturingIndexProvider.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/inmemory/UpdateCapturingIndexProvider.java index 61931654eb124..3135325cd50e2 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/inmemory/UpdateCapturingIndexProvider.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/inmemory/UpdateCapturingIndexProvider.java @@ -40,9 +40,9 @@ public class UpdateCapturingIndexProvider extends SchemaIndexProvider { private final SchemaIndexProvider actual; private final Map indexes = new ConcurrentHashMap<>(); - private final Map> initialUpdates; + private final Map>> initialUpdates; - public UpdateCapturingIndexProvider( SchemaIndexProvider actual, Map> initialUpdates ) + public UpdateCapturingIndexProvider( SchemaIndexProvider actual, Map>> initialUpdates ) { super( actual ); this.actual = actual; @@ -81,9 +81,9 @@ public StoreMigrationParticipant storeMigrationParticipant( FileSystemAbstractio return actual.storeMigrationParticipant( fs, pageCache ); } - public Map> snapshot() + public Map>> snapshot() { - Map> result = new HashMap<>(); + Map>> result = new HashMap<>(); indexes.forEach( ( indexId, index ) -> result.put( indexId, index.snapshot() ) ); return result; } diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/inmemory/UpdateCapturingIndexUpdater.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/inmemory/UpdateCapturingIndexUpdater.java index 1027ab4f13a3a..7e4bc1b754a1a 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/inmemory/UpdateCapturingIndexUpdater.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/index/inmemory/UpdateCapturingIndexUpdater.java @@ -29,16 +29,16 @@ public class UpdateCapturingIndexUpdater implements IndexUpdater { private final IndexUpdater actual; - private final Collection updatesTarget; + private final Collection> updatesTarget; - public UpdateCapturingIndexUpdater( IndexUpdater actual, Collection updatesTarget ) + public UpdateCapturingIndexUpdater( IndexUpdater actual, Collection> updatesTarget ) { this.actual = actual; this.updatesTarget = updatesTarget; } @Override - public void process( IndexEntryUpdate update ) throws IOException, IndexEntryConflictException + public void process( IndexEntryUpdate update ) throws IOException, IndexEntryConflictException { actual.process( update ); updatesTarget.add( update ); diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/state/NodeStoreScanTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/state/NodeStoreScanTest.java index 25c62c13c1567..d2b1b13e5bbe0 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/state/NodeStoreScanTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/state/NodeStoreScanTest.java @@ -61,19 +61,19 @@ public void shouldGiveBackCompletionPercentage() throws Throwable final PercentageSupplier percentageSupplier = new PercentageSupplier(); - final NodeStoreScan scan = new NodeStoreScan( nodeStore, locks, total ) + final NodeStoreScan scan = new NodeStoreScan( nodeStore, locks, total ) { private int read; @Override - public void acceptUpdate( MultipleIndexPopulator.MultipleIndexUpdater updater, IndexEntryUpdate update, + public void acceptUpdate( MultipleIndexPopulator.MultipleIndexUpdater updater, IndexEntryUpdate update, long currentlyIndexedNodeId ) { // no-op } @Override - public void configure( Collection populations ) + public void configure( Collection populations ) { // no-op } @@ -96,7 +96,7 @@ public void process( NodeRecord node ) private static class PercentageSupplier implements Supplier { - private StoreScan storeScan; + private StoreScan storeScan; @Override public Float get() @@ -106,7 +106,7 @@ public Float get() return (float) progress.getCompleted() / (float) progress.getTotal(); } - public void setStoreScan( StoreScan storeScan ) + public void setStoreScan( StoreScan storeScan ) { this.storeScan = storeScan; } diff --git a/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/LuceneIndexAccessor.java b/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/LuceneIndexAccessor.java index 23c025d49b1dc..3e683696dc38e 100644 --- a/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/LuceneIndexAccessor.java +++ b/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/LuceneIndexAccessor.java @@ -59,10 +59,10 @@ public IndexUpdater newUpdater( IndexUpdateMode mode ) switch ( mode ) { case ONLINE: - return new LuceneIndexUpdater( writer, false ); + return new LuceneIndexUpdater( false ); case RECOVERY: - return new LuceneIndexUpdater( writer, true ); + return new LuceneIndexUpdater( true ); default: throw new IllegalArgumentException( "Unsupported update mode: " + mode ); @@ -123,17 +123,15 @@ public void verifyDeferredConstraints( PropertyAccessor propertyAccessor ) private class LuceneIndexUpdater implements IndexUpdater { private final boolean isRecovery; - private final LuceneIndexWriter writer; private boolean hasChanges; - private LuceneIndexUpdater( LuceneIndexWriter indexWriter, boolean isRecovery ) + private LuceneIndexUpdater( boolean isRecovery ) { this.isRecovery = isRecovery; - this.writer = indexWriter; } @Override - public void process( IndexEntryUpdate update ) throws IOException + public void process( IndexEntryUpdate update ) throws IOException { // we do not support adding partial entries assert update.indexKey().schema().equals( descriptor.schema() ); diff --git a/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/populator/LuceneIndexPopulatingUpdater.java b/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/populator/LuceneIndexPopulatingUpdater.java index 582d46558a5be..9ea9dfa5600b0 100644 --- a/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/populator/LuceneIndexPopulatingUpdater.java +++ b/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/populator/LuceneIndexPopulatingUpdater.java @@ -46,7 +46,7 @@ public LuceneIndexPopulatingUpdater( LuceneIndexWriter writer ) } @Override - public void process( IndexEntryUpdate update ) throws IOException, IndexEntryConflictException + public void process( IndexEntryUpdate update ) throws IOException, IndexEntryConflictException { long nodeId = update.getEntityId(); @@ -76,19 +76,19 @@ public void process( IndexEntryUpdate update ) throws IOException, IndexEntryCon * * @param update the update being processed. */ - protected abstract void added( IndexEntryUpdate update ); + protected abstract void added( IndexEntryUpdate update ); /** * Method is invoked when {@link IndexEntryUpdate} with {@link UpdateMode#CHANGED} is processed. * * @param update the update being processed. */ - protected abstract void changed( IndexEntryUpdate update ); + protected abstract void changed( IndexEntryUpdate update ); /** * Method is invoked when {@link IndexEntryUpdate} with {@link UpdateMode#REMOVED} is processed. * * @param update the update being processed. */ - protected abstract void removed( IndexEntryUpdate update ); + protected abstract void removed( IndexEntryUpdate update ); } diff --git a/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/populator/LuceneIndexPopulator.java b/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/populator/LuceneIndexPopulator.java index 02717d6029263..88840df60d58d 100644 --- a/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/populator/LuceneIndexPopulator.java +++ b/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/populator/LuceneIndexPopulator.java @@ -94,7 +94,7 @@ public void markAsFailed( String failure ) throws IOException private boolean updatesForCorrectIndex( Collection> updates ) { - for ( IndexEntryUpdate update : updates ) + for ( IndexEntryUpdate update : updates ) { if ( !update.indexKey().schema().equals( luceneIndex.getDescriptor().schema() ) ) { @@ -104,7 +104,7 @@ private boolean updatesForCorrectIndex( Collection return true; } - private static Document updateAsDocument( IndexEntryUpdate update ) + private static Document updateAsDocument( IndexEntryUpdate update ) { return LuceneDocumentStructure.documentRepresentingProperties( update.getEntityId(), update.values() ); } diff --git a/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/populator/NonUniqueLuceneIndexPopulatingUpdater.java b/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/populator/NonUniqueLuceneIndexPopulatingUpdater.java index 2e88bccd30ee8..6abc901ab1d30 100644 --- a/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/populator/NonUniqueLuceneIndexPopulatingUpdater.java +++ b/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/populator/NonUniqueLuceneIndexPopulatingUpdater.java @@ -38,14 +38,14 @@ public NonUniqueLuceneIndexPopulatingUpdater( LuceneIndexWriter writer, NonUniqu } @Override - protected void added( IndexEntryUpdate update ) + protected void added( IndexEntryUpdate update ) { String encodedValue = LuceneDocumentStructure.encodedStringValuesForSampling( update.values() ); sampler.include( encodedValue ); } @Override - protected void changed( IndexEntryUpdate update ) + protected void changed( IndexEntryUpdate update ) { String encodedValueBefore = LuceneDocumentStructure.encodedStringValuesForSampling( update.beforeValues() ); sampler.exclude( encodedValueBefore ); @@ -55,7 +55,7 @@ protected void changed( IndexEntryUpdate update ) } @Override - protected void removed( IndexEntryUpdate update ) + protected void removed( IndexEntryUpdate update ) { String removedValue = LuceneDocumentStructure.encodedStringValuesForSampling( update.values() ); sampler.exclude( removedValue ); diff --git a/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/populator/NonUniqueLuceneIndexPopulator.java b/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/populator/NonUniqueLuceneIndexPopulator.java index 0276f0cbe769d..4a99cacab2836 100644 --- a/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/populator/NonUniqueLuceneIndexPopulator.java +++ b/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/populator/NonUniqueLuceneIndexPopulator.java @@ -70,7 +70,7 @@ public IndexUpdater newPopulatingUpdater( PropertyAccessor propertyAccessor ) th } @Override - public void includeSample( IndexEntryUpdate update ) + public void includeSample( IndexEntryUpdate update ) { if ( updateSampling ) { diff --git a/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/populator/UniqueLuceneIndexPopulatingUpdater.java b/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/populator/UniqueLuceneIndexPopulatingUpdater.java index 3b0495bf511b9..38350150a37fc 100644 --- a/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/populator/UniqueLuceneIndexPopulatingUpdater.java +++ b/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/populator/UniqueLuceneIndexPopulatingUpdater.java @@ -56,20 +56,20 @@ public UniqueLuceneIndexPopulatingUpdater( LuceneIndexWriter writer, int[] prope } @Override - protected void added( IndexEntryUpdate update ) + protected void added( IndexEntryUpdate update ) { sampler.increment( 1 ); updatedValueTuples.add( update.values() ); } @Override - protected void changed( IndexEntryUpdate update ) + protected void changed( IndexEntryUpdate update ) { updatedValueTuples.add( update.values() ); } @Override - protected void removed( IndexEntryUpdate update ) + protected void removed( IndexEntryUpdate update ) { sampler.increment( -1 ); } diff --git a/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/populator/UniqueLuceneIndexPopulator.java b/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/populator/UniqueLuceneIndexPopulator.java index cd4a6c6e5487f..244820c9e2c50 100644 --- a/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/populator/UniqueLuceneIndexPopulator.java +++ b/community/lucene-index/src/main/java/org/neo4j/kernel/api/impl/schema/populator/UniqueLuceneIndexPopulator.java @@ -61,7 +61,7 @@ public IndexUpdater newPopulatingUpdater( final PropertyAccessor accessor ) thro } @Override - public void includeSample( IndexEntryUpdate update ) + public void includeSample( IndexEntryUpdate update ) { sampler.increment( 1 ); } diff --git a/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/index/LuceneSchemaIndexPopulationIT.java b/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/index/LuceneSchemaIndexPopulationIT.java index 3b567f7061d78..a964e5dad51ee 100644 --- a/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/index/LuceneSchemaIndexPopulationIT.java +++ b/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/index/LuceneSchemaIndexPopulationIT.java @@ -60,17 +60,17 @@ public class LuceneSchemaIndexPopulationIT @Rule public final DefaultFileSystemRule fileSystemRule = new DefaultFileSystemRule(); - private int affectedNodes; + private final int affectedNodes; private final IndexDescriptor descriptor = IndexDescriptorFactory.uniqueForLabel( 0, 0 ); @Before - public void before() throws Exception + public void before() { System.setProperty( "luceneSchemaIndex.maxPartitionSize", "10" ); } @After - public void after() throws IOException + public void after() { System.setProperty( "luceneSchemaIndex.maxPartitionSize", "" ); } @@ -136,7 +136,7 @@ private void generateUpdates( LuceneIndexAccessor indexAccessor, int nodesToUpda } } - private IndexEntryUpdate add( long nodeId, Object value ) + private IndexEntryUpdate add( long nodeId, Object value ) { return IndexEntryUpdate.add( nodeId, descriptor.schema(), Values.of( value ) ); } diff --git a/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/AccessUniqueDatabaseIndexTest.java b/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/AccessUniqueDatabaseIndexTest.java index fc10abcef206c..01d2f842c407a 100644 --- a/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/AccessUniqueDatabaseIndexTest.java +++ b/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/AccessUniqueDatabaseIndexTest.java @@ -142,24 +142,24 @@ private LuceneIndexAccessor createAccessor( PartitionedIndexStorage indexStorage return new LuceneIndexAccessor( luceneIndex, index ); } - private PartitionedIndexStorage getIndexStorage() throws IOException + private PartitionedIndexStorage getIndexStorage() { IndexStorageFactory storageFactory = new IndexStorageFactory( directoryFactory, fileSystemRule.get(), indexDirectory ); return storageFactory.indexStorageOf( 1, false ); } - private IndexEntryUpdate add( long nodeId, Object propertyValue ) + private IndexEntryUpdate add( long nodeId, Object propertyValue ) { return IndexQueryHelper.add( nodeId, index.schema(), propertyValue ); } - private IndexEntryUpdate change( long nodeId, Object oldValue, Object newValue ) + private IndexEntryUpdate change( long nodeId, Object oldValue, Object newValue ) { return IndexQueryHelper.change( nodeId, index.schema(), oldValue, newValue ); } - private IndexEntryUpdate remove( long nodeId, Object oldValue ) + private IndexEntryUpdate remove( long nodeId, Object oldValue ) { return IndexQueryHelper.remove( nodeId, index.schema(), oldValue ); } @@ -170,12 +170,12 @@ private List getAllNodes( PartitionedIndexStorage indexStorage, String pro Values.stringValue( propertyValue ) ); } - private void updateAndCommit( IndexAccessor accessor, Iterable updates ) + private void updateAndCommit( IndexAccessor accessor, Iterable> updates ) throws IOException, IndexEntryConflictException { try ( IndexUpdater updater = accessor.newUpdater( IndexUpdateMode.ONLINE ) ) { - for ( IndexEntryUpdate update : updates ) + for ( IndexEntryUpdate update : updates ) { updater.process( update ); } 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 e01f8854a103b..0bae4b0450280 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 @@ -121,6 +121,7 @@ public static Collection[]> imp ); } + @SuppressWarnings( "unchecked" ) private static IOFunction[] arg( IOFunction foo ) { @@ -260,31 +261,30 @@ public void shouldStopSamplingWhenIndexIsDropped() throws Exception } } - private IndexEntryUpdate add( long nodeId, Object... values ) + private IndexEntryUpdate add( long nodeId, Object... values ) { return IndexQueryHelper.add( nodeId, indexDescriptor.schema(), values ); } - private IndexEntryUpdate remove( long nodeId, Object... values ) + private IndexEntryUpdate remove( long nodeId, Object... values ) { return IndexQueryHelper.remove( nodeId, indexDescriptor.schema(), values ); } - private IndexEntryUpdate change( long nodeId, Object[] valuesBefore, Object[] valuesAfter ) + private IndexEntryUpdate change( long nodeId, Object[] valuesBefore, Object[] valuesAfter ) { return IndexQueryHelper.change( nodeId, indexDescriptor.schema(), valuesBefore, valuesAfter ); } - private void updateAndCommit( List nodePropertyUpdates ) + private void updateAndCommit( List> nodePropertyUpdates ) throws IOException, IndexEntryConflictException { try ( IndexUpdater updater = accessor.newUpdater( IndexUpdateMode.ONLINE ) ) { - for ( IndexEntryUpdate update : nodePropertyUpdates ) + for ( IndexEntryUpdate update : nodePropertyUpdates ) { updater.process( update ); } } } - } diff --git a/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/DatabaseIndexAccessorTest.java b/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/DatabaseIndexAccessorTest.java index aa6709a3a0ac1..f70cae171bde4 100644 --- a/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/DatabaseIndexAccessorTest.java +++ b/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/DatabaseIndexAccessorTest.java @@ -329,27 +329,27 @@ public void shouldStopSamplingWhenIndexIsDropped() throws Exception } } - private IndexEntryUpdate add( long nodeId, Object value ) + private IndexEntryUpdate add( long nodeId, Object value ) { return IndexQueryHelper.add( nodeId, index.schema(), value ); } - private IndexEntryUpdate remove( long nodeId, Object value ) + private IndexEntryUpdate remove( long nodeId, Object value ) { return IndexQueryHelper.remove( nodeId, index.schema(), value ); } - private IndexEntryUpdate change( long nodeId, Object valueBefore, Object valueAfter ) + private IndexEntryUpdate change( long nodeId, Object valueBefore, Object valueAfter ) { return IndexQueryHelper.change( nodeId, index.schema(), valueBefore, valueAfter ); } - private void updateAndCommit( List nodePropertyUpdates ) + private void updateAndCommit( List> nodePropertyUpdates ) throws IOException, IndexEntryConflictException { try ( IndexUpdater updater = accessor.newUpdater( IndexUpdateMode.ONLINE ) ) { - for ( IndexEntryUpdate update : nodePropertyUpdates ) + for ( IndexEntryUpdate update : nodePropertyUpdates ) { updater.process( update ); } diff --git a/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/LuceneSchemaIndexIT.java b/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/LuceneSchemaIndexIT.java index ea05b7ca46790..e9029b40cde8a 100644 --- a/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/LuceneSchemaIndexIT.java +++ b/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/LuceneSchemaIndexIT.java @@ -64,16 +64,16 @@ public class LuceneSchemaIndexIT @Rule public final DefaultFileSystemRule fileSystemRule = new DefaultFileSystemRule(); - private IndexDescriptor descriptor = IndexDescriptorFactory.forLabel( 0, 0 ); + private final IndexDescriptor descriptor = IndexDescriptorFactory.forLabel( 0, 0 ); @Before - public void before() throws Exception + public void before() { System.setProperty( "luceneSchemaIndex.maxPartitionSize", "10" ); } @After - public void after() throws IOException + public void after() { System.setProperty( "luceneSchemaIndex.maxPartitionSize", "" ); } @@ -123,7 +123,7 @@ public void snapshotForIndexWithNoCommits() throws Exception } @Test - public void updateMultiplePartitionedIndex() throws IOException, IndexEntryConflictException + public void updateMultiplePartitionedIndex() throws IOException { try ( SchemaIndex index = LuceneSchemaIndexBuilder.create( descriptor ) .withFileSystem( fileSystemRule.get() ) @@ -308,9 +308,8 @@ private void generateUpdates( LuceneIndexAccessor indexAccessor, int nodesToUpda } } - private IndexEntryUpdate add( long nodeId, Object value ) + private IndexEntryUpdate add( long nodeId, Object value ) { return IndexEntryUpdate.add( nodeId, descriptor.schema(), Values.of( 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 fb7572da2bcee..61ea8954ed069 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 @@ -256,17 +256,17 @@ private static class Hit } } - private IndexEntryUpdate add( long nodeId, Object value ) + private IndexEntryUpdate add( long nodeId, Object value ) { return IndexQueryHelper.add( nodeId, index.schema(), value ); } - private IndexEntryUpdate change( long nodeId, Object valueBefore, Object valueAfter ) + private IndexEntryUpdate change( long nodeId, Object valueBefore, Object valueAfter ) { return IndexQueryHelper.change( nodeId, index.schema(), valueBefore, valueAfter ); } - private IndexEntryUpdate remove( long nodeId, Object removedValue ) + private IndexEntryUpdate remove( long nodeId, Object removedValue ) { return IndexQueryHelper.remove( nodeId, index.schema(), removedValue ); } @@ -305,13 +305,13 @@ private static void addUpdate( IndexPopulator populator, long nodeId, Object val private static void updatePopulator( IndexPopulator populator, - Iterable updates, + Iterable> updates, PropertyAccessor accessor ) throws IOException, IndexEntryConflictException { try ( IndexUpdater updater = populator.newPopulatingUpdater( accessor ) ) { - for ( IndexEntryUpdate update : updates ) + for ( IndexEntryUpdate update : updates ) { updater.process( update ); } diff --git a/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/populator/NonUniqueDatabaseIndexPopulatorTest.java b/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/populator/NonUniqueDatabaseIndexPopulatorTest.java index 3ee022c6fdc5b..bce88168ed74a 100644 --- a/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/populator/NonUniqueDatabaseIndexPopulatorTest.java +++ b/community/lucene-index/src/test/java/org/neo4j/kernel/api/impl/schema/populator/NonUniqueDatabaseIndexPopulatorTest.java @@ -63,7 +63,7 @@ public class NonUniqueDatabaseIndexPopulatorTest private SchemaIndex index; private NonUniqueLuceneIndexPopulator populator; - private LabelSchemaDescriptor labelSchemaDescriptor = SchemaDescriptorFactory.forLabel( 0, 0 ); + private final LabelSchemaDescriptor labelSchemaDescriptor = SchemaDescriptorFactory.forLabel( 0, 0 ); @Before public void setUp() throws Exception @@ -102,7 +102,7 @@ public void sampleIncludedUpdates() throws Exception { populator = newPopulator(); - List updates = Arrays.asList( + List> updates = Arrays.asList( add( 1, labelSchemaDescriptor, "aaa" ), add( 2, labelSchemaDescriptor, "bbb" ), add( 3, labelSchemaDescriptor, "ccc" ) ); @@ -119,7 +119,7 @@ public void sampleIncludedUpdatesWithDuplicates() throws Exception { populator = newPopulator(); - List updates = Arrays.asList( + List> updates = Arrays.asList( add( 1, labelSchemaDescriptor, "foo" ), add( 2, labelSchemaDescriptor, "bar" ), add( 3, labelSchemaDescriptor, "foo" ) ); 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 19faac2aa1d98..3993ee2a1d944 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 @@ -513,7 +513,7 @@ public void sampleIncludedUpdates() throws Exception { LabelSchemaDescriptor schemaDescriptor = SchemaDescriptorFactory.forLabel( 1, 1 ); populator = newPopulator(); - List updates = Arrays.asList( + List> updates = Arrays.asList( add( 1, schemaDescriptor, "foo" ), add( 2, schemaDescriptor, "bar" ), add( 3, schemaDescriptor, "baz" ), diff --git a/community/neo4j/src/test/java/schema/MultiIndexPopulationConcurrentUpdatesIT.java b/community/neo4j/src/test/java/schema/MultiIndexPopulationConcurrentUpdatesIT.java index a7d2585153607..bfee2534cf8db 100644 --- a/community/neo4j/src/test/java/schema/MultiIndexPopulationConcurrentUpdatesIT.java +++ b/community/neo4j/src/test/java/schema/MultiIndexPopulationConcurrentUpdatesIT.java @@ -428,22 +428,22 @@ public StoreScan visitNodes( int[] labelIds { StoreScan storeScan = super.visitNodes( labelIds, propertyKeyIdFilter, propertyUpdatesVisitor, labelUpdateVisitor, forceStoreScan ); - return new LabelScanViewNodeStoreWrapper( nodeStore, locks, propertyStore, getLabelScanStore(), + return new LabelScanViewNodeStoreWrapper<>( nodeStore, locks, propertyStore, getLabelScanStore(), element -> false, propertyUpdatesVisitor, labelIds, propertyKeyIdFilter, - (LabelScanViewNodeStoreScan) storeScan, updates ); + (LabelScanViewNodeStoreScan) storeScan, updates ); } } - private class LabelScanViewNodeStoreWrapper extends LabelScanViewNodeStoreScan + private class LabelScanViewNodeStoreWrapper extends LabelScanViewNodeStoreScan { - private final LabelScanViewNodeStoreScan delegate; + private final LabelScanViewNodeStoreScan delegate; private final List updates; LabelScanViewNodeStoreWrapper( NodeStore nodeStore, LockService locks, PropertyStore propertyStore, - LabelScanStore labelScanStore, Visitor labelUpdateVisitor, - Visitor propertyUpdatesVisitor, int[] labelIds, IntPredicate propertyKeyIdFilter, - LabelScanViewNodeStoreScan delegate, + LabelScanStore labelScanStore, Visitor labelUpdateVisitor, + Visitor propertyUpdatesVisitor, int[] labelIds, IntPredicate propertyKeyIdFilter, + LabelScanViewNodeStoreScan delegate, List updates ) { super( nodeStore, locks, propertyStore, labelScanStore, labelUpdateVisitor, @@ -453,7 +453,7 @@ private class LabelScanViewNodeStoreWrapper extends LabelScanViewNodeStoreScan } @Override - public void acceptUpdate( MultipleIndexPopulator.MultipleIndexUpdater updater, IndexEntryUpdate update, + public void acceptUpdate( MultipleIndexPopulator.MultipleIndexUpdater updater, IndexEntryUpdate update, long currentlyIndexedNodeId ) { delegate.acceptUpdate( updater, update, currentlyIndexedNodeId ); @@ -501,7 +501,7 @@ public long next() for ( int labelId : labelsNameIdMap.values() ) { LabelSchemaDescriptor schema = SchemaDescriptorFactory.forLabel( labelId, propertyId ); - for ( IndexEntryUpdate indexUpdate : + for ( IndexEntryUpdate indexUpdate : update.forIndexKeys( Collections.singleton( schema ) ) ) { switch ( indexUpdate.updateMode() ) 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 c49056fe57133..ef05d0e6ea572 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 @@ -473,7 +473,7 @@ public void markAsFailed( String failure ) throws IOException } @Override - public void includeSample( IndexEntryUpdate update ) + public void includeSample( IndexEntryUpdate update ) { delegate.includeSample( update ); }