private byte[] ReadBlock(BlockHandle handle) { // var br = new BinaryReader(stream); // stream.Position = handle.Offset; // TODO optimize mem usage // TODO max int byte[] var n = (int)handle.Size; var data = _contentReader.ReadContent(handle.Offset, n + BlockTrailerSize); if (data.Length != n + BlockTrailerSize) { throw new InvalidDataException("truncated block read"); } // TODO crc32 checksum switch ((CompressionType)data[n]) { case CompressionType.NoCompression: Array.Resize(ref data, n); return(data); case CompressionType.SnappyCompression: return(_decompressor.Decompress(data, 0, n)); default: throw new InvalidDataException("bad block type"); } }
public static byte[] Decompress(this ISnappyDecompressor decompressor, byte[] src) { return(decompressor.Decompress(src, 0, src.Length)); }