use of org.neo4j.kernel.impl.store.record.RelationshipRecord in project neo4j by neo4j.
the class RelationshipChainExplorer method expandChain.
private RecordSet<RelationshipRecord> expandChain(RelationshipRecord record, long nodeId, RelationshipChainDirection direction) {
RecordSet<RelationshipRecord> chain = new RecordSet<>();
chain.add(record);
RelationshipRecord currentRecord = record;
long nextRelId = direction.fieldFor(nodeId, currentRecord).relOf(currentRecord);
while (currentRecord.inUse() && !direction.fieldFor(nodeId, currentRecord).endOfChain(currentRecord)) {
currentRecord = recordStore.getRecord(nextRelId, recordStore.newRecord(), FORCE);
chain.add(currentRecord);
nextRelId = direction.fieldFor(nodeId, currentRecord).relOf(currentRecord);
}
return chain;
}
use of org.neo4j.kernel.impl.store.record.RelationshipRecord in project neo4j by neo4j.
the class StorageLayer method relationshipVisit.
@Override
public <EXCEPTION extends Exception> void relationshipVisit(long relationshipId, RelationshipVisitor<EXCEPTION> relationshipVisitor) throws EntityNotFoundException, EXCEPTION {
// TODO Please don't create a record for this, it's ridiculous
RelationshipRecord record = relationshipStore.getRecord(relationshipId, relationshipStore.newRecord(), CHECK);
if (!record.inUse()) {
throw new EntityNotFoundException(EntityType.RELATIONSHIP, relationshipId);
}
relationshipVisitor.visit(relationshipId, record.getType(), record.getFirstNode(), record.getSecondNode());
}
use of org.neo4j.kernel.impl.store.record.RelationshipRecord in project neo4j by neo4j.
the class StorageLayer method degreeRelationshipsInGroup.
@Override
public int degreeRelationshipsInGroup(StorageStatement storeStatement, long nodeId, long groupId, Direction direction, Integer relType) {
RelationshipRecord relationshipRecord = relationshipStore.newRecord();
RelationshipGroupRecord relationshipGroupRecord = relationshipGroupStore.newRecord();
return countRelationshipsInGroup(groupId, direction, relType, nodeId, relationshipRecord, relationshipGroupRecord, storeStatement.recordCursors());
}
use of org.neo4j.kernel.impl.store.record.RelationshipRecord in project neo4j by neo4j.
the class StorageLayer method visitDenseNode.
private void visitDenseNode(StorageStatement statement, NodeItem nodeItem, DegreeVisitor visitor) {
RelationshipGroupRecord relationshipGroupRecord = relationshipGroupStore.newRecord();
RecordCursor<RelationshipGroupRecord> relationshipGroupCursor = statement.recordCursors().relationshipGroup();
RelationshipRecord relationshipRecord = relationshipStore.newRecord();
RecordCursor<RelationshipRecord> relationshipCursor = statement.recordCursors().relationship();
long groupId = nodeItem.nextGroupId();
while (groupId != NO_NEXT_RELATIONSHIP.longValue()) {
relationshipGroupCursor.next(groupId, relationshipGroupRecord, FORCE);
if (relationshipGroupRecord.inUse()) {
int type = relationshipGroupRecord.getType();
long firstLoop = relationshipGroupRecord.getFirstLoop();
long firstOut = relationshipGroupRecord.getFirstOut();
long firstIn = relationshipGroupRecord.getFirstIn();
long loop = countByFirstPrevPointer(firstLoop, relationshipCursor, nodeItem.id(), relationshipRecord);
long outgoing = countByFirstPrevPointer(firstOut, relationshipCursor, nodeItem.id(), relationshipRecord) + loop;
long incoming = countByFirstPrevPointer(firstIn, relationshipCursor, nodeItem.id(), relationshipRecord) + loop;
visitor.visitDegree(type, outgoing, incoming);
}
groupId = relationshipGroupRecord.getNext();
}
}
use of org.neo4j.kernel.impl.store.record.RelationshipRecord in project neo4j by neo4j.
the class PhysicalLogCommandReaderV2_1 method visitRelationshipCommand.
private Command visitRelationshipCommand(ReadableChannel channel) throws IOException {
long id = channel.getLong();
byte flags = channel.get();
boolean inUse = false;
if (notFlag(notFlag(flags, Record.IN_USE.byteValue()), Record.CREATED_IN_TX) != 0) {
throw new IOException("Illegal in use flag: " + flags);
}
if (bitFlag(flags, Record.IN_USE.byteValue())) {
inUse = true;
}
RelationshipRecord record;
if (inUse) {
record = new RelationshipRecord(id, channel.getLong(), channel.getLong(), channel.getInt());
record.setInUse(true);
record.setFirstPrevRel(channel.getLong());
record.setFirstNextRel(channel.getLong());
record.setSecondPrevRel(channel.getLong());
record.setSecondNextRel(channel.getLong());
record.setNextProp(channel.getLong());
byte extraByte = channel.get();
record.setFirstInFirstChain((extraByte & 0x1) > 0);
record.setFirstInSecondChain((extraByte & 0x2) > 0);
} else {
record = new RelationshipRecord(id);
record.setInUse(false);
}
if (bitFlag(flags, Record.CREATED_IN_TX)) {
record.setCreated();
}
return new Command.RelationshipCommand(null, record);
}
Aggregations