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); }
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); }
public static long[] Get(NodeRecord node, NodeStore nodeStore) { if (node.Light) { nodeStore.EnsureHeavy(node, firstDynamicLabelRecordId(node.LabelField)); } return(GetDynamicLabelsArray(node.UsedDynamicLabelRecords, nodeStore.DynamicLabelStore)); }
public override ICollection <DynamicRecord> Add(long labelId, NodeStore nodeStore, DynamicRecordAllocator allocator) { nodeStore.EnsureHeavy(_node, firstDynamicLabelRecordId(_node.LabelField)); long[] existingLabelIds = GetDynamicLabelsArray(_node.UsedDynamicLabelRecords, nodeStore.DynamicLabelStore); long[] newLabelIds = LabelIdArray.ConcatAndSort(existingLabelIds, labelId); ICollection <DynamicRecord> existingRecords = _node.DynamicLabelRecords; ICollection <DynamicRecord> changedDynamicRecords = AllocateRecordsForDynamicLabels(_node.Id, newLabelIds, new ReusableRecordsCompositeAllocator(existingRecords, allocator)); _node.setLabelField(DynamicPointer(changedDynamicRecords), changedDynamicRecords); return(changedDynamicRecords); }