コード例 #1
0
ファイル: DynamicNodeLabels.cs プロジェクト: Neo4Net/Neo4Net
        internal static ICollection <DynamicRecord> PutSorted(NodeRecord node, long[] labelIds, NodeStore nodeStore, DynamicRecordAllocator allocator)
        {
            long existingLabelsField = node.LabelField;
            long existingLabelsBits  = parseLabelsBody(existingLabelsField);

            ICollection <DynamicRecord> changedDynamicRecords = node.DynamicLabelRecords;

            long labelField = node.LabelField;

            if (fieldPointsToDynamicRecordOfLabels(labelField))
            {
                // There are existing dynamic label records, get them
                nodeStore.EnsureHeavy(node, existingLabelsBits);
                changedDynamicRecords = node.DynamicLabelRecords;
                NotInUse = changedDynamicRecords;
            }

            if (!InlineNodeLabels.TryInlineInNodeRecord(node, labelIds, changedDynamicRecords))
            {
                IEnumerator <DynamicRecord> recycledRecords  = changedDynamicRecords.GetEnumerator();
                ICollection <DynamicRecord> allocatedRecords = AllocateRecordsForDynamicLabels(node.Id, labelIds, new ReusableRecordsCompositeAllocator(recycledRecords, allocator));
                // Set the rest of the previously set dynamic records as !inUse
                while (recycledRecords.MoveNext())
                {
                    DynamicRecord removedRecord = recycledRecords.Current;
                    removedRecord.InUse = false;
                    allocatedRecords.Add(removedRecord);
                }
                node.SetLabelField(DynamicPointer(allocatedRecords), allocatedRecords);
                changedDynamicRecords = allocatedRecords;
            }

            return(changedDynamicRecords);
        }
コード例 #2
0
ファイル: DynamicNodeLabels.cs プロジェクト: Neo4Net/Neo4Net
        public override ICollection <DynamicRecord> Remove(long labelId, NodeStore nodeStore)
        {
            nodeStore.EnsureHeavy(_node, firstDynamicLabelRecordId(_node.LabelField));
            long[] existingLabelIds = GetDynamicLabelsArray(_node.UsedDynamicLabelRecords, nodeStore.DynamicLabelStore);
            long[] newLabelIds      = filter(existingLabelIds, labelId);
            ICollection <DynamicRecord> existingRecords = _node.DynamicLabelRecords;

            if (InlineNodeLabels.TryInlineInNodeRecord(_node, newLabelIds, existingRecords))
            {
                NotInUse = existingRecords;
            }
            else
            {
                ICollection <DynamicRecord> newRecords = AllocateRecordsForDynamicLabels(_node.Id, newLabelIds, new ReusableRecordsCompositeAllocator(existingRecords, nodeStore.DynamicLabelStore));
                _node.setLabelField(DynamicPointer(newRecords), existingRecords);
                if (!newRecords.Equals(existingRecords))
                {                         // One less dynamic record, mark that one as not in use
                    foreach (DynamicRecord record in existingRecords)
                    {
                        if (!newRecords.Contains(record))
                        {
                            record.InUse = false;
                        }
                    }
                }
            }
            return(existingRecords);
        }
コード例 #3
0
ファイル: NodeLabelsField.cs プロジェクト: Neo4Net/Neo4Net
 public static long[] Get(NodeRecord node, NodeStore nodeStore)
 {
     return(FieldPointsToDynamicRecordOfLabels(node.LabelField) ? DynamicNodeLabels.Get(node, nodeStore) : InlineNodeLabels.Get(node));
 }