Top Description Fields Constructors Methods
io.netty5.handler.codec.compression

pack-priv final Class Bzip2BlockCompressor

extends Object
Class Inheritance
Imports
io.netty5.buffer.Buffer, io.netty5.util.ByteProcessor

Compresses and writes a single Bzip2 block.

Block encoding consists of the following stages:
1. Run-Length Encoding[1] - write(int)
2. Burrows Wheeler Transform - close(Buffer) (through Bzip2DivSufSort)
3. Write block header - close(Buffer)
4. Move To Front Transform - close(Buffer) (through Bzip2HuffmanStageEncoder)
5. Run-Length Encoding[2] - close(Buffer) (through Bzip2HuffmanStageEncoder)
6. Create and write Huffman tables - close(Buffer) (through Bzip2HuffmanStageEncoder)
7. Huffman encode and write data - close(Buffer) (through Bzip2HuffmanStageEncoder)

Field Summary

Modifier and TypeField and Description
private final byte[]
block

The RLE'd block data.

private int
blockLength

Current length of the data within the block array.

private final int
blockLengthLimit

A limit beyond which new data will not be accepted into the block.

private final boolean[]
blockValuesPresent

The values that are present within the RLE'd block data.

private final int[]
bwtBlock

The Burrows Wheeler Transformed block data.

private final Crc32
crc

CRC builder for the block.

private int
rleCurrentValue

The current RLE value being accumulated (undefined when rleLength is 0).

private int
rleLength

The repeat count of the current RLE value.

private final ByteProcessor
private final Bzip2BitWriter
writer

A writer that provides bit-level writes.

Constructor Summary

AccessConstructor and Description
pack-priv
Bzip2BlockCompressor(final Bzip2BitWriter
The Bzip2BitWriter which provides bit-level writes
writer
,
final int
The declared block size in bytes. Up to this many bytes will be accepted into the block after Run-Length Encoding is applied
blockSize
)

Method Summary

Modifier and TypeMethod and Description
pack-priv int

Returns:

Number of available bytes which can be written
availableSize
()

Gets available size of the current block.

pack-priv void
close(Buffer out)

Compresses and writes out the block.

pack-priv int

Returns:

The block's CRC
crc
()

Gets the CRC of the completed block.

pack-priv boolean

Returns:

true if one or more bytes has been written to the block, otherwise false
isEmpty
()

Determines if any bytes have been written to the block.

pack-priv boolean

Returns:

true if the block is full, otherwise false
isFull
()

Determines if the block is full and ready for compression.

pack-priv boolean

Returns:

true if the byte was written, or false if the block is already full
write
(final int
The byte to write
value
)

Writes a byte to the block, accumulating to an RLE run where possible.

pack-priv int

Returns:

The actual number of input bytes written. May be less than the number requested, or zero if the block is already full
write
(final Buffer
The buffer to write
buffer
,
int
The offset within the input data to write from
offset
,
int
The number of bytes of input data to write
length
)

Writes an array to the block.

private void
writeRun(final int
The value to write
value
,
int
The run length of the value to write
runLength
)

Writes an RLE run to the block array, updating the block CRC and present values array as required.

private void
writeSymbolMap(Buffer out)

Write the Huffman symbol to output byte map.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

blockback to summary
private final byte[] block

The RLE'd block data.

blockLengthback to summary
private int blockLength

Current length of the data within the block array.

blockLengthLimitback to summary
private final int blockLengthLimit

A limit beyond which new data will not be accepted into the block.

blockValuesPresentback to summary
private final boolean[] blockValuesPresent

The values that are present within the RLE'd block data. For each index, true if that value is present within the data, otherwise false.

bwtBlockback to summary
private final int[] bwtBlock

The Burrows Wheeler Transformed block data.

crcback to summary
private final Crc32 crc

CRC builder for the block.

rleCurrentValueback to summary
private int rleCurrentValue

The current RLE value being accumulated (undefined when rleLength is 0).

rleLengthback to summary
private int rleLength

The repeat count of the current RLE value.

writeProcessorback to summary
private final ByteProcessor writeProcessor
writerback to summary
private final Bzip2BitWriter writer

A writer that provides bit-level writes.

Constructor Detail

Bzip2BlockCompressorback to summary
pack-priv Bzip2BlockCompressor(final Bzip2BitWriter writer, final int blockSize)
Parameters
writer:Bzip2BitWriter

The Bzip2BitWriter which provides bit-level writes

blockSize:int

The declared block size in bytes. Up to this many bytes will be accepted into the block after Run-Length Encoding is applied

Method Detail

availableSizeback to summary
pack-priv int availableSize()

Gets available size of the current block.

Returns:int

Number of available bytes which can be written

closeback to summary
pack-priv void close(Buffer out)

Compresses and writes out the block.

crcback to summary
pack-priv int crc()

Gets the CRC of the completed block. Only valid after calling close(Buffer).

Returns:int

The block's CRC

isEmptyback to summary
pack-priv boolean isEmpty()

Determines if any bytes have been written to the block.

Returns:boolean

true if one or more bytes has been written to the block, otherwise false

isFullback to summary
pack-priv boolean isFull()

Determines if the block is full and ready for compression.

Returns:boolean

true if the block is full, otherwise false

writeback to summary
pack-priv boolean write(final int value)

Writes a byte to the block, accumulating to an RLE run where possible.

Parameters
value:int

The byte to write

Returns:boolean

true if the byte was written, or false if the block is already full

writeback to summary
pack-priv int write(final Buffer buffer, int offset, int length)

Writes an array to the block.

Parameters
buffer:Buffer

The buffer to write

offset:int

The offset within the input data to write from

length:int

The number of bytes of input data to write

Returns:int

The actual number of input bytes written. May be less than the number requested, or zero if the block is already full

writeRunback to summary
private void writeRun(final int value, int runLength)

Writes an RLE run to the block array, updating the block CRC and present values array as required.

Parameters
value:int

The value to write

runLength:int

The run length of the value to write

writeSymbolMapback to summary
private void writeSymbolMap(Buffer out)

Write the Huffman symbol to output byte map.