use of org.neo4j.storageengine.api.txstate.NodeState in project neo4j by neo4j.
the class DefaultNodeCursor method fillDegrees.
private void fillDegrees(RelationshipSelection selection, Degrees.Mutator degrees) {
boolean hasChanges = hasChanges();
NodeState nodeTxState = hasChanges ? read.txState().getNodeState(nodeReference()) : null;
if (currentAddedInTx == NO_ID) {
if (allowsTraverseAll()) {
storeCursor.degrees(selection, degrees, true);
} else {
storeCursor.degrees(new SecureRelationshipSelection(selection), degrees, false);
}
}
if (nodeTxState != null) {
// Then add the remaining types that's only present in the tx-state
IntIterator txTypes = nodeTxState.getAddedAndRemovedRelationshipTypes().intIterator();
while (txTypes.hasNext()) {
int type = txTypes.next();
if (selection.test(type)) {
int outgoing = selection.test(RelationshipDirection.OUTGOING) ? nodeTxState.augmentDegree(RelationshipDirection.OUTGOING, 0, type) : 0;
int incoming = selection.test(RelationshipDirection.INCOMING) ? nodeTxState.augmentDegree(RelationshipDirection.INCOMING, 0, type) : 0;
int loop = selection.test(RelationshipDirection.LOOP) ? nodeTxState.augmentDegree(RelationshipDirection.LOOP, 0, type) : 0;
if (!degrees.add(type, outgoing, incoming, loop)) {
return;
}
}
}
}
}
use of org.neo4j.storageengine.api.txstate.NodeState in project neo4j by neo4j.
the class StateHandlingStatementOperations method nodeGetRelationships.
@Override
public Cursor<RelationshipItem> nodeGetRelationships(KernelStatement statement, NodeItem node, Direction direction, int[] relTypes) {
Cursor<RelationshipItem> cursor;
if (statement.hasTxStateWithChanges() && statement.txState().nodeIsAddedInThisTx(node.id())) {
cursor = empty();
} else {
cursor = storeLayer.nodeGetRelationships(statement.getStoreStatement(), node, direction, any(relTypes));
}
if (!statement.hasTxStateWithChanges()) {
return cursor;
}
NodeState nodeState = statement.txState().getNodeState(node.id());
return statement.txState().augmentNodeRelationshipCursor(cursor, nodeState, direction, relTypes);
}
use of org.neo4j.storageengine.api.txstate.NodeState in project neo4j by neo4j.
the class DefaultNodeCursor method relationshipTypes.
@Override
public int[] relationshipTypes() {
boolean hasChanges = hasChanges();
NodeState nodeTxState = hasChanges ? read.txState().getNodeState(nodeReference()) : null;
int[] storedTypes = currentAddedInTx == NO_ID ? storeCursor.relationshipTypes() : null;
MutableIntSet types = storedTypes != null ? IntSets.mutable.of(storedTypes) : IntSets.mutable.empty();
if (nodeTxState != null) {
types.addAll(nodeTxState.getAddedRelationshipTypes());
}
return types.toArray();
}
use of org.neo4j.storageengine.api.txstate.NodeState in project neo4j by neo4j.
the class DefaultRelationshipTraversalCursor method collectAddedTxStateSnapshot.
@Override
protected void collectAddedTxStateSnapshot() {
NodeState nodeState = read.txState().getNodeState(originNodeReference);
addedRelationships = selection.addedRelationship(nodeState);
}
use of org.neo4j.storageengine.api.txstate.NodeState in project neo4j by neo4j.
the class TxStateTransactionDataSnapshot method snapshotModifiedNodes.
private void snapshotModifiedNodes(MemoryTracker memoryTracker, StorageNodeCursor node, StoragePropertyCursor properties, TokenRead tokenRead) throws PropertyKeyIdNotFoundKernelException {
for (NodeState nodeState : state.modifiedNodes()) {
Iterator<StorageProperty> added = nodeState.addedAndChangedProperties();
long nodeId = nodeState.getId();
while (added.hasNext()) {
StorageProperty property = added.next();
var entryView = createNodePropertyEntryView(memoryTracker, tokenRead, nodeId, property.propertyKeyId(), property.value(), committedValue(nodeState, property.propertyKeyId(), node, properties));
assignedNodeProperties.add(entryView);
}
nodeState.removedProperties().each(id -> {
try {
removedNodeProperties.add(createNodePropertyEntryView(memoryTracker, tokenRead, nodeId, id, null, committedValue(nodeState, id, node, properties)));
} catch (PropertyKeyIdNotFoundKernelException e) {
throw new IllegalStateException("Not existing node properties was modified for node " + nodeId, e);
}
});
final LongDiffSets labels = nodeState.labelDiffSets();
addLabelEntriesTo(nodeId, labels.getAdded(), assignedLabels);
addLabelEntriesTo(nodeId, labels.getRemoved(), removedLabels);
}
}
Aggregations