Skip to content

Commit

Permalink
Fixes some delegation issues ParallelNativeIndexPopulator
Browse files Browse the repository at this point in the history
  • Loading branch information
tinwelint committed Oct 10, 2018
1 parent da0736f commit 7008cf7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Expand Up @@ -152,6 +152,11 @@ public void verifyDeferredConstraints( NodePropertyAccessor nodePropertyAccessor

@Override
public IndexUpdater newPopulatingUpdater( NodePropertyAccessor accessor )
{
return newPopulatingUpdater();
}

IndexUpdater newPopulatingUpdater()
{
IndexUpdater updater = new CollectingIndexUpdater<KEY,VALUE>()
{
Expand Down
Expand Up @@ -57,7 +57,6 @@ class ParallelNativeIndexPopulator<KEY extends NativeIndexKey<KEY>,VALUE extends
private final List<ThreadLocalPopulator> partPopulators = new CopyOnWriteArrayList<>();
private NativeIndexPopulator<KEY,VALUE> 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.
Expand Down Expand Up @@ -120,14 +119,15 @@ public void add( Collection<? extends IndexEntryUpdate<?>> 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<KEY,VALUE>()
{
@Override
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -320,7 +321,7 @@ void applyQueuedUpdates() throws IndexEntryConflictException
{
if ( !updates.isEmpty() )
{
try ( IndexUpdater updater = populator.newPopulatingUpdater( propertyAccessor ) )
try ( IndexUpdater updater = populator.newPopulatingUpdater() )
{
Collection<IndexEntryUpdate<?>> batch;
while ( (batch = updates.poll()) != null )
Expand Down

0 comments on commit 7008cf7

Please sign in to comment.