use of org.neo4j.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException in project neo4j by neo4j.
the class TxStateTransactionDataSnapshot method takeSnapshot.
private void takeSnapshot() {
try {
for (long nodeId : state.addedAndRemovedNodes().getRemoved()) {
try (Cursor<NodeItem> node = storeStatement.acquireSingleNodeCursor(nodeId)) {
if (node.next()) {
Lock lock = node.get().lock();
try (Cursor<PropertyItem> properties = storeStatement.acquirePropertyCursor(node.get().nextPropertyId(), lock)) {
while (properties.next()) {
removedNodeProperties.add(new NodePropertyEntryView(nodeId, store.propertyKeyGetName(properties.get().propertyKeyId()), null, properties.get().value()));
}
}
node.get().labels().visitKeys(labelId -> {
removedLabels.add(new LabelEntryView(nodeId, store.labelGetName(labelId)));
return false;
});
}
}
}
for (long relId : state.addedAndRemovedRelationships().getRemoved()) {
Relationship relationshipProxy = relationship(relId);
try (Cursor<RelationshipItem> relationship = storeStatement.acquireSingleRelationshipCursor(relId)) {
if (relationship.next()) {
Lock lock = relationship.get().lock();
try (Cursor<PropertyItem> properties = storeStatement.acquirePropertyCursor(relationship.get().nextPropertyId(), lock)) {
while (properties.next()) {
removedRelationshipProperties.add(new RelationshipPropertyEntryView(relationshipProxy, store.propertyKeyGetName(properties.get().propertyKeyId()), null, properties.get().value()));
}
}
}
}
}
for (NodeState nodeState : state.modifiedNodes()) {
Iterator<StorageProperty> added = nodeState.addedAndChangedProperties();
while (added.hasNext()) {
DefinedProperty property = (DefinedProperty) added.next();
assignedNodeProperties.add(new NodePropertyEntryView(nodeState.getId(), store.propertyKeyGetName(property.propertyKeyId()), property.value(), committedValue(nodeState, property.propertyKeyId())));
}
Iterator<Integer> removed = nodeState.removedProperties();
while (removed.hasNext()) {
Integer property = removed.next();
removedNodeProperties.add(new NodePropertyEntryView(nodeState.getId(), store.propertyKeyGetName(property), null, committedValue(nodeState, property)));
}
ReadableDiffSets<Integer> labels = nodeState.labelDiffSets();
for (Integer label : labels.getAdded()) {
assignedLabels.add(new LabelEntryView(nodeState.getId(), store.labelGetName(label)));
}
for (Integer label : labels.getRemoved()) {
removedLabels.add(new LabelEntryView(nodeState.getId(), store.labelGetName(label)));
}
}
for (RelationshipState relState : state.modifiedRelationships()) {
Relationship relationship = relationship(relState.getId());
Iterator<StorageProperty> added = relState.addedAndChangedProperties();
while (added.hasNext()) {
DefinedProperty property = (DefinedProperty) added.next();
assignedRelationshipProperties.add(new RelationshipPropertyEntryView(relationship, store.propertyKeyGetName(property.propertyKeyId()), property.value(), committedValue(relState, property.propertyKeyId())));
}
Iterator<Integer> removed = relState.removedProperties();
while (removed.hasNext()) {
Integer property = removed.next();
removedRelationshipProperties.add(new RelationshipPropertyEntryView(relationship, store.propertyKeyGetName(property), null, committedValue(relState, property)));
}
}
} catch (PropertyKeyIdNotFoundKernelException | LabelNotFoundKernelException e) {
throw new IllegalStateException("An entity that does not exist was modified.", e);
}
}
use of org.neo4j.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException in project neo4j by neo4j.
the class InternalAutoIndexOperations method propertyAdded.
@Override
public void propertyAdded(DataWriteOperations ops, long entityId, Property property) throws AutoIndexingKernelException {
if (enabled) {
try {
String name = propertyKeyLookup.getTokenById(property.propertyKeyId()).name();
if (propertyKeysToInclude.get().contains(name)) {
ensureIndexExists(ops);
type.add(ops, entityId, name, property.value());
}
} catch (LegacyIndexNotFoundKernelException | EntityNotFoundException | PropertyNotFoundException e) {
throw new AutoIndexingKernelException(e);
} catch (TokenNotFoundException e) {
// KernelException now
throw new AutoIndexingKernelException(new PropertyKeyIdNotFoundKernelException(property.propertyKeyId(), e));
}
}
}
use of org.neo4j.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException in project neo4j by neo4j.
the class InternalAutoIndexOperations method propertyRemoved.
@Override
public void propertyRemoved(DataWriteOperations ops, long entityId, int propertyKey) throws AutoIndexingKernelException {
if (enabled) {
try {
String name = propertyKeyLookup.getTokenById(propertyKey).name();
if (propertyKeysToInclude.get().contains(name)) {
ensureIndexExists(ops);
type.remove(ops, entityId, name);
}
} catch (LegacyIndexNotFoundKernelException | EntityNotFoundException e) {
throw new AutoIndexingKernelException(e);
} catch (TokenNotFoundException e) {
// KernelException now
throw new AutoIndexingKernelException(new PropertyKeyIdNotFoundKernelException(propertyKey, e));
}
}
}
use of org.neo4j.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException in project neo4j by neo4j.
the class GraphPropertiesProxy method getPropertyKeys.
@Override
public Iterable<String> getPropertyKeys() {
try (Statement statement = actions.statement()) {
List<String> keys = new ArrayList<>();
PrimitiveIntIterator properties = statement.readOperations().graphGetPropertyKeys();
while (properties.hasNext()) {
keys.add(statement.readOperations().propertyKeyGetName(properties.next()));
}
return keys;
} catch (PropertyKeyIdNotFoundKernelException e) {
throw new IllegalStateException("Property key retrieved through kernel API should exist.", e);
}
}
use of org.neo4j.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException in project neo4j by neo4j.
the class NodeProxy method getAllProperties.
@Override
public Map<String, Object> getAllProperties() {
try (Statement statement = actions.statement()) {
try (Cursor<NodeItem> node = statement.readOperations().nodeCursorById(nodeId)) {
try (Cursor<PropertyItem> propertyCursor = statement.readOperations().nodeGetProperties(node.get())) {
Map<String, Object> properties = new HashMap<>();
// Get all properties
while (propertyCursor.next()) {
String name = statement.readOperations().propertyKeyGetName(propertyCursor.get().propertyKeyId());
properties.put(name, propertyCursor.get().value());
}
return properties;
}
} catch (EntityNotFoundException e) {
throw new NotFoundException("Node not found", e);
}
} catch (PropertyKeyIdNotFoundKernelException e) {
throw new IllegalStateException("Property key retrieved through kernel API should exist.", e);
}
}
Aggregations