use of org.neo4j.kernel.impl.store.record.RelationshipRecord in project neo4j by neo4j.
the class RelationshipCreator method relationshipCreate.
/**
* Creates a relationship with the given id, from the nodes identified by id
* and of type typeId
*
* @param id The id of the relationship to create.
* @param type The id of the relationship type this relationship will
* have.
* @param firstNodeId The id of the start node.
* @param secondNodeId The id of the end node.
*/
public void relationshipCreate(long id, int type, long firstNodeId, long secondNodeId, RecordAccessSet recordChangeSet, ResourceLocker locks) {
// TODO could be unnecessary to mark as changed here already, dense nodes may not need to change
NodeRecord firstNode = recordChangeSet.getNodeRecords().getOrLoad(firstNodeId, null).forChangingLinkage();
NodeRecord secondNode = recordChangeSet.getNodeRecords().getOrLoad(secondNodeId, null).forChangingLinkage();
convertNodeToDenseIfNecessary(firstNode, recordChangeSet.getRelRecords(), recordChangeSet.getRelGroupRecords(), locks);
convertNodeToDenseIfNecessary(secondNode, recordChangeSet.getRelRecords(), recordChangeSet.getRelGroupRecords(), locks);
RelationshipRecord record = recordChangeSet.getRelRecords().create(id, null).forChangingLinkage();
record.setLinks(firstNodeId, secondNodeId, type);
record.setInUse(true);
record.setCreated();
connectRelationship(firstNode, secondNode, record, recordChangeSet.getRelRecords(), recordChangeSet.getRelGroupRecords(), locks);
}
use of org.neo4j.kernel.impl.store.record.RelationshipRecord in project neo4j by neo4j.
the class RelationshipDeleter method decrementTotalRelationshipCount.
private boolean decrementTotalRelationshipCount(long nodeId, RelationshipRecord rel, long firstRelId, RecordAccess<Long, RelationshipRecord, Void> relRecords, ResourceLocker locks) {
if (firstRelId == Record.NO_PREV_RELATIONSHIP.intValue()) {
return true;
}
boolean firstInChain = relIsFirstInChain(nodeId, rel);
if (!firstInChain) {
locks.acquireExclusive(LockTracer.NONE, ResourceTypes.RELATIONSHIP, firstRelId);
}
RelationshipRecord firstRel = relRecords.getOrLoad(firstRelId, null).forChangingLinkage();
if (nodeId == firstRel.getFirstNode()) {
firstRel.setFirstPrevRel(firstInChain ? relCount(nodeId, rel) - 1 : relCount(nodeId, firstRel) - 1);
firstRel.setFirstInFirstChain(true);
}
if (nodeId == firstRel.getSecondNode()) {
firstRel.setSecondPrevRel(firstInChain ? relCount(nodeId, rel) - 1 : relCount(nodeId, firstRel) - 1);
firstRel.setFirstInSecondChain(true);
}
return false;
}
use of org.neo4j.kernel.impl.store.record.RelationshipRecord in project neo4j by neo4j.
the class RelationshipDeleter method relDelete.
/**
* Deletes a relationship by its id, returning its properties which are now
* removed. It is assumed that the nodes it connects have already been
* deleted in this
* transaction.
*
* @param id The id of the relationship to delete.
*/
public void relDelete(long id, RecordAccessSet recordChanges, ResourceLocker locks) {
RelationshipRecord record = recordChanges.getRelRecords().getOrLoad(id, null).forChangingLinkage();
propertyChainDeleter.deletePropertyChain(record, recordChanges.getPropertyRecords());
disconnectRelationship(record, recordChanges, locks);
updateNodesForDeletedRelationship(record, recordChanges, locks);
record.setInUse(false);
}
use of org.neo4j.kernel.impl.store.record.RelationshipRecord in project neo4j by neo4j.
the class PhysicalLogCommandReaderV3_0_2 method visitRelationshipCommand.
private Command visitRelationshipCommand(ReadableChannel channel) throws IOException {
long id = channel.getLong();
RelationshipRecord before = readRelationshipRecord(id, channel);
if (before == null) {
return null;
}
RelationshipRecord after = readRelationshipRecord(id, channel);
if (after == null) {
return null;
}
if (!before.inUse() && after.inUse()) {
after.setCreated();
}
return new Command.RelationshipCommand(before, after);
}
use of org.neo4j.kernel.impl.store.record.RelationshipRecord in project neo4j by neo4j.
the class NodePropertiesReporter method reportNodeProperties.
public void reportNodeProperties(PrintWriter writer, RecordSet<RelationshipRecord> relationshipRecords) {
Set<Long> nodeIds = new HashSet<Long>();
for (RelationshipRecord relationshipRecord : relationshipRecords) {
nodeIds.add(relationshipRecord.getFirstNode());
nodeIds.add(relationshipRecord.getSecondNode());
}
for (Long nodeId : nodeIds) {
reportNodeProperties(writer, nodeId);
}
}
Aggregations