From 7008cf7225bcf9938f4eae430320df05d58245b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Finn=C3=A9?= Date: Thu, 4 Oct 2018 07:25:38 +0200 Subject: [PATCH] Fixes some delegation issues ParallelNativeIndexPopulator --- .../impl/index/schema/NativeIndexPopulator.java | 5 +++++ .../index/schema/ParallelNativeIndexPopulator.java | 11 ++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/NativeIndexPopulator.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/NativeIndexPopulator.java index b7347429d4eef..b0504814f313f 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/NativeIndexPopulator.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/NativeIndexPopulator.java @@ -152,6 +152,11 @@ public void verifyDeferredConstraints( NodePropertyAccessor nodePropertyAccessor @Override public IndexUpdater newPopulatingUpdater( NodePropertyAccessor accessor ) + { + return newPopulatingUpdater(); + } + + IndexUpdater newPopulatingUpdater() { IndexUpdater updater = new CollectingIndexUpdater() { diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/ParallelNativeIndexPopulator.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/ParallelNativeIndexPopulator.java index 69a4314267ac9..0bca66a38d5e3 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/ParallelNativeIndexPopulator.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/ParallelNativeIndexPopulator.java @@ -57,7 +57,6 @@ class ParallelNativeIndexPopulator,VALUE extends private final List partPopulators = new CopyOnWriteArrayList<>(); private NativeIndexPopulator completePopulator; private String failure; - private volatile NodePropertyAccessor propertyAccessor; // There are various access points considered to be the "first" after population is completed, // be it verifyDeferredConstraints, sampleResult or some other call. Regardless all of those methods // have to be able to merge the parts into the real index. This is what this flag is all about. @@ -120,14 +119,15 @@ public void add( Collection> scanBatch ) throws In public void verifyDeferredConstraints( NodePropertyAccessor nodePropertyAccessor ) { ensureMerged(); - partPopulators.forEach( p -> p.populator.verifyDeferredConstraints( nodePropertyAccessor ) ); + completePopulator.verifyDeferredConstraints( nodePropertyAccessor ); } @Override public IndexUpdater newPopulatingUpdater( NodePropertyAccessor accessor ) { + // Native index populators don't make use of NodePropertyAccessor, so just ignore it + // Don't have an explicit updatesPopulator, instead record these updates and then each populator will have to apply next time they notice. - propertyAccessor = accessor; return new CollectingIndexUpdater() { @Override @@ -259,12 +259,13 @@ private void mergeParts() throws IOException, IndexEntryConflictException public void markAsFailed( String failure ) { this.failure = failure; - partPopulators.forEach( p -> p.populator.markAsFailed( failure ) ); + completePopulator.markAsFailed( failure ); } @Override public void includeSample( IndexEntryUpdate update ) { + completePopulator.includeSample( update ); } @Override @@ -320,7 +321,7 @@ void applyQueuedUpdates() throws IndexEntryConflictException { if ( !updates.isEmpty() ) { - try ( IndexUpdater updater = populator.newPopulatingUpdater( propertyAccessor ) ) + try ( IndexUpdater updater = populator.newPopulatingUpdater() ) { Collection> batch; while ( (batch = updates.poll()) != null )