Skip to content

Commit

Permalink
Some attempt to call IndexPopulator#scanCompleted
Browse files Browse the repository at this point in the history
  • Loading branch information
tinwelint authored and burqen committed Feb 18, 2019
1 parent 81119ff commit 22bd340
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 25 deletions.
Expand Up @@ -141,6 +141,10 @@ public interface IndexPopulator

IndexPopulator EMPTY = new Adapter();

default void scanCompleted() throws IndexEntryConflictException
{ // no-op by default
}

class Adapter implements IndexPopulator
{
@Override
Expand All @@ -164,6 +168,11 @@ public IndexUpdater newPopulatingUpdater( NodePropertyAccessor accessor )
return SwallowingIndexUpdater.INSTANCE;
}

@Override
public void scanCompleted()
{
}

@Override
public void close( boolean populationCompletedSuccessfully )
{
Expand Down
Expand Up @@ -293,6 +293,12 @@ public IndexSample sampleResult()
throw new UnsupportedOperationException( "Multiple index populator can't perform index sampling." );
}

@Override
public void scanCompleted()
{
throw new UnsupportedOperationException( "Not supposed to be called" );
}

void resetIndexCounts()
{
forEachPopulation( this::resetIndexCountsForPopulation );
Expand All @@ -309,6 +315,7 @@ void flipAfterPopulation( boolean verifyBeforeFlipping )
{
try
{
population.scanCompleted();
population.flip( verifyBeforeFlipping );
}
catch ( Throwable t )
Expand Down Expand Up @@ -634,6 +641,11 @@ Collection<IndexEntryUpdate<?>> takeCurrentBatch()
batchedUpdates = new ArrayList<>( BATCH_SIZE );
return batch;
}

void scanCompleted() throws IndexEntryConflictException
{
populator.scanCompleted();
}
}

private class EntityPopulationVisitor implements Visitor<EntityUpdates,
Expand Down
Expand Up @@ -39,7 +39,6 @@
import org.neo4j.kernel.api.index.NodePropertyAccessor;
import org.neo4j.kernel.impl.index.schema.config.IndexSpecificSpaceFillingCurveSettingsCache;
import org.neo4j.kernel.impl.index.schema.config.SpaceFillingCurveSettingsWriter;
import org.neo4j.storageengine.api.schema.IndexSample;
import org.neo4j.storageengine.api.schema.StoreIndexDescriptor;
import org.neo4j.util.FeatureToggles;
import org.neo4j.util.Preconditions;
Expand Down Expand Up @@ -137,7 +136,8 @@ private void storeUpdate( IndexEntryUpdate<?> update, BlockStorage<KEY,VALUE> bl
storeUpdate( update.getEntityId(), update.values(), blockStorage );
}

void finishUp() throws IndexEntryConflictException
@Override
public void scanCompleted() throws IndexEntryConflictException
{
try
{
Expand All @@ -158,20 +158,6 @@ void finishUp() throws IndexEntryConflictException
}
}

@Override
public IndexSample sampleResult()
{
try
{
finishUp();
return super.sampleResult();
}
catch ( IndexEntryConflictException e )
{
throw new IllegalStateException( e );
}
}

private void writeExternalUpdatesToTree() throws IOException
{
try ( Writer<KEY,VALUE> writer = tree.writer();
Expand Down Expand Up @@ -223,14 +209,6 @@ private void writeScanUpdatesToTree() throws IOException, IndexEntryConflictExce
}
}

@Override
public void verifyDeferredConstraints( NodePropertyAccessor nodePropertyAccessor ) throws IndexEntryConflictException
{
// On building tree
finishUp(); // TODO just kidding, perhaps not here
super.verifyDeferredConstraints( nodePropertyAccessor );
}

@Override
public IndexUpdater newPopulatingUpdater( NodePropertyAccessor accessor )
{
Expand Down
Expand Up @@ -125,7 +125,7 @@ public void merge() throws IOException
File tempFile = new File( blockFile.getParent(), blockFile.getName() + ".b" );
try
{
int mergeFactor = 10;
int mergeFactor = 16;
File targetFile = tempFile;
while ( numberOfBlocksInCurrentFile > 1 )
{
Expand Down
Expand Up @@ -137,6 +137,12 @@ public void consistencyCheck()
actual.consistencyCheck();
}

@Override
public void scanCompleted() throws IndexEntryConflictException
{
actual.scanCompleted();
}

private class IndexUpdateApply
{
void process( Collection<? extends IndexEntryUpdate<?>> indexEntryUpdates ) throws Exception
Expand Down

0 comments on commit 22bd340

Please sign in to comment.