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(); IndexPopulator EMPTY = new Adapter();


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

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


@Override
public void scanCompleted()
{
}

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

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


private class EntityPopulationVisitor implements Visitor<EntityUpdates, 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.api.index.NodePropertyAccessor;
import org.neo4j.kernel.impl.index.schema.config.IndexSpecificSpaceFillingCurveSettingsCache; import org.neo4j.kernel.impl.index.schema.config.IndexSpecificSpaceFillingCurveSettingsCache;
import org.neo4j.kernel.impl.index.schema.config.SpaceFillingCurveSettingsWriter; 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.storageengine.api.schema.StoreIndexDescriptor;
import org.neo4j.util.FeatureToggles; import org.neo4j.util.FeatureToggles;
import org.neo4j.util.Preconditions; 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 ); storeUpdate( update.getEntityId(), update.values(), blockStorage );
} }


void finishUp() throws IndexEntryConflictException @Override
public void scanCompleted() throws IndexEntryConflictException
{ {
try 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 private void writeExternalUpdatesToTree() throws IOException
{ {
try ( Writer<KEY,VALUE> writer = tree.writer(); 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 @Override
public IndexUpdater newPopulatingUpdater( NodePropertyAccessor accessor ) 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" ); File tempFile = new File( blockFile.getParent(), blockFile.getName() + ".b" );
try try
{ {
int mergeFactor = 10; int mergeFactor = 16;
File targetFile = tempFile; File targetFile = tempFile;
while ( numberOfBlocksInCurrentFile > 1 ) while ( numberOfBlocksInCurrentFile > 1 )
{ {
Expand Down
Expand Up @@ -137,6 +137,12 @@ public void consistencyCheck()
actual.consistencyCheck(); actual.consistencyCheck();
} }


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

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

0 comments on commit 22bd340

Please sign in to comment.