Exemplo n.º 1
0
        public IEnumerable <KeyValuePair <uint, uint> > QuerySizeEnumerator()
        {
            long prevProtectionCounter   = 0;
            var  prevModificationCounter = 0;
            long pos = 0;

            while (true)
            {
                _keyValueTrProtector.Start();
                if (pos == 0)
                {
                    prevModificationCounter = _modificationCounter;
                    _keyValueTr.SetKeyPrefix(_prefix);
                    if (!_keyValueTr.FindFirstKey())
                    {
                        break;
                    }
                }
                else
                {
                    if (_keyValueTrProtector.WasInterupted(prevProtectionCounter))
                    {
                        if (prevModificationCounter != _modificationCounter)
                        {
                            ThrowModifiedDuringEnum();
                        }
                        _keyValueTr.SetKeyPrefix(_prefix);
                        if (!_keyValueTr.SetKeyIndex(pos))
                        {
                            break;
                        }
                    }
                    else
                    {
                        if (!_keyValueTr.FindNextKey())
                        {
                            break;
                        }
                    }
                }

                prevProtectionCounter = _keyValueTrProtector.ProtectionCounter;
                var size = _keyValueTr.GetStorageSizeOfCurrentKey();
                yield return(size);

                pos++;
            }
        }
Exemplo n.º 2
0
 public void MarkCurrentKeyAsUsed(IKeyValueDBTransaction tr)
 {
     Keys = Keys.ResizingAppend(ByteBuffer.NewAsync(tr.GetKey()));
     Builder.Append("Used key: ");
     Print(tr.GetKey());
     Builder.AppendFormat(" Value len:{0}", tr.GetStorageSizeOfCurrentKey().Value);
     Builder.AppendLine();
 }
Exemplo n.º 3
0
 public void MarkCurrentKeyAsUsed(IKeyValueDBTransaction tr)
 {
     Keys = Keys.ResizingAppend(ByteBuffer.NewSync(tr.GetKeyPrefix())).ResizingAppend(tr.GetKey());
     Builder.Append("Used key: ");
     Print(ByteBuffer.NewSync(tr.GetKeyPrefix()));
     Builder.Append('|');
     Print(tr.GetKey());
     Builder.AppendFormat(" Value len:{0}", tr.GetStorageSizeOfCurrentKey().Value);
     Builder.AppendLine();
 }
Exemplo n.º 4
0
        public KeyValuePair <uint, uint> GetStorageSize(ulong oid)
        {
            _keyValueTrProtector.Start();
            _keyValueTr.SetKeyPrefix(ObjectDB.AllObjectsPrefix);
            if (!_keyValueTr.FindExactKey(BuildKeyFromOid(oid)))
            {
                return(new KeyValuePair <uint, uint>(0, 0));
            }
            var res = _keyValueTr.GetStorageSizeOfCurrentKey();

            return(res);
        }
Exemplo n.º 5
0
 void ImportKeysWithPrefix(byte[] prefix, IKeyValueDBTransaction sourceKvTr)
 {
     sourceKvTr.SetKeyPrefix(prefix);
     if (!sourceKvTr.FindFirstKey())
         return;
     using (var kvtr = _keyValueDb.StartWritingTransaction().Result)
     {
         kvtr.SetKeyPrefix(prefix);
         do
         {
             //create all keys, instead of value store only byte length of value
             kvtr.CreateOrUpdateKeyValue(sourceKvTr.GetKey(), Vuint2ByteBuffer(sourceKvTr.GetStorageSizeOfCurrentKey().Value));
         } while (sourceKvTr.FindNextKey());
         kvtr.Commit();
     }
 }
Exemplo n.º 6
0
 void ImportKeysWithPrefix(byte[] prefix, IKeyValueDBTransaction sourceKvTr)
 {
     sourceKvTr.SetKeyPrefix(prefix);
     if (!sourceKvTr.FindFirstKey())
     {
         return;
     }
     using (var kvtr = _keyValueDb.StartWritingTransaction().Result)
     {
         kvtr.SetKeyPrefix(prefix);
         do
         {
             //create all keys, instead of value store only byte length of value
             kvtr.CreateOrUpdateKeyValue(sourceKvTr.GetKey(), Vuint2ByteBuffer(sourceKvTr.GetStorageSizeOfCurrentKey().Value));
         } while (sourceKvTr.FindNextKey());
         kvtr.Commit();
     }
 }
Exemplo n.º 7
0
 public void MarkCurrentKeyAsUsed(IKeyValueDBTransaction tr)
 {
     var(memory, disk)   = tr.GetStorageSizeOfCurrentKey();
     _currentMemorySize += memory + KeyOverhead;
     _currentOnDiskSize += disk;
 }
 public KeyValuePair <uint, uint> GetStorageSizeOfCurrentKey()
 {
     return(_keyValueDBTransaction.GetStorageSizeOfCurrentKey());
 }