Skip to content

Commit

Permalink
Flat all property cursors
Browse files Browse the repository at this point in the history
By having one cursor handling both txState and reading records from disk
  • Loading branch information
davidegrohmann committed May 8, 2017
1 parent 8cf9e50 commit 0ebb2ee
Show file tree
Hide file tree
Showing 24 changed files with 192 additions and 478 deletions.
Expand Up @@ -102,8 +102,10 @@
import org.neo4j.storageengine.api.Token; import org.neo4j.storageengine.api.Token;
import org.neo4j.storageengine.api.schema.IndexReader; import org.neo4j.storageengine.api.schema.IndexReader;
import org.neo4j.storageengine.api.schema.PopulationProgress; import org.neo4j.storageengine.api.schema.PopulationProgress;
import org.neo4j.storageengine.api.txstate.NodeState;
import org.neo4j.storageengine.api.txstate.ReadableDiffSets; import org.neo4j.storageengine.api.txstate.ReadableDiffSets;
import org.neo4j.storageengine.api.txstate.ReadableTransactionState; import org.neo4j.storageengine.api.txstate.ReadableTransactionState;
import org.neo4j.storageengine.api.txstate.RelationshipState;


import static java.lang.String.format; import static java.lang.String.format;
import static org.neo4j.collection.primitive.PrimitiveIntCollections.filter; import static org.neo4j.collection.primitive.PrimitiveIntCollections.filter;
Expand All @@ -117,7 +119,6 @@
import static org.neo4j.kernel.impl.api.state.IndexTxStateUpdater.LabelChangeType.ADDED_LABEL; import static org.neo4j.kernel.impl.api.state.IndexTxStateUpdater.LabelChangeType.ADDED_LABEL;
import static org.neo4j.kernel.impl.api.state.IndexTxStateUpdater.LabelChangeType.REMOVED_LABEL; import static org.neo4j.kernel.impl.api.state.IndexTxStateUpdater.LabelChangeType.REMOVED_LABEL;
import static org.neo4j.kernel.impl.util.Cursors.count; import static org.neo4j.kernel.impl.util.Cursors.count;
import static org.neo4j.kernel.impl.util.Cursors.empty;
import static org.neo4j.register.Registers.newDoubleLongRegister; import static org.neo4j.register.Registers.newDoubleLongRegister;
import static org.neo4j.storageengine.api.NodeItem.transientNode; import static org.neo4j.storageengine.api.NodeItem.transientNode;
import static org.neo4j.storageengine.api.txstate.TxStateVisitor.EMPTY; import static org.neo4j.storageengine.api.txstate.TxStateVisitor.EMPTY;
Expand Down Expand Up @@ -218,19 +219,8 @@ public Cursor<RelationshipItem> nodeGetRelationships( KernelStatement statement,
@Override @Override
public Cursor<PropertyItem> nodeGetProperties( KernelStatement statement, NodeItem node ) public Cursor<PropertyItem> nodeGetProperties( KernelStatement statement, NodeItem node )
{ {
Cursor<PropertyItem> cursor; NodeState state = statement.hasTxStateWithChanges() ? statement.txState().getNodeState( node.id() ) : null;
if ( statement.hasTxStateWithChanges() && statement.txState().nodeIsAddedInThisTx( node.id() ) ) return storeLayer.nodeGetProperties( statement.getStoreStatement(), node, state );
{
cursor = empty();
}
else
{
cursor = storeLayer.nodeGetProperties( statement.getStoreStatement(), node );
}

return statement.hasTxStateWithChanges()
? statement.txState().augmentPropertyCursor( cursor, statement.txState().getNodeState( node.id() ) )
: cursor;
} }


@Override @Override
Expand Down Expand Up @@ -277,40 +267,17 @@ public boolean nodeHasProperty( KernelStatement statement, NodeItem node, int pr


private Cursor<PropertyItem> nodeGetPropertyCursor( KernelStatement statement, NodeItem node, int propertyKeyId ) private Cursor<PropertyItem> nodeGetPropertyCursor( KernelStatement statement, NodeItem node, int propertyKeyId )
{ {

NodeState state = statement.hasTxStateWithChanges() ? statement.txState().getNodeState( node.id() ) : null;
Cursor<PropertyItem> cursor; return storeLayer.nodeGetProperty( statement.getStoreStatement(), node, propertyKeyId, state );
if ( statement.hasTxStateWithChanges() && statement.txState().nodeIsAddedInThisTx( node.id() ) )
{
cursor = empty();
}
else
{
cursor = storeLayer.nodeGetProperty( statement.getStoreStatement(), node, propertyKeyId );
}

return statement.hasTxStateWithChanges()
? statement.txState().augmentSinglePropertyCursor(
cursor, statement.txState().getNodeState( node.id() ), propertyKeyId )
: cursor;
} }


@Override @Override
public Cursor<PropertyItem> relationshipGetProperties( KernelStatement statement, RelationshipItem relationship ) public Cursor<PropertyItem> relationshipGetProperties( KernelStatement statement, RelationshipItem relationship )
{ {
Cursor<PropertyItem> cursor; RelationshipState state = statement.hasTxStateWithChanges()
if ( statement.hasTxStateWithChanges() && statement.txState().relationshipIsAddedInThisTx( relationship.id() ) ) ? statement.txState().getRelationshipState( relationship.id() )
{ : null;
cursor = empty(); return storeLayer.relationshipGetProperties( statement.getStoreStatement(), relationship, state );
}
else
{
cursor = storeLayer.relationshipGetProperties( statement.getStoreStatement(), relationship );
}

return statement.hasTxStateWithChanges()
? statement.txState()
.augmentPropertyCursor( cursor, statement.txState().getRelationshipState( relationship.id() ) )
: cursor;
} }


@Override @Override
Expand Down Expand Up @@ -360,20 +327,10 @@ public boolean relationshipHasProperty( KernelStatement statement, RelationshipI
private Cursor<PropertyItem> relationshipGetPropertyCursor( KernelStatement statement, private Cursor<PropertyItem> relationshipGetPropertyCursor( KernelStatement statement,
RelationshipItem relationship, int propertyKeyId ) RelationshipItem relationship, int propertyKeyId )
{ {
Cursor<PropertyItem> cursor; RelationshipState state = statement.hasTxStateWithChanges()
if ( statement.hasTxStateWithChanges() && statement.txState().relationshipIsAddedInThisTx( relationship.id() ) ) ? statement.txState().getRelationshipState( relationship.id() )
{ : null;
cursor = empty(); return storeLayer.relationshipGetProperty( statement.getStoreStatement(), relationship, propertyKeyId, state );
}
else
{
cursor = storeLayer.relationshipGetProperty( statement.getStoreStatement(), relationship, propertyKeyId );
}

return statement.hasTxStateWithChanges()
? statement.txState().augmentSinglePropertyCursor( cursor, statement.txState()
.getRelationshipState( relationship.id() ), propertyKeyId )
: cursor;
} }


// </Cursors> // </Cursors>
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 0ebb2ee

Please sign in to comment.