コード例 #1
0
        ByteBuffer GetCurrentKeyFromStack()
        {
            var result = ByteBuffer.NewAsync(new byte[_cursor.GetKeyLength()]);

            _cursor.FillByKey(result.AsSyncSpan());
            return(result);
        }
コード例 #2
0
 public void EraseRange(long firstKeyIndex, long lastKeyIndex)
 {
     if (firstKeyIndex < 0)
     {
         firstKeyIndex = 0;
     }
     if (lastKeyIndex >= GetKeyValueCount())
     {
         lastKeyIndex = _prefixKeyCount - 1;
     }
     if (lastKeyIndex < firstKeyIndex)
     {
         return;
     }
     MakeWritable();
     firstKeyIndex += _prefixKeyStart;
     lastKeyIndex  += _prefixKeyStart;
     _cursor.SeekIndex(firstKeyIndex);
     if (lastKeyIndex != firstKeyIndex)
     {
         if (_cursor2 == null)
         {
             _cursor2 = BTreeRoot.CreateCursor();
         }
         _cursor2.SeekIndex(lastKeyIndex);
         var firstKey  = GetCurrentKeyFromStack();
         var secondKey = ByteBuffer.NewAsync(new byte[_cursor2.GetKeyLength()]);
         _cursor2.FillByKey(secondKey.AsSyncSpan());
         _keyValueDB.WriteEraseRangeCommand(firstKey, secondKey);
         _cursor.EraseTo(_cursor2);
     }
     else
     {
         _keyValueDB.WriteEraseOneCommand(GetCurrentKeyFromStack());
         _cursor.Erase();
     }
     InvalidateCurrentKey();
     _prefixKeyCount -= lastKeyIndex - firstKeyIndex + 1;
 }
コード例 #3
0
ファイル: CursorTestsBase.cs プロジェクト: valmac/BTDB
        public void CanInsertFirstData(byte[] key)
        {
            Assert.Equal(0, _root.GetCount());
            var val = GetSampleValue();

            Assert.True(_cursor.Upsert(key, val));
            Assert.Equal(1, _root.GetCount());
            Assert.Equal(key.Length, _cursor.GetKeyLength());
            Assert.Equal(key, _cursor.FillByKey(new byte[key.Length]).ToArray());
            Assert.Equal(val.Length, _cursor.GetValueLength());
            Assert.Equal(val.ToArray(), _cursor.GetValue().ToArray());
        }