Beispiel #1
0
 public VarintPostingsList(byte[] buffer, int length)
 {
     data         = buffer;
     this.length  = length;
     Count        = VarintEncoder.GetIntegerCount(buffer.AsSpan(0, length));
     prevInserted = this.LastOrDefault();
 }
        public void VarintEncoderSmokeTest()
        {
            var data = new byte[30];
            int pos  = 0;

            pos += VarintEncoder.Encode(1023, data.AsSpan(pos));
            pos += VarintEncoder.Encode(5, data.AsSpan(pos));
            pos += VarintEncoder.Encode(ulong.MaxValue, data.AsSpan(pos));
            pos += VarintEncoder.Encode(ulong.MinValue, data.AsSpan(pos));

            var encoded = VarintEncoder.Decode(data, 0, pos).ToArray();

            Assert.Equal(new ulong[] { 1023, 5, ulong.MaxValue, ulong.MinValue }, encoded);
            Assert.Equal(4, VarintEncoder.GetIntegerCount(data.AsSpan()));
        }