Search in sources :

Example 1 with PropertyKeyIdNotFoundKernelException

use of org.neo4j.internal.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException in project neo4j by neo4j.

the class NodeEntity method getAllProperties.

public Map<String, Object> getAllProperties(NodeCursor nodes, PropertyCursor propertyCursor) {
    KernelTransaction transaction = internalTransaction.kernelTransaction();
    Map<String, Object> properties = new HashMap<>();
    try {
        TokenRead token = transaction.tokenRead();
        if (nodes.isClosed() || nodes.nodeReference() != getId()) {
            singleNode(transaction, nodes);
        }
        nodes.properties(propertyCursor);
        while (propertyCursor.next()) {
            properties.put(token.propertyKeyName(propertyCursor.propertyKey()), propertyCursor.propertyValue().asObjectCopy());
        }
    } catch (PropertyKeyIdNotFoundKernelException e) {
        throw new IllegalStateException("Property key retrieved through kernel API should exist.", e);
    }
    return properties;
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) HashMap(java.util.HashMap) TokenRead(org.neo4j.internal.kernel.api.TokenRead) PropertyKeyIdNotFoundKernelException(org.neo4j.internal.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException)

Example 2 with PropertyKeyIdNotFoundKernelException

use of org.neo4j.internal.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException in project neo4j by neo4j.

the class RelationshipEntity method getPropertyKeys.

@Override
public Iterable<String> getPropertyKeys() {
    KernelTransaction transaction = internalTransaction.kernelTransaction();
    List<String> keys = new ArrayList<>();
    try {
        RelationshipScanCursor relationships = transaction.ambientRelationshipCursor();
        PropertyCursor properties = transaction.ambientPropertyCursor();
        singleRelationship(transaction, relationships);
        TokenRead token = transaction.tokenRead();
        relationships.properties(properties);
        while (properties.next()) {
            keys.add(token.propertyKeyName(properties.propertyKey()));
        }
    } catch (PropertyKeyIdNotFoundKernelException e) {
        throw new IllegalStateException("Property key retrieved through kernel API should exist.", e);
    }
    return keys;
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) RelationshipScanCursor(org.neo4j.internal.kernel.api.RelationshipScanCursor) ArrayList(java.util.ArrayList) PropertyCursor(org.neo4j.internal.kernel.api.PropertyCursor) TokenRead(org.neo4j.internal.kernel.api.TokenRead) PropertyKeyIdNotFoundKernelException(org.neo4j.internal.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException)

Example 3 with PropertyKeyIdNotFoundKernelException

use of org.neo4j.internal.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException in project neo4j by neo4j.

the class RelationshipEntity method getAllProperties.

public Map<String, Object> getAllProperties(PropertyCursor propertyCursor) {
    KernelTransaction transaction = internalTransaction.kernelTransaction();
    Map<String, Object> properties = new HashMap<>();
    try {
        RelationshipScanCursor relationships = transaction.ambientRelationshipCursor();
        TokenRead token = transaction.tokenRead();
        singleRelationship(transaction, relationships);
        relationships.properties(propertyCursor);
        while (propertyCursor.next()) {
            properties.put(token.propertyKeyName(propertyCursor.propertyKey()), propertyCursor.propertyValue().asObjectCopy());
        }
    } catch (PropertyKeyIdNotFoundKernelException e) {
        throw new IllegalStateException("Property key retrieved through kernel API should exist.", e);
    }
    return properties;
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) RelationshipScanCursor(org.neo4j.internal.kernel.api.RelationshipScanCursor) HashMap(java.util.HashMap) TokenRead(org.neo4j.internal.kernel.api.TokenRead) PropertyKeyIdNotFoundKernelException(org.neo4j.internal.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException)

Example 4 with PropertyKeyIdNotFoundKernelException

use of org.neo4j.internal.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException 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)

Example 5 with PropertyKeyIdNotFoundKernelException

use of org.neo4j.internal.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException in project neo4j by neo4j.

the class TxStateTransactionDataSnapshot method snapshotRemovedRelationships.

private void snapshotRemovedRelationships(MemoryTracker memoryTracker, StoragePropertyCursor properties, TokenRead tokenRead) {
    state.addedAndRemovedRelationships().getRemoved().each(relId -> {
        Relationship relationship = relationship(relId);
        this.relationship.single(relId);
        if (this.relationship.next()) {
            this.relationship.properties(properties);
            while (properties.next()) {
                try {
                    removedRelationshipProperties.add(createRelationshipPropertyEntryView(memoryTracker, tokenRead, relationship, properties.propertyKey(), null, properties.propertyValue()));
                } catch (PropertyKeyIdNotFoundKernelException e) {
                    throw new IllegalStateException("Not existing node properties was modified for relationship " + relId, e);
                }
            }
        }
    });
}
Also used : Relationship(org.neo4j.graphdb.Relationship) PropertyKeyIdNotFoundKernelException(org.neo4j.internal.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException)

Aggregations

PropertyKeyIdNotFoundKernelException (org.neo4j.internal.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException)8 TokenRead (org.neo4j.internal.kernel.api.TokenRead)5 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)4 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Relationship (org.neo4j.graphdb.Relationship)2 PropertyCursor (org.neo4j.internal.kernel.api.PropertyCursor)2 RelationshipScanCursor (org.neo4j.internal.kernel.api.RelationshipScanCursor)2 StorageProperty (org.neo4j.storageengine.api.StorageProperty)2 NodeCursor (org.neo4j.internal.kernel.api.NodeCursor)1 StorageNodeCursor (org.neo4j.storageengine.api.StorageNodeCursor)1 StoragePropertyCursor (org.neo4j.storageengine.api.StoragePropertyCursor)1 LongDiffSets (org.neo4j.storageengine.api.txstate.LongDiffSets)1 NodeState (org.neo4j.storageengine.api.txstate.NodeState)1 RelationshipState (org.neo4j.storageengine.api.txstate.RelationshipState)1