use of org.neo4j.storageengine.api.RelationshipItem in project neo4j by neo4j.
the class TxIteratorRelationshipCursor method next.
@Override
public boolean next() {
if (added == null) {
while (cursor.next()) {
RelationshipItem relationshipItem = cursor.get();
long id = relationshipItem.id();
if (state.relationshipIsDeletedInThisTx(id)) {
continue;
}
visit(id, relationshipItem.type(), relationshipItem.startNode(), relationshipItem.endNode());
relationshipState = state.getRelationshipState(relationshipItem.id());
return true;
}
added = addedRelationshipIterator;
relationshipIsAddedInThisTx = true;
}
if (added.hasNext()) {
relationshipState = state.getRelationshipState(added.next());
relationshipState.accept(this);
return true;
} else {
visit(-1, -1, -1, -1);
relationshipState = null;
return false;
}
}
use of org.neo4j.storageengine.api.RelationshipItem in project neo4j by neo4j.
the class TxSingleRelationshipCursor method next.
@Override
public boolean next() {
if (state.relationshipIsDeletedInThisTx(nextId)) {
visit(StatementConstants.NO_SUCH_RELATIONSHIP, StatementConstants.NO_SUCH_RELATIONSHIP_TYPE, StatementConstants.NO_SUCH_NODE, StatementConstants.NO_SUCH_NODE);
nextId = StatementConstants.NO_SUCH_RELATIONSHIP;
return false;
}
boolean exists = cursor.next();
this.relationshipIsAddedInThisTx = state.relationshipIsAddedInThisTx(nextId);
if (exists || relationshipIsAddedInThisTx) {
if (relationshipIsAddedInThisTx) {
state.relationshipVisit(nextId, this);
} else {
RelationshipItem relationshipItem = cursor.get();
visit(nextId, relationshipItem.type(), relationshipItem.startNode(), relationshipItem.endNode());
}
relationshipState = state.getRelationshipState(nextId);
return true;
} else {
visit(StatementConstants.NO_SUCH_RELATIONSHIP, StatementConstants.NO_SUCH_RELATIONSHIP_TYPE, StatementConstants.NO_SUCH_NODE, StatementConstants.NO_SUCH_NODE);
relationshipState = null;
nextId = StatementConstants.NO_SUCH_RELATIONSHIP;
return false;
}
}
use of org.neo4j.storageengine.api.RelationshipItem in project neo4j by neo4j.
the class StateHandlingStatementOperations method relationshipDelete.
@Override
public void relationshipDelete(final KernelStatement state, long relationshipId) throws EntityNotFoundException, InvalidTransactionTypeKernelException, AutoIndexingKernelException {
try (Cursor<RelationshipItem> cursor = relationshipCursorById(state, relationshipId)) {
RelationshipItem relationship = cursor.get();
// NOTE: We implicitly delegate to neoStoreTransaction via txState.legacyState here. This is because that
// call returns modified properties, which node manager uses to update legacy tx state. This will be cleaned up
// once we've removed legacy tx state.
autoIndexing.relationships().entityRemoved(state.dataWriteOperations(), relationshipId);
final TransactionState txState = state.txState();
if (txState.relationshipIsAddedInThisTx(relationship.id())) {
txState.relationshipDoDeleteAddedInThisTx(relationship.id());
} else {
txState.relationshipDoDelete(relationship.id(), relationship.type(), relationship.startNode(), relationship.endNode());
}
}
}
use of org.neo4j.storageengine.api.RelationshipItem in project neo4j by neo4j.
the class StateHandlingStatementOperations method relationshipRemoveProperty.
@Override
public Property relationshipRemoveProperty(KernelStatement state, long relationshipId, int propertyKeyId) throws EntityNotFoundException, InvalidTransactionTypeKernelException, AutoIndexingKernelException {
DataWriteOperations ops = state.dataWriteOperations();
try (Cursor<RelationshipItem> cursor = relationshipCursorById(state, relationshipId)) {
RelationshipItem relationship = cursor.get();
Property existingProperty;
try (Cursor<PropertyItem> properties = relationshipGetPropertyCursor(state, relationship, propertyKeyId)) {
if (!properties.next()) {
existingProperty = Property.noProperty(propertyKeyId, EntityType.RELATIONSHIP, relationship.id());
} else {
existingProperty = Property.property(properties.get().propertyKeyId(), properties.get().value());
autoIndexing.relationships().propertyRemoved(ops, relationshipId, propertyKeyId);
state.txState().relationshipDoRemoveProperty(relationship.id(), (DefinedProperty) existingProperty);
}
}
return existingProperty;
}
}
use of org.neo4j.storageengine.api.RelationshipItem in project neo4j by neo4j.
the class StateHandlingStatementOperations method relationshipSetProperty.
@Override
public Property relationshipSetProperty(KernelStatement state, long relationshipId, DefinedProperty property) throws EntityNotFoundException, InvalidTransactionTypeKernelException, AutoIndexingKernelException {
DataWriteOperations ops = state.dataWriteOperations();
try (Cursor<RelationshipItem> cursor = relationshipCursorById(state, relationshipId)) {
RelationshipItem relationship = cursor.get();
Property existingProperty;
try (Cursor<PropertyItem> properties = relationshipGetPropertyCursor(state, relationship, property.propertyKeyId())) {
if (!properties.next()) {
autoIndexing.relationships().propertyAdded(ops, relationshipId, property);
existingProperty = Property.noProperty(property.propertyKeyId(), EntityType.RELATIONSHIP, relationship.id());
} else {
existingProperty = Property.property(properties.get().propertyKeyId(), properties.get().value());
autoIndexing.relationships().propertyChanged(ops, relationshipId, existingProperty, property);
}
}
state.txState().relationshipDoReplaceProperty(relationship.id(), existingProperty, property);
return existingProperty;
}
}
Aggregations