private void TestEncodeDecodeMinDelta32 <T>(int count, Func <int, T[]> factory, int shift, int skip) where T : unmanaged { var chunk = factory(count); var result = new T[count]; var size = CodecExt.GetMaxEncodedSizeForMinDelta32(chunk.Length); var buffer = new UnsafeBuffer(size); // Copy partial data if (skip > 0) { fixed(T *src = chunk) fixed(T * dst = result) { Extensions.CopyBlock((byte *)src, (byte *)dst, count * sizeof(T), skip, sizeof(T) - skip); } } fixed(T *p = chunk) { var dst = buffer.Ptr; CodecExt.EncodeMinDelta32((byte *)p + shift, count * sizeof(T) - shift, skip, ref dst); } fixed(T *p = result) { var src = buffer.Ptr; CodecExt.DecodeMinDelta32(ref src, skip, (byte *)p + shift); } chunk.IsEqualTo(result); }
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); }