示例#1
0
        public static RelationshipGroupCommand CreateRelationshipGroup(long id, int type)
        {
            RelationshipGroupRecord before = new RelationshipGroupRecord(id);
            RelationshipGroupRecord after  = new RelationshipGroupRecord(id, type);

            after.InUse = true;
            after.SetCreated();
            return(new RelationshipGroupCommand(before, after));
        }
示例#2
0
        public virtual RecordAccess_RecordProxy <RelationshipGroupRecord, int> GetOrCreateRelationshipGroup(NodeRecord node, int type, RecordAccess <RelationshipGroupRecord, int> relGroupRecords)
        {
            RelationshipGroupPosition existingGroup = GetRelationshipGroup(node, type, relGroupRecords);
            RecordAccess_RecordProxy <RelationshipGroupRecord, int> change = existingGroup.Group();

            if (change == null)
            {
                Debug.Assert(node.Dense, "Node " + node + " should have been dense at this point");
                long id = _idGenerator.nextId();
                change = relGroupRecords.Create(id, type);
                RelationshipGroupRecord record = change.ForChangingData();
                record.InUse = true;
                record.SetCreated();
                record.OwningNode = node.Id;

                // Attach it...
                RecordAccess_RecordProxy <RelationshipGroupRecord, int> closestPreviousChange = existingGroup.ClosestPrevious();
                if (closestPreviousChange != null)
                {                         // ...after the closest previous one
                    RelationshipGroupRecord closestPrevious = closestPreviousChange.ForChangingLinkage();
                    record.Next          = closestPrevious.Next;
                    record.Prev          = closestPrevious.Id;
                    closestPrevious.Next = id;
                }
                else
                {                         // ...first in the chain
                    long firstGroupId = node.NextRel;
                    if (firstGroupId != Record.NO_NEXT_RELATIONSHIP.intValue())
                    {                              // There are others, make way for this new group
                        RelationshipGroupRecord previousFirstRecord = relGroupRecords.GetOrLoad(firstGroupId, type).forReadingData();
                        record.Next = previousFirstRecord.Id;
                        previousFirstRecord.Prev = id;
                    }
                    node.NextRel = id;
                }
            }
            return(change);
        }
示例#3
0
 public virtual void Create(RelationshipGroupRecord group)
 {
     group.SetCreated();
     Update(new RelationshipGroupRecord(group.Id, group.Type), group);
 }