Skip to content

Commit

Permalink
Rename Progression to BatchingLongProgression
Browse files Browse the repository at this point in the history
  • Loading branch information
davidegrohmann committed May 8, 2017
1 parent 42e78ed commit 0bd87e9
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 21 deletions.
Expand Up @@ -21,7 +21,7 @@


import org.neo4j.kernel.impl.store.NodeStore; import org.neo4j.kernel.impl.store.NodeStore;


public class AllNodeProgression implements Progression public class AllNodeProgression implements BatchingLongProgression
{ {
private final NodeStore nodeStore; private final NodeStore nodeStore;


Expand Down
Expand Up @@ -19,7 +19,7 @@
*/ */
package org.neo4j.kernel.impl.api.store; package org.neo4j.kernel.impl.api.store;


public interface Progression public interface BatchingLongProgression
{ {
boolean nextBatch( Batch batch ); boolean nextBatch( Batch batch );


Expand Down
Expand Up @@ -52,7 +52,7 @@ public class NodeCursor implements NodeItem, Cursor<NodeItem>, Disposable
private final LockService lockService; private final LockService lockService;
private final PageCursor pageCursor; private final PageCursor pageCursor;


private Progression progression; private BatchingLongProgression progression;
private boolean fetched; private boolean fetched;
private long[] labels; private long[] labels;
private Iterator<Long> added; private Iterator<Long> added;
Expand All @@ -67,7 +67,7 @@ public class NodeCursor implements NodeItem, Cursor<NodeItem>, Disposable
this.lockService = lockService; this.lockService = lockService;
} }


public Cursor<NodeItem> init( Progression progression, NodeTransactionStateView stateView ) public Cursor<NodeItem> init( BatchingLongProgression progression, NodeTransactionStateView stateView )
{ {
this.progression = progression; this.progression = progression;
this.added = progression.appendAdded() ? stateView.addedAndRemovedNodes().getAdded().iterator() : null; this.added = progression.appendAdded() ? stateView.addedAndRemovedNodes().getAdded().iterator() : null;
Expand Down
Expand Up @@ -21,7 +21,7 @@


import static org.neo4j.kernel.api.StatementConstants.NO_SUCH_NODE; import static org.neo4j.kernel.api.StatementConstants.NO_SUCH_NODE;


public class SingleNodeProgression implements Progression public class SingleNodeProgression implements BatchingLongProgression
{ {
private long nodeId; private long nodeId;


Expand Down
Expand Up @@ -152,7 +152,7 @@ public void acquire()
} }


@Override @Override
public Progression parallelNodeScanProgression() public BatchingLongProgression parallelNodeScanProgression()
{ {
throw unsupportedOperation(); throw unsupportedOperation();
} }
Expand All @@ -164,7 +164,7 @@ private UnsupportedOperationException unsupportedOperation()
} }


@Override @Override
public Cursor<NodeItem> acquireNodeCursor( Progression progression, NodeTransactionStateView stateView ) public Cursor<NodeItem> acquireNodeCursor( BatchingLongProgression progression, NodeTransactionStateView stateView )
{ {
neoStores.assertOpen(); neoStores.assertOpen();
return nodeCursor.get().init( progression, stateView ); return nodeCursor.get().init( progression, stateView );
Expand Down
Expand Up @@ -23,7 +23,7 @@
import org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException; import org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException;
import org.neo4j.kernel.api.schema.index.IndexDescriptor; import org.neo4j.kernel.api.schema.index.IndexDescriptor;
import org.neo4j.kernel.impl.api.store.NodeDegreeCounter; import org.neo4j.kernel.impl.api.store.NodeDegreeCounter;
import org.neo4j.kernel.impl.api.store.Progression; import org.neo4j.kernel.impl.api.store.BatchingLongProgression;
import org.neo4j.kernel.impl.locking.Lock; import org.neo4j.kernel.impl.locking.Lock;
import org.neo4j.storageengine.api.schema.IndexReader; import org.neo4j.storageengine.api.schema.IndexReader;
import org.neo4j.storageengine.api.schema.LabelScanReader; import org.neo4j.storageengine.api.schema.LabelScanReader;
Expand Down Expand Up @@ -67,7 +67,7 @@ public interface StorageStatement extends AutoCloseable
@Override @Override
void close(); void close();


Progression parallelNodeScanProgression(); BatchingLongProgression parallelNodeScanProgression();


/** /**
* Acquires {@link Cursor} capable of {@link Cursor#get() serving} {@link NodeItem} for selected nodes. * Acquires {@link Cursor} capable of {@link Cursor#get() serving} {@link NodeItem} for selected nodes.
Expand All @@ -78,7 +78,7 @@ public interface StorageStatement extends AutoCloseable
* @param stateView the transaction state view for nodes * @param stateView the transaction state view for nodes
* @return a {@link Cursor} over {@link NodeItem} for the given {@code nodeId}. * @return a {@link Cursor} over {@link NodeItem} for the given {@code nodeId}.
*/ */
Cursor<NodeItem> acquireNodeCursor( Progression progression, NodeTransactionStateView stateView ); Cursor<NodeItem> acquireNodeCursor( BatchingLongProgression progression, NodeTransactionStateView stateView );


/** /**
* Acquires {@link Cursor} capable of {@link Cursor#get() serving} {@link RelationshipItem} for selected * Acquires {@link Cursor} capable of {@link Cursor#get() serving} {@link RelationshipItem} for selected
Expand Down
Expand Up @@ -228,7 +228,7 @@ public void shouldCallTheConsumerOnClose()
{ {
MutableBoolean called = new MutableBoolean(); MutableBoolean called = new MutableBoolean();
NodeCursor cursor = new NodeCursor( nodeStore, c -> called.setTrue(), NO_LOCK_SERVICE ); NodeCursor cursor = new NodeCursor( nodeStore, c -> called.setTrue(), NO_LOCK_SERVICE );
cursor.init( mock( Progression.class ), mock( NodeTransactionStateView.class ) ); cursor.init( mock( BatchingLongProgression.class ), mock( NodeTransactionStateView.class ) );
assertFalse( called.booleanValue() ); assertFalse( called.booleanValue() );


cursor.close(); cursor.close();
Expand All @@ -239,7 +239,7 @@ public void shouldCallTheConsumerOnClose()
public void shouldCloseThePageCursorWhenDisposed() public void shouldCloseThePageCursorWhenDisposed()
{ {
NodeCursor cursor = new NodeCursor( nodeStore, c -> {}, NO_LOCK_SERVICE ); NodeCursor cursor = new NodeCursor( nodeStore, c -> {}, NO_LOCK_SERVICE );
cursor.init( mock( Progression.class ), mock( NodeTransactionStateView.class ) ); cursor.init( mock( BatchingLongProgression.class ), mock( NodeTransactionStateView.class ) );


cursor.close(); cursor.close();
cursor.dispose(); cursor.dispose();
Expand Down Expand Up @@ -533,9 +533,9 @@ Cursor<NodeItem> initialize( NodeCursor cursor, NodeStore nodeStore, PageCursor
return cursor.init( createProgression( ops, mode ), state == null ? EMPTY : state ); return cursor.init( createProgression( ops, mode ), state == null ? EMPTY : state );
} }


private Progression createProgression( Operation[] ops, Mode mode ) private BatchingLongProgression createProgression( Operation[] ops, Mode mode )
{ {
return new Progression() return new BatchingLongProgression()
{ {
private int i = 0; private int i = 0;


Expand Down
Expand Up @@ -40,7 +40,7 @@
import org.neo4j.kernel.api.txstate.TransactionState; import org.neo4j.kernel.api.txstate.TransactionState;
import org.neo4j.kernel.impl.api.KernelTransactionImplementation; import org.neo4j.kernel.impl.api.KernelTransactionImplementation;
import org.neo4j.kernel.impl.api.state.TxState; import org.neo4j.kernel.impl.api.state.TxState;
import org.neo4j.kernel.impl.api.store.Progression; import org.neo4j.kernel.impl.api.store.BatchingLongProgression;
import org.neo4j.kernel.impl.api.store.StoreStatement; import org.neo4j.kernel.impl.api.store.StoreStatement;
import org.neo4j.kernel.impl.core.NodeProxy; import org.neo4j.kernel.impl.core.NodeProxy;
import org.neo4j.kernel.impl.core.RelationshipProxy; import org.neo4j.kernel.impl.core.RelationshipProxy;
Expand Down Expand Up @@ -304,7 +304,7 @@ public void shouldListAddedLabels() throws Exception
// Given // Given
state.nodeDoAddLabel( 2, 1L ); state.nodeDoAddLabel( 2, 1L );
when( ops.labelGetName( 2 ) ).thenReturn( "theLabel" ); when( ops.labelGetName( 2 ) ).thenReturn( "theLabel" );
when( storeStatement.acquireNodeCursor( any( Progression.class ), any( NodeTransactionStateView.class ) ) ) when( storeStatement.acquireNodeCursor( any( BatchingLongProgression.class ), any( NodeTransactionStateView.class ) ) )
.thenReturn( asNodeCursor( 1 ) ); .thenReturn( asNodeCursor( 1 ) );


// When // When
Expand Down
Expand Up @@ -26,7 +26,6 @@
import org.neo4j.kernel.impl.store.NeoStores; import org.neo4j.kernel.impl.store.NeoStores;
import org.neo4j.kernel.impl.store.NodeStore; import org.neo4j.kernel.impl.store.NodeStore;
import org.neo4j.storageengine.api.schema.LabelScanReader; import org.neo4j.storageengine.api.schema.LabelScanReader;
import org.neo4j.storageengine.api.txstate.ReadableTransactionState;


public class EnterpriseStoreStatement extends StoreStatement public class EnterpriseStoreStatement extends StoreStatement
{ {
Expand All @@ -40,7 +39,7 @@ public EnterpriseStoreStatement( NeoStores neoStores, Supplier<IndexReaderFactor
} }


@Override @Override
public Progression parallelNodeScanProgression() public BatchingLongProgression parallelNodeScanProgression()
{ {
return new ParallelAllNodeProgression( nodeStore ); return new ParallelAllNodeProgression( nodeStore );
} }
Expand Down
Expand Up @@ -24,7 +24,7 @@


import org.neo4j.kernel.impl.store.NodeStore; import org.neo4j.kernel.impl.store.NodeStore;


class ParallelAllNodeProgression implements Progression class ParallelAllNodeProgression implements BatchingLongProgression
{ {
private final NodeStore nodeStore; private final NodeStore nodeStore;
private final AtomicLong nextPageId; private final AtomicLong nextPageId;
Expand Down
Expand Up @@ -38,7 +38,6 @@
import org.neo4j.kernel.internal.GraphDatabaseAPI; import org.neo4j.kernel.internal.GraphDatabaseAPI;
import org.neo4j.storageengine.api.NodeItem; import org.neo4j.storageengine.api.NodeItem;
import org.neo4j.storageengine.api.txstate.NodeTransactionStateView; import org.neo4j.storageengine.api.txstate.NodeTransactionStateView;
import org.neo4j.storageengine.api.txstate.ReadableTransactionState;
import org.neo4j.test.rule.EnterpriseDatabaseRule; import org.neo4j.test.rule.EnterpriseDatabaseRule;
import org.neo4j.test.rule.RandomRule; import org.neo4j.test.rule.RandomRule;


Expand Down Expand Up @@ -115,7 +114,7 @@ private Set<Long> parallelExecution( NeoStores neoStores, ExecutorService execut
localStatements[i] = new EnterpriseStoreStatement( neoStores, null, null, NO_LOCK_SERVICE ); localStatements[i] = new EnterpriseStoreStatement( neoStores, null, null, NO_LOCK_SERVICE );
} }
// use any of the local statements to build the shared progression // use any of the local statements to build the shared progression
Progression progression = localStatements[0].parallelNodeScanProgression(); BatchingLongProgression progression = localStatements[0].parallelNodeScanProgression();


@SuppressWarnings( "unchecked" ) @SuppressWarnings( "unchecked" )
Future<Set<Long>>[] futures = new Future[threads]; Future<Set<Long>>[] futures = new Future[threads];
Expand Down

0 comments on commit 0bd87e9

Please sign in to comment.