@Test public void testCompressInputForJprotobuf() throws IOException { EchoRequest request = new EchoRequest(); request.setMessage("hello"); ByteBuf byteBuf = compress.compressInput(request, jprotobufRpcMethodInfo); System.out.println(byteBuf.readableBytes()); }
@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); }
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); } }
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); }  }
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); }  @Override ByteBuf compressInput(Object proto, RpcMethodInfo rpcMethodInfo); @Override Object uncompressOutput(ByteBuf byteBuf, RpcMethodInfo rpcMethodInfo); @Override Object uncompressOutput(byte[] bytes, RpcMethodInfo rpcMethodInfo); @Override Object uncompressOutput(DynamicCompositeByteBuf byteBuf, RpcMethodInfo rpcMethodInfo); @Override Object uncompressInput(ByteBuf byteBuf, RpcMethodInfo rpcMethodInfo); @Override Object uncompressInput(byte[] bytes, RpcMethodInfo rpcMethodInfo); @Override Object uncompressInput(DynamicCompositeByteBuf byteBuf, RpcMethodInfo rpcMethodInfo); @Override ByteBuf compressOutput(Object proto, RpcMethodInfo rpcMethodInfo); }
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); }  @Override ByteBuf compressInput(Object proto, RpcMethodInfo rpcMethodInfo); @Override Object uncompressOutput(ByteBuf byteBuf, RpcMethodInfo rpcMethodInfo); @Override Object uncompressOutput(byte[] bytes, RpcMethodInfo rpcMethodInfo); @Override Object uncompressOutput(DynamicCompositeByteBuf byteBuf, RpcMethodInfo rpcMethodInfo); @Override Object uncompressInput(ByteBuf byteBuf, RpcMethodInfo rpcMethodInfo); @Override Object uncompressInput(byte[] bytes, RpcMethodInfo rpcMethodInfo); @Override Object uncompressInput(DynamicCompositeByteBuf byteBuf, RpcMethodInfo rpcMethodInfo); @Override ByteBuf compressOutput(Object proto, RpcMethodInfo rpcMethodInfo);  }