Exemple #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++;
            }
        }
Exemple #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();
 }
Exemple #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();
 }
Exemple #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);
        }
 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();
     }
 }
 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();
     }
 }
Exemple #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());
 }