private NodeRecord readNodeRecord(long id) throws IOException { byte inUseFlag = channel.get(); boolean inUse = false; if (inUseFlag == Record.IN_USE.byteValue()) { inUse = true; } else if (inUseFlag != Record.NOT_IN_USE.byteValue()) { throw new IOException("Illegal in use flag: " + inUseFlag); } NodeRecord record; if (inUse) { record = new NodeRecord(id, false, channel.getLong(), channel.getLong()); // labels long labelField = channel.getLong(); Collection<DynamicRecord> dynamicLabelRecords = new ArrayList<>(); readDynamicRecords(dynamicLabelRecords, COLLECTION_DYNAMIC_RECORD_ADDER); record.setLabelField(labelField, dynamicLabelRecords); } else { record = new NodeRecord( id, false, Record.NO_NEXT_RELATIONSHIP.intValue(), Record.NO_NEXT_PROPERTY.intValue()); } record.setInUse(inUse); return record; }
@Override public long nextPosition(long nextPosition, DirectionWrapper direction, int[] types) { currentPosition.nextPosition(nextPosition, direction, types); if (nextPosition != Record.NO_NEXT_RELATIONSHIP.intValue()) { return nextPosition; } return position(direction, types); }
public RecordProxy<Long, RelationshipGroupRecord, Integer> getRelationshipGroup( NodeRecord node, int type) { long groupId = node.getNextRel(); long previousGroupId = Record.NO_NEXT_RELATIONSHIP.intValue(); Set<Integer> allTypes = new HashSet<>(); while (groupId != Record.NO_NEXT_RELATIONSHIP.intValue()) { RecordProxy<Long, RelationshipGroupRecord, Integer> change = recordChangeSet.getRelGroupRecords().getOrLoad(groupId, type); RelationshipGroupRecord record = change.forReadingData(); record.setPrev(previousGroupId); // not persistent so not a "change" allTypes.add(record.getType()); if (record.getType() == type) { return change; } previousGroupId = groupId; groupId = record.getNext(); } return null; }
TypePosition(RelationshipGroupRecord record) { for (DirectionWrapper direction : DirectionWrapper.values()) { long firstRel = direction.getNextRel(record); directions.put( direction, firstRel != Record.NO_NEXT_RELATIONSHIP.intValue() ? new SingleChainPosition(firstRel) : RelationshipLoadingPosition.EMPTY); } }
@Override public long position(DirectionWrapper direction, int[] types) { if (types.length == 0) { types = this.types; } for (int type : types) { RelationshipLoadingPosition position = getTypePosition(type); if (position.hasMore(direction, types)) { currentPosition = position; return position.position(direction, types); } } return Record.NO_NEXT_RELATIONSHIP.intValue(); }
@Override public long position(DirectionWrapper direction, int[] types) { if (direction == DirectionWrapper.BOTH) { for (RelationshipLoadingPosition position : directions.values()) { if (position.hasMore(direction, types)) { currentPosition = position; return position.position(direction, types); } } } else { for (DirectionWrapper dir : new DirectionWrapper[] {direction, DirectionWrapper.BOTH}) { RelationshipLoadingPosition position = directions.get(dir); if (position.hasMore(dir, types)) { currentPosition = position; return position.position(dir, types); } } } return Record.NO_NEXT_RELATIONSHIP.intValue(); }