Exemplo n.º 1
0
        public ulong GetCounterValue(Counter counter, Span <byte> index)
        {
            using var _ = RocksDbEncoder.EncodeCounter(counter, index, out var key);
            var result = Database.Get(key);

            return(result != null?BinaryPrimitives.ReadUInt64LittleEndian(result) : 0);
        }
Exemplo n.º 2
0
        internal void IncrementCounterValue(WriteBatch batch, Counter counter, Span <byte> index)
        {
            using var _ = RocksDbEncoder.EncodeCounter(counter, index, out var key);

            byte[] newValueBytes = new byte[8];
            BinaryPrimitives.WriteUInt64LittleEndian(newValueBytes, 1);
            // Todo: Allocation
            batch.Merge(key.ToArray(), (ulong)key.Length, newValueBytes, (ulong)newValueBytes.Length);
        }