Ejemplo n.º 1
0
        public void SetItems(LowLevelTransaction tx, Dictionary <long, PagePosition> items)
        {
            lock (_transactionPages)
            {
                UpdateMaxSeenTxId(tx);
                _transactionPages.Add(tx.Id, items);
            }

            // here we rely on the fact that only one thread can update the concurrent dictionary
            foreach (var item in items)
            {
                if (_values.TryGetValue(item.Key, out var value) == false)
                {
                    value = new PagesBuffer(new PagePosition[2], null);
                    _values.TryAdd(item.Key, value);
                }
                if (value.CanAdd == false)
                {
                    var newVal = new PagesBuffer(new PagePosition[value.Capacity * 2], value);
                    _values.TryUpdate(item.Key, newVal, value);
                    value = newVal;
                }
                value.Add(item.Value);
            }
        }
Ejemplo n.º 2
0
 public PagesBuffer(PagePosition[] buffer, PagesBuffer previous)
 {
     PagePositions = buffer;
     if (previous == null)
     {
         return;
     }
     End = previous.End - previous.Start;
     Array.Copy(previous.PagePositions, previous.Start, PagePositions, 0, End);
 }