use of org.neo4j.kernel.impl.core.RelationshipEntity in project neo4j by neo4j.
the class RelationshipEntityWrappingValue method properties.
public MapValue properties(PropertyCursor propertyCursor) {
MapValue m = properties;
if (m == null) {
try {
synchronized (this) {
m = properties;
if (m == null) {
var relProperties = relationship instanceof RelationshipEntity ? ((RelationshipEntity) relationship).getAllProperties(propertyCursor) : relationship.getAllProperties();
m = properties = ValueUtils.asMapValue(relProperties);
}
}
} catch (NotFoundException | IllegalStateException e) {
throw new ReadAndDeleteTransactionConflictException(RelationshipEntity.isDeletedInCurrentTransaction(relationship), e);
}
}
return m;
}
use of org.neo4j.kernel.impl.core.RelationshipEntity in project neo4j by neo4j.
the class RelationshipEntityWrappingValue method writeTo.
@Override
public <E extends Exception> void writeTo(AnyValueWriter<E> writer) throws E {
if (writer.entityMode() == REFERENCE) {
writer.writeRelationshipReference(id());
} else {
if (relationship instanceof RelationshipEntity) {
RelationshipEntity proxy = (RelationshipEntity) relationship;
if (!proxy.initializeData()) {
// and that they need to retry it.
throw new ReadAndDeleteTransactionConflictException(RelationshipEntity.isDeletedInCurrentTransaction(relationship));
}
}
MapValue p;
try {
p = properties();
} catch (ReadAndDeleteTransactionConflictException e) {
if (!e.wasDeletedInThisTransaction()) {
throw e;
}
// If it isn't a transient error then the relationship was deleted in the current transaction and we should write an 'empty' relationship.
p = VirtualValues.EMPTY_MAP;
}
if (id() < 0) {
writer.writeVirtualRelationshipHack(relationship);
}
writer.writeRelationship(id(), startNode().id(), endNode().id(), type(), p);
}
}
use of org.neo4j.kernel.impl.core.RelationshipEntity in project neo4j by neo4j.
the class RelationshipEntityWrappingValue method populate.
public void populate() {
try {
if (relationship instanceof RelationshipEntity) {
RelationshipEntity proxy = (RelationshipEntity) relationship;
if (!proxy.initializeData()) {
// transaction.
return;
}
}
type();
properties();
startNode();
endNode();
} catch (NotFoundException | ReadAndDeleteTransactionConflictException e) {
// best effort, cannot do more
}
}
use of org.neo4j.kernel.impl.core.RelationshipEntity in project neo4j by neo4j.
the class RelationshipEntityWrappingValue method populate.
public void populate(RelationshipScanCursor relCursor, PropertyCursor propertyCursor) {
try {
if (relationship instanceof RelationshipEntity) {
RelationshipEntity proxy = (RelationshipEntity) relationship;
if (!proxy.initializeData(relCursor)) {
// transaction.
return;
}
}
// type, startNode and endNode will have counted their DB hits as part of initializeData.
type();
properties(propertyCursor);
startNode();
endNode();
} catch (NotFoundException | ReadAndDeleteTransactionConflictException e) {
// best effort, cannot do more
}
}
use of org.neo4j.kernel.impl.core.RelationshipEntity in project neo4j by neo4j.
the class TxStateTransactionDataSnapshot method relationship.
private Relationship relationship(long relId) {
RelationshipEntity relationship = (RelationshipEntity) internalTransaction.newRelationshipEntity(relId);
if (!state.relationshipVisit(relId, relationship)) {
// This relationship has been created or changed in this transaction
RelationshipEntity cached = relationshipsReadFromStore.get(relId);
if (cached != null) {
return cached;
}
// Get this relationship data from the store
this.relationship.single(relId);
if (!this.relationship.next()) {
throw new IllegalStateException("Getting deleted relationship data should have been covered by the tx state");
}
relationship.visit(relId, this.relationship.type(), this.relationship.sourceNodeReference(), this.relationship.targetNodeReference());
memoryTracker.allocateHeap(RelationshipEntity.SHALLOW_SIZE);
relationshipsReadFromStore.put(relId, relationship);
}
return relationship;
}
Aggregations