Search in sources :

Example 6 with PropertyKeyIdNotFoundKernelException

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

the class TxStateTransactionDataSnapshot method takeSnapshot.

private void takeSnapshot(MemoryTracker memoryTracker) {
    var cursorContext = transaction.cursorContext();
    try (StorageNodeCursor node = store.allocateNodeCursor(cursorContext);
        StoragePropertyCursor properties = store.allocatePropertyCursor(cursorContext, memoryTracker)) {
        TokenRead tokenRead = transaction.tokenRead();
        snapshotRemovedNodes(memoryTracker, node, properties, tokenRead);
        snapshotRemovedRelationships(memoryTracker, properties, tokenRead);
        snapshotModifiedNodes(memoryTracker, node, properties, tokenRead);
        snapshotModifiedRelationships(memoryTracker, properties, tokenRead);
    } catch (PropertyKeyIdNotFoundKernelException e) {
        throw new IllegalStateException("An entity that does not exist was modified.", e);
    }
}
Also used : StoragePropertyCursor(org.neo4j.storageengine.api.StoragePropertyCursor) StorageNodeCursor(org.neo4j.storageengine.api.StorageNodeCursor) TokenRead(org.neo4j.internal.kernel.api.TokenRead) PropertyKeyIdNotFoundKernelException(org.neo4j.internal.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException)

Example 7 with PropertyKeyIdNotFoundKernelException

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

the class TxStateTransactionDataSnapshot method snapshotModifiedRelationships.

private void snapshotModifiedRelationships(MemoryTracker memoryTracker, StoragePropertyCursor properties, TokenRead tokenRead) throws PropertyKeyIdNotFoundKernelException {
    for (RelationshipState relState : state.modifiedRelationships()) {
        Relationship relationship = relationship(relState.getId());
        Iterator<StorageProperty> added = relState.addedAndChangedProperties();
        while (added.hasNext()) {
            StorageProperty property = added.next();
            assignedRelationshipProperties.add(createRelationshipPropertyEntryView(memoryTracker, tokenRead, relationship, property.propertyKeyId(), property.value(), committedValue(relState, property.propertyKeyId(), this.relationship, properties)));
        }
        relState.removedProperties().each(id -> {
            try {
                var entryView = createRelationshipPropertyEntryView(memoryTracker, tokenRead, relationship, id, null, committedValue(relState, id, this.relationship, properties));
                removedRelationshipProperties.add(entryView);
            } catch (PropertyKeyIdNotFoundKernelException e) {
                throw new IllegalStateException("Not existing properties was modified for relationship " + relState.getId(), e);
            }
        });
    }
}
Also used : Relationship(org.neo4j.graphdb.Relationship) RelationshipState(org.neo4j.storageengine.api.txstate.RelationshipState) StorageProperty(org.neo4j.storageengine.api.StorageProperty) PropertyKeyIdNotFoundKernelException(org.neo4j.internal.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException)

Example 8 with PropertyKeyIdNotFoundKernelException

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

the class NodeEntity method getPropertyKeys.

@Override
public Iterable<String> getPropertyKeys() {
    KernelTransaction transaction = internalTransaction.kernelTransaction();
    List<String> keys = new ArrayList<>();
    try {
        NodeCursor nodes = transaction.ambientNodeCursor();
        PropertyCursor properties = transaction.ambientPropertyCursor();
        singleNode(transaction, nodes);
        TokenRead token = transaction.tokenRead();
        nodes.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) ArrayList(java.util.ArrayList) NodeCursor(org.neo4j.internal.kernel.api.NodeCursor) PropertyCursor(org.neo4j.internal.kernel.api.PropertyCursor) TokenRead(org.neo4j.internal.kernel.api.TokenRead) 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