public void EraseCurrent()
 {
     EnsureValidKey();
     MakeWritable();
     _keyValueDB.WriteEraseOneCommand(GetCurrentKeyFromStack());
     _cursor.Erase();
     InvalidateCurrentKey();
     if (_prefixKeyCount >= 0)
     {
         _prefixKeyCount--;
     }
 }
Example #2
0
 public void EraseCurrent()
 {
     EnsureValidKey();
     MakeWrittable();
     _cursor.Erase();
     InvalidateCurrentKey();
     if (_prefixKeyCount >= 0)
     {
         _prefixKeyCount--;
     }
 }
Example #3
0
        public void EraseToOneChild(int count)
        {
            var val = GetSampleValue().ToArray();
            var key = new byte[3];

            for (var i = 0; i < count; i++)
            {
                key[1] = (byte)(i * 2);
                key[2] = (byte)(i + 5);
                _cursor.Upsert(key, val);
            }

            key[1] = 2;
            key[2] = 6;
            _cursor.FindExact(key);
            var c2 = _cursor.Clone();

            c2.SeekIndex(c2.FindLastWithPrefix(new ReadOnlySpan <byte>()));
            Assert.Equal(count - 1, _cursor.EraseTo(c2));
            Assert.Equal(1, _root.GetCount());
            _cursor.FindFirst(new ReadOnlySpan <byte>());
            key = _cursor.GetKeyAsArray();
            Assert.Equal(0, key[0]);
            Assert.Equal(0, key[1]);
            Assert.Equal(5, key[2]);
            Assert.Equal(val, _cursor.GetValue().ToArray());
            _cursor.Erase();
            for (var i = 0; i < count; i++)
            {
                key[1] = (byte)(i * 2);
                _cursor.Upsert(key, val);
            }

            key[1] = 0;
            _cursor.FindExact(key);
            c2 = _cursor.Clone();
            c2.SeekIndex(c2.FindLastWithPrefix(new ReadOnlySpan <byte>()));
            c2.MovePrevious();
            Assert.Equal(count - 1, _cursor.EraseTo(c2));
            Assert.Equal(1, _root.GetCount());
            _cursor.FindFirst(new ReadOnlySpan <byte>());
            key = _cursor.GetKeyAsArray();
            Assert.Equal(0, key[0]);
            Assert.Equal((count - 1) * 2, key[1]);
            Assert.Equal(val, _cursor.GetValue().ToArray());
        }