Search in sources :

Example 6 with NodeState

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;
                }
            }
        }
    }
}
Also used : NodeState(org.neo4j.storageengine.api.txstate.NodeState) IntIterator(org.eclipse.collections.api.iterator.IntIterator)

Example 7 with NodeState

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);
}
Also used : NodeState(org.neo4j.storageengine.api.txstate.NodeState) RelationshipItem(org.neo4j.storageengine.api.RelationshipItem)

Example 8 with NodeState

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();
}
Also used : MutableIntSet(org.eclipse.collections.api.set.primitive.MutableIntSet) NodeState(org.neo4j.storageengine.api.txstate.NodeState)

Example 9 with NodeState

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);
}
Also used : NodeState(org.neo4j.storageengine.api.txstate.NodeState)

Example 10 with 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);
    }
}
Also used : NodeState(org.neo4j.storageengine.api.txstate.NodeState) StorageProperty(org.neo4j.storageengine.api.StorageProperty) LongDiffSets(org.neo4j.storageengine.api.txstate.LongDiffSets) PropertyKeyIdNotFoundKernelException(org.neo4j.internal.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException)

Aggregations

NodeState (org.neo4j.storageengine.api.txstate.NodeState)10 RelationshipItem (org.neo4j.storageengine.api.RelationshipItem)3 StorageProperty (org.neo4j.storageengine.api.StorageProperty)2 LongDiffSets (org.neo4j.storageengine.api.txstate.LongDiffSets)2 RelationshipState (org.neo4j.storageengine.api.txstate.RelationshipState)2 ArrayList (java.util.ArrayList)1 IntIterator (org.eclipse.collections.api.iterator.IntIterator)1 LongIterator (org.eclipse.collections.api.iterator.LongIterator)1 MutableIntSet (org.eclipse.collections.api.set.primitive.MutableIntSet)1 Relationship (org.neo4j.graphdb.Relationship)1 PropertyKeyIdNotFoundKernelException (org.neo4j.internal.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException)1 FlatRelationshipModifications (org.neo4j.internal.recordstorage.FlatRelationshipModifications)1 RelationshipData (org.neo4j.internal.recordstorage.FlatRelationshipModifications.RelationshipData)1 ConstraintDescriptor (org.neo4j.internal.schema.ConstraintDescriptor)1 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)1 IndexBackedConstraintDescriptor (org.neo4j.internal.schema.constraints.IndexBackedConstraintDescriptor)1 LabelNotFoundKernelException (org.neo4j.kernel.api.exceptions.LabelNotFoundKernelException)1 PropertyKeyIdNotFoundKernelException (org.neo4j.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException)1 DefinedProperty (org.neo4j.kernel.api.properties.DefinedProperty)1 Lock (org.neo4j.kernel.impl.locking.Lock)1