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

pack-priv final Class FastLz

extends Object
Class Inheritance
Imports
io.netty.buffer.ByteBuf

Core of FastLZ compression algorithm. This class provides methods for compression and decompression of buffers and saves constants which use by FastLzFrameEncoder and FastLzFrameDecoder. This is refactored code of jfastlz library written by William Kinney.

Field Summary

Modifier and TypeField and Description
pack-priv static final byte
pack-priv static final byte
pack-priv static final byte
pack-priv static final byte
pack-priv static final int
private static final int
private static final int
private static final int
pack-priv static final int
LEVEL_1

Level 1 is the fastest compression and generally useful for short data.

pack-priv static final int
LEVEL_2

Level 2 is slightly slower but it gives better compression ratio.

pack-priv static final int
LEVEL_AUTO

In this case compress(ByteBuf, int, int, ByteBuf, int, int) will choose level automatically depending on the length of the input buffer.

pack-priv static final int
pack-priv static final int
private static final int
private static final int
private static final int
private static final int
pack-priv static final int
MIN_LENGTH_TO_COMPRESSION

Do not call compress(ByteBuf, int, int, ByteBuf, int, int) for input buffers which length less than this value.

private static final int
pack-priv static final int

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv static int

Returns:

Maximum output buffer length
calculateOutputBufferLength
(int
length of input buffer
inputLength
)

The output buffer must be at least 6% larger than the input buffer and can not be smaller than 66 bytes.

pack-priv static int
compress(final ByteBuf input, final int inOffset, final int inLength, final ByteBuf output, final int outOffset, final int proposedLevel)

Compress a block of data in the input buffer and returns the size of compressed block.

pack-priv static int
decompress(final ByteBuf input, final int inOffset, final int inLength, final ByteBuf output, final int outOffset, final int outLength)

Decompress a block of compressed data and returns the size of the decompressed block.

private static int
hashFunction(ByteBuf p, int offset)

private static int
readU16(ByteBuf data, int offset)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

BLOCK_TYPE_COMPRESSEDback to summary
pack-priv static final byte BLOCK_TYPE_COMPRESSED
BLOCK_TYPE_NON_COMPRESSEDback to summary
pack-priv static final byte BLOCK_TYPE_NON_COMPRESSED
BLOCK_WITH_CHECKSUMback to summary
pack-priv static final byte BLOCK_WITH_CHECKSUM
BLOCK_WITHOUT_CHECKSUMback to summary
pack-priv static final byte BLOCK_WITHOUT_CHECKSUM
CHECKSUM_OFFSETback to summary
pack-priv static final int CHECKSUM_OFFSET
HASH_LOGback to summary
private static final int HASH_LOG
HASH_MASKback to summary
private static final int HASH_MASK
HASH_SIZEback to summary
private static final int HASH_SIZE
LEVEL_1back to summary
pack-priv static final int LEVEL_1

Level 1 is the fastest compression and generally useful for short data.

LEVEL_2back to summary
pack-priv static final int LEVEL_2

Level 2 is slightly slower but it gives better compression ratio.

LEVEL_AUTOback to summary
pack-priv static final int LEVEL_AUTO

In this case compress(ByteBuf, int, int, ByteBuf, int, int) will choose level automatically depending on the length of the input buffer. If length less than MIN_RECOMENDED_LENGTH_FOR_LEVEL_2 LEVEL_1 will be chosen, otherwise LEVEL_2.

MAGIC_NUMBERback to summary
pack-priv static final int MAGIC_NUMBER
MAX_CHUNK_LENGTHback to summary
pack-priv static final int MAX_CHUNK_LENGTH
MAX_COPYback to summary
private static final int MAX_COPY
MAX_DISTANCEback to summary
private static final int MAX_DISTANCE
MAX_FARDISTANCEback to summary
private static final int MAX_FARDISTANCE
MAX_LENback to summary
private static final int MAX_LEN
MIN_LENGTH_TO_COMPRESSIONback to summary
pack-priv static final int MIN_LENGTH_TO_COMPRESSION

Do not call compress(ByteBuf, int, int, ByteBuf, int, int) for input buffers which length less than this value.

MIN_RECOMENDED_LENGTH_FOR_LEVEL_2back to summary
private static final int MIN_RECOMENDED_LENGTH_FOR_LEVEL_2
OPTIONS_OFFSETback to summary
pack-priv static final int OPTIONS_OFFSET

Constructor Detail

FastLzback to summary
private FastLz()

Method Detail

calculateOutputBufferLengthback to summary
pack-priv static int calculateOutputBufferLength(int inputLength)

The output buffer must be at least 6% larger than the input buffer and can not be smaller than 66 bytes.

Parameters
inputLength:int

length of input buffer

Returns:int

Maximum output buffer length

compressback to summary
pack-priv static int compress(final ByteBuf input, final int inOffset, final int inLength, final ByteBuf output, final int outOffset, final int proposedLevel)

Compress a block of data in the input buffer and returns the size of compressed block. The size of input buffer is specified by length. The minimum input buffer size is 32. If the input is not compressible, the return value might be larger than length (input buffer size).

Annotations
@SuppressWarnings:IdentityBinaryExpression
decompressback to summary
pack-priv static int decompress(final ByteBuf input, final int inOffset, final int inLength, final ByteBuf output, final int outOffset, final int outLength)

Decompress a block of compressed data and returns the size of the decompressed block. If error occurs, e.g. the compressed data is corrupted or the output buffer is not large enough, then 0 (zero) will be returned instead. Decompression is memory safe and guaranteed not to write the output buffer more than what is specified in outLength.

hashFunctionback to summary
private static int hashFunction(ByteBuf p, int offset)
readU16back to summary
private static int readU16(ByteBuf data, int offset)