Esempio n. 1
0
        private void TestEncodeDecodeMinDelta64 <T>(int count, Func <int, T[]> factory, int skip)
            where T : unmanaged
        {
            var chunk  = factory(count);
            var result = new T[count];

            var size   = CodecExt.GetMaxEncodedSizeForMinDeltaU64(chunk.Length);
            var buffer = new UnsafeBuffer(size);

            fixed(T *p = chunk)
            {
                var dst = buffer.Ptr;

                CodecExt.EncodeMinDeltaU64((byte *)p, count * sizeof(T), skip, ref dst);
            }

            fixed(T *p = result)
            {
                var src = buffer.Ptr;

                CodecExt.DecodeMinDeltaU64(ref src, skip, (byte *)p);
            }

            chunk.IsEqualTo(result);
        }
Esempio n. 2
0
        public int Decode(byte *src, int len, Int32Entry *dst)
        {
            var count = *(int *)src;

            src += sizeof(int);

            // Decodes header
            CodecExt.DecodeMinDeltaU64(ref src, sizeof(int), (byte *)dst);
            CodecExt.DecodeMinDelta32(ref src, sizeof(long), (byte *)(dst + sizeof(long)));

            return(count);
        }