blockCompressor = new Bzip2BlockCompressor(writer, streamBlockSize); currentState = State.WRITE_DATA; final int length = Math.min(in.readableBytes(), blockCompressor.availableSize()); final int bytesWritten = blockCompressor.write(in, in.readerIndex(), length); in.skipBytes(bytesWritten); if (!blockCompressor.isFull()) { if (in.isReadable()) { break;
/** * Close current block and update {@link #streamCRC}. */ private void closeBlock(ByteBuf out) { final Bzip2BlockCompressor blockCompressor = this.blockCompressor; if (!blockCompressor.isEmpty()) { blockCompressor.close(out); final int blockCRC = blockCompressor.crc(); streamCRC = (streamCRC << 1 | streamCRC >>> 31) ^ blockCRC; } }
/** * Writes a byte to the block, accumulating to an RLE run where possible. * @param value The byte to write * @return {@code true} if the byte was written, or {@code false} if the block is already full */ boolean write(final int value) { if (blockLength > blockLengthLimit) { return false; } final int rleCurrentValue = this.rleCurrentValue; final int rleLength = this.rleLength; if (rleLength == 0) { this.rleCurrentValue = value; this.rleLength = 1; } else if (rleCurrentValue != value) { // This path commits us to write 6 bytes - one RLE run (5 bytes) plus one extra writeRun(rleCurrentValue & 0xff, rleLength); this.rleCurrentValue = value; this.rleLength = 1; } else { if (rleLength == 254) { writeRun(rleCurrentValue & 0xff, 255); this.rleLength = 0; } else { this.rleLength = rleLength + 1; } } return true; }
writeRun(rleCurrentValue & 0xff, rleLength); writeSymbolMap(out);
@Override public boolean process(byte value) throws Exception { return write(value); } };
writeRun(rleCurrentValue & 0xff, rleLength); writeSymbolMap(out);
@Override public boolean process(byte value) throws Exception { return write(value); } };
blockCompressor = new Bzip2BlockCompressor(writer, streamBlockSize); currentState = State.WRITE_DATA; final int length = Math.min(in.readableBytes(), blockCompressor.availableSize()); final int bytesWritten = blockCompressor.write(in, in.readerIndex(), length); in.skipBytes(bytesWritten); if (!blockCompressor.isFull()) { if (in.isReadable()) { break;
/** * Close current block and update {@link #streamCRC}. */ private void closeBlock(ByteBuf out) { final Bzip2BlockCompressor blockCompressor = this.blockCompressor; if (!blockCompressor.isEmpty()) { blockCompressor.close(out); final int blockCRC = blockCompressor.crc(); streamCRC = (streamCRC << 1 | streamCRC >>> 31) ^ blockCRC; } }
writeRun(rleCurrentValue & 0xff, rleLength); writeSymbolMap(out);
@Override public boolean process(byte value) throws Exception { return write(value); } };
/** * Writes a byte to the block, accumulating to an RLE run where possible. * @param value The byte to write * @return {@code true} if the byte was written, or {@code false} if the block is already full */ boolean write(final int value) { if (blockLength > blockLengthLimit) { return false; } final int rleCurrentValue = this.rleCurrentValue; final int rleLength = this.rleLength; if (rleLength == 0) { this.rleCurrentValue = value; this.rleLength = 1; } else if (rleCurrentValue != value) { // This path commits us to write 6 bytes - one RLE run (5 bytes) plus one extra writeRun(rleCurrentValue & 0xff, rleLength); this.rleCurrentValue = value; this.rleLength = 1; } else { if (rleLength == 254) { writeRun(rleCurrentValue & 0xff, 255); this.rleLength = 0; } else { this.rleLength = rleLength + 1; } } return true; }
blockCompressor = new Bzip2BlockCompressor(writer, streamBlockSize); currentState = State.WRITE_DATA; final int length = Math.min(in.readableBytes(), blockCompressor.availableSize()); final int bytesWritten = blockCompressor.write(in, in.readerIndex(), length); in.skipBytes(bytesWritten); if (!blockCompressor.isFull()) { if (in.isReadable()) { break;
/** * Close current block and update {@link #streamCRC}. */ private void closeBlock(ByteBuf out) { final Bzip2BlockCompressor blockCompressor = this.blockCompressor; if (!blockCompressor.isEmpty()) { blockCompressor.close(out); final int blockCRC = blockCompressor.crc(); streamCRC = (streamCRC << 1 | streamCRC >>> 31) ^ blockCRC; } }
writeRun(rleCurrentValue & 0xff, rleLength); writeSymbolMap(out);
@Override public boolean process(byte value) throws Exception { return write(value); } };
/** * Writes a byte to the block, accumulating to an RLE run where possible. * @param value The byte to write * @return {@code true} if the byte was written, or {@code false} if the block is already full */ boolean write(final int value) { if (blockLength > blockLengthLimit) { return false; } final int rleCurrentValue = this.rleCurrentValue; final int rleLength = this.rleLength; if (rleLength == 0) { this.rleCurrentValue = value; this.rleLength = 1; } else if (rleCurrentValue != value) { // This path commits us to write 6 bytes - one RLE run (5 bytes) plus one extra writeRun(rleCurrentValue & 0xff, rleLength); this.rleCurrentValue = value; this.rleLength = 1; } else { if (rleLength == 254) { writeRun(rleCurrentValue & 0xff, 255); this.rleLength = 0; } else { this.rleLength = rleLength + 1; } } return true; }
blockCompressor = new Bzip2BlockCompressor(writer, streamBlockSize); currentState = State.WRITE_DATA; final int length = Math.min(in.readableBytes(), blockCompressor.availableSize()); final int bytesWritten = blockCompressor.write(in, in.readerIndex(), length); in.skipBytes(bytesWritten); if (!blockCompressor.isFull()) { if (in.isReadable()) { break;
/** * Close current block and update {@link #streamCRC}. */ private void closeBlock(ByteBuf out) { final Bzip2BlockCompressor blockCompressor = this.blockCompressor; if (!blockCompressor.isEmpty()) { blockCompressor.close(out); final int blockCRC = blockCompressor.crc(); streamCRC = (streamCRC << 1 | streamCRC >>> 31) ^ blockCRC; } }
writeRun(rleCurrentValue & 0xff, rleLength); writeSymbolMap(out);