public static byte[] Compress(byte[] input) { var compressionArray = new byte[input.Length + 2]; var compressedLength = SnappyCompress.Compress(SnappyByteBuffer.NewSync(compressionArray), SnappyByteBuffer.NewSync(input)); var output = new byte[compressedLength]; Array.Copy(compressionArray, output, compressedLength); return(output); }
public static SnappyByteBuffer Decompress(SnappyByteBuffer compressedBytes) { int ofs; var decompressedSize = DecompressedSize(compressedBytes, out ofs); if (decompressedSize < 0) { throw new InvalidDataException(); } var dst = new byte[decompressedSize]; var dstBuf = SnappyByteBuffer.NewAsync(dst); if (!DecompressRaw(dstBuf, SnappyByteBuffer.NewSync(compressedBytes.Buffer, compressedBytes.Offset + ofs, compressedBytes.Length - ofs))) { throw new InvalidDataException(); } return(dstBuf); }
public static byte[] Decompress(byte[] input) { var buffer = SnappyDecompress.Decompress(SnappyByteBuffer.NewSync(input)); return(buffer.ToByteArray()); }