Skip to content

Commit

Permalink
Code cleanup in TransactionCountingStateVisitor
Browse files Browse the repository at this point in the history
  • Loading branch information
davidegrohmann committed May 8, 2017
1 parent b09d1c8 commit 14c39a5
Showing 1 changed file with 3 additions and 9 deletions.
Expand Up @@ -24,7 +24,6 @@
import org.neo4j.collection.primitive.PrimitiveIntCollection;
import org.neo4j.collection.primitive.PrimitiveIntSet;
import org.neo4j.collection.primitive.PrimitiveIntVisitor;
import org.neo4j.cursor.Cursor;
import org.neo4j.kernel.api.exceptions.EntityNotFoundException;
import org.neo4j.kernel.api.exceptions.schema.ConstraintValidationException;
import org.neo4j.kernel.impl.api.CountsRecordState;
Expand Down Expand Up @@ -67,7 +66,7 @@ public void visitCreatedNode( long id )
public void visitDeletedNode( long id )
{
counts.incrementNodeCount( ANY_LABEL, -1 );
statement.acquireSingleNodeCursor( id, null ).forAll( this::decrementCountForLabelsAndRelationships );
storeLayer.nodeCursor( statement, id, null ).forAll( this::decrementCountForLabelsAndRelationships );
super.visitDeletedNode( id );
}

Expand Down Expand Up @@ -124,7 +123,7 @@ public void visitNodeLabelChanges( long id, final Set<Integer> added, final Set<
}
// get the relationship counts from *before* this transaction,
// the relationship changes will compensate for what happens during the transaction
statement.acquireSingleNodeCursor( id, null )
storeLayer.nodeCursor( statement, id, null )
.forAll( node -> storeLayer.degrees( statement, node, ( type, out, in ) ->
{
added.forEach( label -> updateRelationshipsCountsFromDegrees( type, label, out, in ) );
Expand Down Expand Up @@ -160,11 +159,6 @@ private void updateRelationshipCount( long startNode, int type, long endNode, in

private void visitLabels( long nodeId, PrimitiveIntVisitor<RuntimeException> visitor )
{
nodeCursor( statement, nodeId ).forAll( node -> node.labels().visitKeys( visitor ) );
}

private Cursor<NodeItem> nodeCursor( StorageStatement statement, long nodeId )
{
return statement.acquireSingleNodeCursor( nodeId, txState );
storeLayer.nodeCursor( statement, nodeId, txState ).forAll( node -> node.labels().visitKeys( visitor ) );
}
}

0 comments on commit 14c39a5

Please sign in to comment.