예제 #1
0
        private void ConnectRelationshipToDenseNode(NodeRecord node, RelationshipRecord rel, RecordAccess <RelationshipRecord, Void> relRecords, RecordAccess <RelationshipGroupRecord, int> relGroupRecords, ResourceLocker locks)
        {
            RelationshipGroupRecord group = _relGroupGetter.getOrCreateRelationshipGroup(node, rel.Type, relGroupRecords).forChangingData();
            DirectionWrapper        dir   = DirectionIdentifier.wrapDirection(rel, node);
            long nextRel = dir.getNextRel(group);

            SetCorrectNextRel(node, rel, nextRel);
            Connect(node.Id, nextRel, rel, relRecords, locks);
            dir.setNextRel(group, rel.Id);
        }
예제 #2
0
        private void UpdateNodesForDeletedRelationship(RelationshipRecord rel, RecordAccessSet recordChanges, ResourceLocker locks)
        {
            RecordAccess_RecordProxy <NodeRecord, Void> startNodeChange = recordChanges.NodeRecords.getOrLoad(rel.FirstNode, null);
            RecordAccess_RecordProxy <NodeRecord, Void> endNodeChange   = recordChanges.NodeRecords.getOrLoad(rel.SecondNode, null);

            NodeRecord startNode = recordChanges.NodeRecords.getOrLoad(rel.FirstNode, null).forReadingLinkage();
            NodeRecord endNode   = recordChanges.NodeRecords.getOrLoad(rel.SecondNode, null).forReadingLinkage();
            bool       loop      = startNode.Id == endNode.Id;

            if (!startNode.Dense)
            {
                if (rel.FirstInFirstChain)
                {
                    startNode         = startNodeChange.ForChangingLinkage();
                    startNode.NextRel = rel.FirstNextRel;
                }
                DecrementTotalRelationshipCount(startNode.Id, rel, startNode.NextRel, recordChanges.RelRecords, locks);
            }
            else
            {
                RecordAccess_RecordProxy <RelationshipGroupRecord, int> groupChange = _relGroupGetter.getRelationshipGroup(startNode, rel.Type, recordChanges.RelGroupRecords).group();
                Debug.Assert(groupChange != null, "Relationship group " + rel.Type + " should have existed here");
                RelationshipGroupRecord group = groupChange.ForReadingData();
                DirectionWrapper        dir   = DirectionIdentifier.wrapDirection(rel, startNode);
                if (rel.FirstInFirstChain)
                {
                    group = groupChange.ForChangingData();
                    dir.setNextRel(group, rel.FirstNextRel);
                    if (GroupIsEmpty(group))
                    {
                        DeleteGroup(startNodeChange, group, recordChanges.RelGroupRecords);
                    }
                }
                DecrementTotalRelationshipCount(startNode.Id, rel, dir.getNextRel(group), recordChanges.RelRecords, locks);
            }

            if (!endNode.Dense)
            {
                if (rel.FirstInSecondChain)
                {
                    endNode         = endNodeChange.ForChangingLinkage();
                    endNode.NextRel = rel.SecondNextRel;
                }
                if (!loop)
                {
                    DecrementTotalRelationshipCount(endNode.Id, rel, endNode.NextRel, recordChanges.RelRecords, locks);
                }
            }
            else
            {
                RecordAccess_RecordProxy <RelationshipGroupRecord, int> groupChange = _relGroupGetter.getRelationshipGroup(endNode, rel.Type, recordChanges.RelGroupRecords).group();
                DirectionWrapper dir = DirectionIdentifier.wrapDirection(rel, endNode);
                Debug.Assert(groupChange != null || loop, "Group has been deleted");
                if (groupChange != null)
                {
                    RelationshipGroupRecord group;
                    if (rel.FirstInSecondChain)
                    {
                        group = groupChange.ForChangingData();
                        dir.setNextRel(group, rel.SecondNextRel);
                        if (GroupIsEmpty(group))
                        {
                            DeleteGroup(endNodeChange, group, recordChanges.RelGroupRecords);
                        }
                    }
                }                         // Else this is a loop-rel and the group was deleted when dealing with the start node
                if (!loop)
                {
                    DecrementTotalRelationshipCount(endNode.Id, rel, dir.getNextRel(groupChange.ForChangingData()), recordChanges.RelRecords, locks);
                }
            }
        }