class SnappyCompress implements Compress {

    @Override
    public ByteBuf compressInput(Object proto, RpcMethodInfo rpcMethodInfo) throws IOException {
        byte[] bytes = rpcMethodInfo.inputEncode(proto);
        int maxCompressedSize = Snappy.maxCompressedLength(bytes.length);
        byte[] compressedBytes = new byte[maxCompressedSize];
        int compressedLen = Snappy.compress(bytes, 0, bytes.length, compressedBytes, 0);
        return Unpooled.wrappedBuffer(compressedBytes, 0, compressedLen);
    }

}