private static void link( RelationshipGroupRecord... groups ) { for ( int i = 0; i < groups.length; i++ ) { if ( i > 0 ) { groups[i].setPrev( groups[i - 1].getId() ); } if ( i < groups.length - 1 ) { groups[i].setNext( groups[i + 1].getId() ); } } }
private void deleteGroup( RecordProxy<NodeRecord, Void> nodeChange, RelationshipGroupRecord group, RecordAccess<RelationshipGroupRecord, Integer> relGroupRecords ) { long previous = group.getPrev(); long next = group.getNext(); if ( previous == Record.NO_NEXT_RELATIONSHIP.intValue() ) { // This is the first one, just point the node to the next group nodeChange.forChangingLinkage().setNextRel( next ); } else { // There are others before it, point the previous to the next group RelationshipGroupRecord previousRecord = relGroupRecords.getOrLoad( previous, null ).forChangingLinkage(); previousRecord.setNext( next ); } if ( next != Record.NO_NEXT_RELATIONSHIP.intValue() ) { // There are groups after this one, point that next group to the previous of the group to be deleted RelationshipGroupRecord nextRecord = relGroupRecords.getOrLoad( next, null ).forChangingLinkage(); nextRecord.setPrev( previous ); } group.setInUse( false ); }
public RelationshipGroupPosition getRelationshipGroup( NodeRecord node, int type, RecordAccess<RelationshipGroupRecord, Integer> relGroupRecords ) { long groupId = node.getNextRel(); long previousGroupId = Record.NO_NEXT_RELATIONSHIP.intValue(); RecordProxy<RelationshipGroupRecord, Integer> previous = null; RecordProxy<RelationshipGroupRecord, Integer> current; while ( groupId != Record.NO_NEXT_RELATIONSHIP.intValue() ) { current = relGroupRecords.getOrLoad( groupId, null ); RelationshipGroupRecord record = current.forReadingData(); record.setPrev( previousGroupId ); // not persistent so not a "change" if ( record.getType() == type ) { return new RelationshipGroupPosition( previous, current ); } else if ( record.getType() > type ) { // The groups are sorted in the chain, so if we come too far we can return // empty handed right away return new RelationshipGroupPosition( previous, null ); } previousGroupId = groupId; groupId = record.getNext(); previous = current; } return new RelationshipGroupPosition( previous, null ); }
private static RecordProxy<RelationshipGroupRecord, Integer> getRelationshipGroup( RecordChangeSet recordChangeSet, NodeRecord node, int type ) { long groupId = node.getNextRel(); long previousGroupId = Record.NO_NEXT_RELATIONSHIP.intValue(); while ( groupId != Record.NO_NEXT_RELATIONSHIP.intValue() ) { RecordProxy<RelationshipGroupRecord, Integer> change = recordChangeSet.getRelGroupRecords().getOrLoad( groupId, type ); RelationshipGroupRecord record = change.forReadingData(); record.setPrev( previousGroupId ); // not persistent so not a "change" if ( record.getType() == type ) { return change; } previousGroupId = groupId; groupId = record.getNext(); } return null; }
public RelationshipGroupPosition getRelationshipGroup( NodeRecord node, int type, RecordAccess<RelationshipGroupRecord, Integer> relGroupRecords ) { long groupId = node.getNextRel(); long previousGroupId = Record.NO_NEXT_RELATIONSHIP.intValue(); RecordProxy<RelationshipGroupRecord, Integer> previous = null; RecordProxy<RelationshipGroupRecord, Integer> current; while ( groupId != Record.NO_NEXT_RELATIONSHIP.intValue() ) { current = relGroupRecords.getOrLoad( groupId, null ); RelationshipGroupRecord record = current.forReadingData(); record.setPrev( previousGroupId ); // not persistent so not a "change" if ( record.getType() == type ) { return new RelationshipGroupPosition( previous, current ); } else if ( record.getType() > type ) { // The groups are sorted in the chain, so if we come too far we can return // empty handed right away return new RelationshipGroupPosition( previous, null ); } previousGroupId = groupId; groupId = record.getNext(); previous = current; } return new RelationshipGroupPosition( previous, null ); }
private void deleteGroup( RecordProxy<NodeRecord, Void> nodeChange, RelationshipGroupRecord group, RecordAccess<RelationshipGroupRecord, Integer> relGroupRecords ) { long previous = group.getPrev(); long next = group.getNext(); if ( previous == Record.NO_NEXT_RELATIONSHIP.intValue() ) { // This is the first one, just point the node to the next group nodeChange.forChangingLinkage().setNextRel( next ); } else { // There are others before it, point the previous to the next group RelationshipGroupRecord previousRecord = relGroupRecords.getOrLoad( previous, null ).forChangingLinkage(); previousRecord.setNext( next ); } if ( next != Record.NO_NEXT_RELATIONSHIP.intValue() ) { // There are groups after this one, point that next group to the previous of the group to be deleted RelationshipGroupRecord nextRecord = relGroupRecords.getOrLoad( next, null ).forChangingLinkage(); nextRecord.setPrev( previous ); } group.setInUse( false ); }