示例#1
0
        public static byte[] Encode(ReadOnlySpan <byte> src)
        {
            int maxLen = SnappyWriter.GetMaxEncodedLen(src.Length);

            using (var dst = new RentedBuffer(maxLen))
            {
                ReadOnlySpan <byte> compressed = SnappyWriter.Encode(dst.Span, src);

                return(compressed.ToArray());
            }
        }
示例#2
0
        public static byte[] Decode(ReadOnlySpan <byte> src)
        {
            int dLen = SnappyReader.DecodedLen(src);

            using (var dst = new RentedBuffer(dLen))
            {
                Span <byte> uncompressed = SnappyReader.Decode(dst.Span, src);

                return(uncompressed.ToArray());
            }
        }
示例#3
0
 public RentedBuffer(RentedBuffer parent, int start, int count)
 {
     _parent = parent;
     _start  = start;
     _count  = count;
 }