Skip to content

Commit

Permalink
Refactor Adaptable store view - move new methods to store scan. Updat…
Browse files Browse the repository at this point in the history
…e tests.
  • Loading branch information
MishaDemianenko committed Sep 27, 2016
1 parent d830275 commit 1aa2ef8
Show file tree
Hide file tree
Showing 21 changed files with 466 additions and 401 deletions.
Expand Up @@ -39,6 +39,8 @@

import org.neo4j.function.Predicates;
import org.neo4j.helpers.Exceptions;
import org.neo4j.kernel.api.exceptions.EntityNotFoundException;
import org.neo4j.kernel.api.exceptions.PropertyNotFoundException;
import org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException;
import org.neo4j.kernel.api.exceptions.index.IndexPopulationFailedKernelException;
import org.neo4j.kernel.api.index.IndexConfiguration;
Expand Down Expand Up @@ -407,10 +409,30 @@ public void stop()
delegate.stop();
}

@Override
public void complete( IndexPopulator indexPopulator, IndexDescriptor descriptor )
throws EntityNotFoundException, PropertyNotFoundException, IOException, IndexEntryConflictException
{
delegate.complete( indexPopulator, descriptor );
}

@Override
public void acceptUpdate( MultipleIndexUpdater updater, NodePropertyUpdate update,
long currentlyIndexedNodeId )
{
delegate.acceptUpdate( updater, update, currentlyIndexedNodeId );
}

@Override
public PopulationProgress getProgress()
{
return delegate.getProgress();
}

@Override
public void configure( List<IndexPopulation> populations )
{
delegate.configure( populations );
}
}
}
Expand Up @@ -21,6 +21,7 @@

import java.io.IOException;
import java.util.Collection;
import java.util.List;
import java.util.function.IntPredicate;

import org.neo4j.helpers.collection.Visitor;
Expand Down Expand Up @@ -68,21 +69,6 @@ <FAILURE extends Exception> StoreScan<FAILURE> visitNodes(

void incrementIndexUpdates( IndexDescriptor descriptor, long updatesDelta );

/**
* Check if provided node update is applicable in a context of current store view.
*
* @param updater
* @param update update to check
* @param currentlyIndexedNodeId id of currently indexed node
*/
void acceptUpdate( MultipleIndexPopulator.MultipleIndexUpdater updater, NodePropertyUpdate update,
long currentlyIndexedNodeId );

void complete( IndexPopulator populator, IndexDescriptor descriptor )
throws EntityNotFoundException, PropertyNotFoundException, IOException, IndexEntryConflictException;

boolean isFullScan();

StoreScan EMPTY_SCAN = new StoreScan()
{
@Override
Expand All @@ -95,11 +81,31 @@ public void stop()
{
}

@Override
public void complete( IndexPopulator indexPopulator, IndexDescriptor descriptor )
throws EntityNotFoundException, PropertyNotFoundException, IOException, IndexEntryConflictException
{

}

@Override
public void acceptUpdate( MultipleIndexPopulator.MultipleIndexUpdater updater, NodePropertyUpdate update,
long currentlyIndexedNodeId )
{

}

@Override
public PopulationProgress getProgress()
{
return PopulationProgress.DONE;
}

@Override
public void configure( List list )
{

}
};

IndexStoreView EMPTY = new IndexStoreView()
Expand Down Expand Up @@ -146,25 +152,5 @@ public void incrementIndexUpdates( IndexDescriptor descriptor, long updatesDelta
{
}

@Override
public void acceptUpdate( MultipleIndexPopulator.MultipleIndexUpdater updater, NodePropertyUpdate update,
long currentlyIndexedNodeId )
{
}

@Override
public void complete( IndexPopulator populator, IndexDescriptor descriptor )
{

}

@Override
public boolean isFullScan()
{
return true;
}
};



}
Expand Up @@ -93,6 +93,7 @@ public class MultipleIndexPopulator implements IndexPopulator
private final IndexStoreView storeView;
private final LogProvider logProvider;
protected final Log log;
private StoreScan<IndexPopulationFailedKernelException> storeScan;

public MultipleIndexPopulator( IndexStoreView storeView, LogProvider logProvider )
{
Expand Down Expand Up @@ -155,13 +156,9 @@ public StoreScan<IndexPopulationFailedKernelException> indexAllNodes()
int[] propertyKeyIds = propertyKeyIds();
IntPredicate propertyKeyIdFilter = (propertyKeyId) -> contains( propertyKeyIds, propertyKeyId );

StoreScan<IndexPopulationFailedKernelException> storeScan =
storeView.visitNodes( labelIds, propertyKeyIdFilter, new NodePopulationVisitor(), null );

populations.forEach( population -> population.populator.configureSampling( storeView.isFullScan() ) );

storeScan = storeView.visitNodes( labelIds, propertyKeyIdFilter, new NodePopulationVisitor(), null );
storeScan.configure(populations);
return storeScan;

}

/**
Expand Down Expand Up @@ -337,7 +334,7 @@ private void populateFromQueueIfAvailable( long currentlyIndexedNodeId )
{
// no need to check for null as nobody else is emptying this queue
NodePropertyUpdate update = queue.poll();
storeView.acceptUpdate( updater, update, currentlyIndexedNodeId );
storeScan.acceptUpdate( updater, update, currentlyIndexedNodeId );
}
while ( !queue.isEmpty() );
}
Expand Down Expand Up @@ -435,9 +432,9 @@ public void close()
}
}

protected class IndexPopulation
public class IndexPopulation
{
final IndexPopulator populator;
public final IndexPopulator populator;
final IndexDescriptor descriptor;
final IndexConfiguration config;
final SchemaIndexProvider.Descriptor providerDescriptor;
Expand Down Expand Up @@ -506,7 +503,7 @@ private void flip() throws FlipFailedKernelException
{
flipper.flip( () -> {
populateFromQueueIfAvailable( Long.MAX_VALUE );
storeView.complete(populator, descriptor);
storeScan.complete(populator, descriptor);
IndexSample sample = populator.sampleResult();
storeView.replaceIndexCounts( descriptor, sample.uniqueValues(), sample.sampleSize(),
sample.indexSize() );
Expand Down
Expand Up @@ -19,6 +19,15 @@
*/
package org.neo4j.kernel.impl.api.index;

import java.io.IOException;
import java.util.List;

import org.neo4j.kernel.api.exceptions.EntityNotFoundException;
import org.neo4j.kernel.api.exceptions.PropertyNotFoundException;
import org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException;
import org.neo4j.kernel.api.index.IndexDescriptor;
import org.neo4j.kernel.api.index.IndexPopulator;
import org.neo4j.kernel.api.index.NodePropertyUpdate;
import org.neo4j.storageengine.api.schema.PopulationProgress;

public interface StoreScan<FAILURE extends Exception>
Expand All @@ -27,5 +36,13 @@ public interface StoreScan<FAILURE extends Exception>

void stop();

void complete( IndexPopulator indexPopulator, IndexDescriptor descriptor )
throws EntityNotFoundException, PropertyNotFoundException, IOException, IndexEntryConflictException;

void acceptUpdate( MultipleIndexPopulator.MultipleIndexUpdater updater, NodePropertyUpdate update,
long currentlyIndexedNodeId );

PopulationProgress getProgress();

void configure( List<MultipleIndexPopulator.IndexPopulation> populations );
}

0 comments on commit 1aa2ef8

Please sign in to comment.