@Override protected void encode(ChannelHandlerContext ctx, ByteBuf in, ByteBuf out) throws Exception { final int length = in.readableBytes(); final int idx = in.readerIndex(); final byte[] input; final int inputPtr; if (in.hasArray()) { input = in.array(); inputPtr = in.arrayOffset() + idx; } else { input = recycler.allocInputBuffer(length); in.getBytes(idx, input, 0, length); inputPtr = 0; } final int maxOutputLength = LZFEncoder.estimateMaxWorkspaceSize(length); out.ensureWritable(maxOutputLength); final byte[] output = out.array(); final int outputPtr = out.arrayOffset() + out.writerIndex(); final int outputLength = LZFEncoder.appendEncoded(encoder, input, inputPtr, length, output, outputPtr) - outputPtr; out.writerIndex(out.writerIndex() + outputLength); in.skipBytes(length); if (!in.hasArray()) { recycler.releaseInputBuffer(input); } } }
@Override protected void encode(ChannelHandlerContext ctx, ByteBuf in, ByteBuf out) throws Exception { final int length = in.readableBytes(); final int idx = in.readerIndex(); final byte[] input; final int inputPtr; if (in.hasArray()) { input = in.array(); inputPtr = in.arrayOffset() + idx; } else { input = recycler.allocInputBuffer(length); in.getBytes(idx, input, 0, length); inputPtr = 0; } final int maxOutputLength = LZFEncoder.estimateMaxWorkspaceSize(length); out.ensureWritable(maxOutputLength); final byte[] output = out.array(); final int outputPtr = out.arrayOffset() + out.writerIndex(); final int outputLength = LZFEncoder.appendEncoded(encoder, input, inputPtr, length, output, outputPtr) - outputPtr; out.writerIndex(out.writerIndex() + outputLength); in.skipBytes(length); if (!in.hasArray()) { recycler.releaseInputBuffer(input); } } }
inPos = in.arrayOffset() + idx; } else { inputArray = recycler.allocInputBuffer(chunkLength); in.getBytes(idx, inputArray, 0, chunkLength); inPos = 0;
@Override protected void encode(ChannelHandlerContext ctx, ByteBuf in, ByteBuf out) throws Exception { final int length = in.readableBytes(); final int idx = in.readerIndex(); final byte[] input; final int inputPtr; if (in.hasArray()) { input = in.array(); inputPtr = in.arrayOffset() + idx; } else { input = recycler.allocInputBuffer(length); in.getBytes(idx, input, 0, length); inputPtr = 0; } final int maxOutputLength = LZFEncoder.estimateMaxWorkspaceSize(length); out.ensureWritable(maxOutputLength); final byte[] output = out.array(); final int outputPtr = out.arrayOffset() + out.writerIndex(); final int outputLength = LZFEncoder.appendEncoded(encoder, input, inputPtr, length, output, outputPtr) - outputPtr; out.writerIndex(out.writerIndex() + outputLength); in.skipBytes(length); if (!in.hasArray()) { recycler.releaseInputBuffer(input); } } }
inPos = in.arrayOffset() + idx; } else { inputArray = recycler.allocInputBuffer(chunkLength); in.getBytes(idx, inputArray, 0, chunkLength); inPos = 0;
inPos = in.arrayOffset() + idx; } else { inputArray = recycler.allocInputBuffer(chunkLength); in.getBytes(idx, inputArray, 0, chunkLength); inPos = 0;
public LZFInputStream(final ChunkDecoder decoder, final InputStream in, final BufferRecycler bufferRecycler, boolean fullReads) throws IOException { super(); _decoder = decoder; _recycler = bufferRecycler; _inputStream = in; _inputStreamClosed = false; _cfgFullReads = fullReads; _inputBuffer = bufferRecycler.allocInputBuffer(LZFChunk.MAX_CHUNK_LEN); _decodedBytes = bufferRecycler.allocDecodeBuffer(LZFChunk.MAX_CHUNK_LEN); }
public LZFCompressingInputStream(final ChunkEncoder encoder, InputStream in, BufferRecycler bufferRecycler) { // may be passed by caller, or could be null _encoder = encoder; _inputStream = in; if (bufferRecycler==null) { bufferRecycler = (encoder!=null) ? _encoder._recycler : BufferRecycler.instance(); } _recycler = bufferRecycler; _inputBuffer = bufferRecycler.allocInputBuffer(LZFChunk.MAX_CHUNK_LEN); // let's not yet allocate encoding buffer; don't know optimal size }
public LZFInputStream(final ChunkDecoder decoder, final InputStream in, final BufferRecycler bufferRecycler, boolean fullReads) throws IOException { super(); _decoder = decoder; _recycler = bufferRecycler; _inputStream = in; _inputStreamClosed = false; _cfgFullReads = fullReads; _inputBuffer = bufferRecycler.allocInputBuffer(LZFChunk.MAX_CHUNK_LEN); _decodedBytes = bufferRecycler.allocDecodeBuffer(LZFChunk.MAX_CHUNK_LEN); }
public LZFInputStream(final ChunkDecoder decoder, final InputStream in, final BufferRecycler bufferRecycler, boolean fullReads) throws IOException { super(); _decoder = decoder; _recycler = bufferRecycler; _inputStream = in; _inputStreamClosed = false; _cfgFullReads = fullReads; _inputBuffer = bufferRecycler.allocInputBuffer(LZFChunk.MAX_CHUNK_LEN); _decodedBytes = bufferRecycler.allocDecodeBuffer(LZFChunk.MAX_CHUNK_LEN); }
public LZFCompressingInputStream(final ChunkEncoder encoder, InputStream in, BufferRecycler bufferRecycler) { // may be passed by caller, or could be null _encoder = encoder; _inputStream = in; if (bufferRecycler==null) { bufferRecycler = (encoder!=null) ? _encoder._recycler : BufferRecycler.instance(); } _recycler = bufferRecycler; _inputBuffer = bufferRecycler.allocInputBuffer(LZFChunk.MAX_CHUNK_LEN); // let's not yet allocate encoding buffer; don't know optimal size }
public LZFFileInputStream(FileDescriptor fdObj, ChunkDecoder decompressor, BufferRecycler bufferRecycler) { super(fdObj); _decompressor = decompressor; _recycler = bufferRecycler; _inputStreamClosed = false; _inputBuffer = bufferRecycler.allocInputBuffer(LZFChunk.MAX_CHUNK_LEN); _decodedBytes = bufferRecycler.allocDecodeBuffer(LZFChunk.MAX_CHUNK_LEN); _wrapper = new Wrapper(); }
public LZFFileInputStream(FileDescriptor fdObj, ChunkDecoder decompressor, BufferRecycler bufferRecycler) { super(fdObj); _decompressor = decompressor; _recycler = bufferRecycler; _inputStreamClosed = false; _inputBuffer = bufferRecycler.allocInputBuffer(LZFChunk.MAX_CHUNK_LEN); _decodedBytes = bufferRecycler.allocDecodeBuffer(LZFChunk.MAX_CHUNK_LEN); _wrapper = new Wrapper(); }
public LZFFileInputStream(File file, ChunkDecoder decompressor, BufferRecycler bufferRecycler) throws FileNotFoundException { super(file); _decompressor = decompressor; _recycler = bufferRecycler; _inputStreamClosed = false; _inputBuffer = bufferRecycler.allocInputBuffer(LZFChunk.MAX_CHUNK_LEN); _decodedBytes = bufferRecycler.allocDecodeBuffer(LZFChunk.MAX_CHUNK_LEN); _wrapper = new Wrapper(); }
public LZFFileInputStream(String name, ChunkDecoder decompressor, BufferRecycler bufferRecycler) throws FileNotFoundException { super(name); _decompressor = decompressor; _recycler = bufferRecycler; _inputStreamClosed = false; _inputBuffer = bufferRecycler.allocInputBuffer(LZFChunk.MAX_CHUNK_LEN); _decodedBytes = bufferRecycler.allocDecodeBuffer(LZFChunk.MAX_CHUNK_LEN); _wrapper = new Wrapper(); }
public LZFFileInputStream(String name, ChunkDecoder decompressor, BufferRecycler bufferRecycler) throws FileNotFoundException { super(name); _decompressor = decompressor; _recycler = bufferRecycler; _inputStreamClosed = false; _inputBuffer = bufferRecycler.allocInputBuffer(LZFChunk.MAX_CHUNK_LEN); _decodedBytes = bufferRecycler.allocDecodeBuffer(LZFChunk.MAX_CHUNK_LEN); _wrapper = new Wrapper(); }
public LZFFileInputStream(File file, ChunkDecoder decompressor, BufferRecycler bufferRecycler) throws FileNotFoundException { super(file); _decompressor = decompressor; _recycler = bufferRecycler; _inputStreamClosed = false; _inputBuffer = bufferRecycler.allocInputBuffer(LZFChunk.MAX_CHUNK_LEN); _decodedBytes = bufferRecycler.allocDecodeBuffer(LZFChunk.MAX_CHUNK_LEN); _wrapper = new Wrapper(); }
public LZFFileInputStream(String name, ChunkDecoder decompressor, BufferRecycler bufferRecycler) throws FileNotFoundException { super(name); _decompressor = decompressor; _recycler = bufferRecycler; _inputStreamClosed = false; _inputBuffer = bufferRecycler.allocInputBuffer(LZFChunk.MAX_CHUNK_LEN); _decodedBytes = bufferRecycler.allocDecodeBuffer(LZFChunk.MAX_CHUNK_LEN); _wrapper = new Wrapper(); }
public LZFCompressedStreamInput(StreamInput in, ChunkDecoder decoder) throws IOException { super(in); this.recycler = BufferRecycler.instance(); this.decoder = decoder; this.uncompressed = recycler.allocDecodeBuffer(LZFChunk.MAX_CHUNK_LEN); this.inputBuffer = recycler.allocInputBuffer(LZFChunk.MAX_CHUNK_LEN); }
public LZFFileInputStream(File file, ChunkDecoder decompressor, BufferRecycler bufferRecycler) throws FileNotFoundException { super(file); _decompressor = decompressor; _recycler = bufferRecycler; _inputStreamClosed = false; _inputBuffer = bufferRecycler.allocInputBuffer(LZFChunk.MAX_CHUNK_LEN); _decodedBytes = bufferRecycler.allocDecodeBuffer(LZFChunk.MAX_CHUNK_LEN); _wrapper = new Wrapper(); }