@Override public Object decode(ByteBuf buf, State state) throws IOException { ByteBuf out = ByteBufAllocator.DEFAULT.buffer(); try { while (buf.isReadable()) { int chunkSize = buf.readInt(); ByteBuf chunk = buf.readSlice(chunkSize); snappyDecoder.get().decode(chunk, out); snappyDecoder.get().reset(); } return innerCodec.getValueDecoder().decode(out, state); } finally { snappyDecoder.get().reset(); out.release(); } } };
@Override public Object decode(ByteBuf buf, State state) throws IOException { ByteBuf out = ByteBufAllocator.DEFAULT.buffer(); try { while (buf.isReadable()) { int chunkSize = buf.readInt(); ByteBuf chunk = buf.readSlice(chunkSize); snappyDecoder.get().decode(chunk, out); snappyDecoder.get().reset(); } return innerCodec.getValueDecoder().decode(out, state); } finally { snappyDecoder.get().reset(); out.release(); } } };
@Override public ByteBuf encode(Object in) throws IOException { ByteBuf buf = innerCodec.getValueEncoder().encode(in); ByteBuf out = ByteBufAllocator.DEFAULT.buffer(); try { int chunksAmount = (int)Math.ceil(buf.readableBytes() / (double)Short.MAX_VALUE); for (int i = 1; i <= chunksAmount; i++) { int chunkSize = Math.min(Short.MAX_VALUE, buf.readableBytes()); ByteBuf chunk = buf.readSlice(chunkSize); int lenIndex = out.writerIndex(); out.writeInt(0); snappyEncoder.get().encode(chunk, out, chunk.readableBytes()); int compressedDataLength = out.writerIndex() - 4 - lenIndex; out.setInt(lenIndex, compressedDataLength); } return out; } finally { buf.release(); snappyEncoder.get().reset(); } } };
@Override public ByteBuf encode(Object in) throws IOException { ByteBuf buf = innerCodec.getValueEncoder().encode(in); ByteBuf out = ByteBufAllocator.DEFAULT.buffer(); try { int chunksAmount = (int)Math.ceil(buf.readableBytes() / (double)Short.MAX_VALUE); for (int i = 1; i <= chunksAmount; i++) { int chunkSize = Math.min(Short.MAX_VALUE, buf.readableBytes()); ByteBuf chunk = buf.readSlice(chunkSize); int lenIndex = out.writerIndex(); out.writeInt(0); snappyEncoder.get().encode(chunk, out, chunk.readableBytes()); int compressedDataLength = out.writerIndex() - 4 - lenIndex; out.setInt(lenIndex, compressedDataLength); } return out; } finally { buf.release(); snappyEncoder.get().reset(); } } };
snappy.reset(); break;
snappy.reset(); break;
snappy.reset(); break;
@Override public Object decode(ByteBuf buf, State state) throws IOException { ByteBuf out = ByteBufAllocator.DEFAULT.buffer(); try { while (buf.isReadable()) { int chunkSize = buf.readInt(); ByteBuf chunk = buf.readSlice(chunkSize); snappyDecoder.get().decode(chunk, out); snappyDecoder.get().reset(); } return innerCodec.getValueDecoder().decode(out, state); } finally { snappyDecoder.get().reset(); out.release(); } } };
@Override public ByteBuf encode(Object in) throws IOException { ByteBuf buf = innerCodec.getValueEncoder().encode(in); ByteBuf out = ByteBufAllocator.DEFAULT.buffer(); try { int chunksAmount = (int)Math.ceil(buf.readableBytes() / (double)Short.MAX_VALUE); for (int i = 1; i <= chunksAmount; i++) { int chunkSize = Math.min(Short.MAX_VALUE, buf.readableBytes()); ByteBuf chunk = buf.readSlice(chunkSize); int lenIndex = out.writerIndex(); out.writeInt(0); snappyEncoder.get().encode(chunk, out, chunk.readableBytes()); int compressedDataLength = out.writerIndex() - 4 - lenIndex; out.setInt(lenIndex, compressedDataLength); } return out; } finally { buf.release(); snappyEncoder.get().reset(); } } };
snappy.reset(); break;
snappy.reset(); break;
snappy.reset(); break;
snappy.reset(); break;