internal NativeLabelScanWriter(int batchSize, WriteMonitor monitor) { this._pendingUpdates = new NodeLabelUpdate[batchSize]; this._addMerger = (existingKey, newKey, existingValue, newValue) => { monitor.MergeAdd(existingValue, newValue); return(existingValue.add(newValue)); }; this._removeMerger = (existingKey, newKey, existingValue, newValue) => { monitor.MergeRemove(existingValue, newValue); return(existingValue.remove(newValue)); }; this._monitor = monitor; }
public override void Merge(LabelScanKey key, LabelScanValue value, ValueMerger <LabelScanKey, LabelScanValue> amender) { // Clone since these instances are reused between calls, internally in the writer key = Clone(key); value = Clone(value); IDictionary <LabelScanKey, LabelScanValue> forLabel = Data.computeIfAbsent(key.LabelId, labelId => new SortedDictionary <LabelScanKey, LabelScanValue>(_keyComparator)); LabelScanValue existing = forLabel[key]; if (existing == null) { forLabel[key] = value; } else { amender.Merge(key, key, existing, value); } }