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

public Class Lz4FrameDecoder

extends ByteToMessageDecoder
Class Inheritance
Imports
io.netty.buffer.ByteBuf, io.netty.channel.ChannelHandlerContext, io.netty.handler.codec.ByteToMessageDecoder, io.netty.util.internal.ObjectUtil, net.jpountz.lz4.LZ4Exception, .LZ4Factory, .LZ4FastDecompressor, java.util.List, java.util.zip.Checksum

Uncompresses a ByteBuf encoded with the LZ4 format. See original LZ4 Github project and LZ4 block format for full description. Since the original LZ4 block format does not contains size of compressed block and size of original data this encoder uses format like LZ4 Java library written by Adrien Grand and approved by Yann Collet (author of original LZ4 library). * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Magic * Token * Compressed * Decompressed * Checksum * + * LZ4 compressed * * * * length * length * * * block * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static enum
Lz4FrameDecoder.State

Current state of stream.

Field Summary

Modifier and TypeField and Description
private int
blockType

Type of current block.

private ByteBufChecksum
checksum

Underlying checksum calculator in use.

private int
compressedLength

Compressed length of current incoming block.

private int
currentChecksum

Checksum value of current incoming block.

private Lz4FrameDecoder.State
private int
decompressedLength

Decompressed length of current incoming block.

private LZ4FastDecompressor
decompressor

Underlying decompressor in use.

Inherited from io.netty.handler.codec.ByteToMessageDecoder:
COMPOSITE_CUMULATORMERGE_CUMULATOR

Constructor Summary

AccessConstructor and Description
public
Lz4FrameDecoder()

Creates the fastest LZ4 decoder.

public
Lz4FrameDecoder(boolean
if true, the checksum field will be validated against the actual uncompressed data, and if the checksums do not match, a suitable DecompressionException will be thrown
validateChecksums
)

Creates a LZ4 decoder with fastest decoder instance available on your machine.

public
Lz4FrameDecoder(LZ4Factory
user customizable LZ4Factory instance which may be JNI bindings to the original C implementation, a pure Java implementation or a Java implementation that uses the sun.misc.Unsafe
factory
,
boolean
if true, the checksum field will be validated against the actual uncompressed data, and if the checksums do not match, a suitable DecompressionException will be thrown. In this case encoder will use xxhash hashing for Java, based on Yann Collet's work available at Github.
validateChecksums
)

Creates a new LZ4 decoder with customizable implementation.

public
Lz4FrameDecoder(LZ4Factory
user customizable LZ4Factory instance which may be JNI bindings to the original C implementation, a pure Java implementation or a Java implementation that uses the sun.misc.Unsafe
factory
,
Checksum
the Checksum instance to use to check data for integrity. You may set null if you do not want to validate checksum of each block
checksum
)

Creates a new customizable LZ4 decoder.

Method Summary

Modifier and TypeMethod and Description
protected void
decode(ChannelHandlerContext ctx, ByteBuf
the ByteBuf from which to read data
in
,
List<Object>
the List to which decoded messages should be added
out
)

Implements abstract io.netty.handler.codec.ByteToMessageDecoder.decode.

Decode the from one ByteBuf to an other.
public boolean
isClosed()

Returns true if and only if the end of the compressed stream has been reached.

Inherited from io.netty.handler.codec.ByteToMessageDecoder:
actualReadableBytescallDecodechannelInactivechannelReadchannelReadCompletedecodeLastdiscardSomeReadByteshandlerRemovedhandlerRemoved0internalBufferisSingleDecodesetCumulatorsetDiscardAfterReadssetSingleDecodeuserEventTriggered

Field Detail

blockTypeback to summary
private int blockType

Type of current block.

checksumback to summary
private ByteBufChecksum checksum

Underlying checksum calculator in use.

compressedLengthback to summary
private int compressedLength

Compressed length of current incoming block.

currentChecksumback to summary
private int currentChecksum

Checksum value of current incoming block.

currentStateback to summary
private Lz4FrameDecoder.State currentState
decompressedLengthback to summary
private int decompressedLength

Decompressed length of current incoming block.

decompressorback to summary
private LZ4FastDecompressor decompressor

Deprecated

as a consequence of LZ4FastDecompressor being deprecated. See corresponding docs for further information.

Underlying decompressor in use.

Constructor Detail

Lz4FrameDecoderback to summary
public Lz4FrameDecoder()

Creates the fastest LZ4 decoder. Note that by default, validation of the checksum header in each chunk is DISABLED for performance improvements. If performance is less of an issue, or if you would prefer the safety that checksum validation brings, please use the Lz4FrameDecoder(boolean) constructor with the argument set to true.

Lz4FrameDecoderback to summary
public Lz4FrameDecoder(boolean validateChecksums)

Creates a LZ4 decoder with fastest decoder instance available on your machine.

Parameters
validateChecksums:boolean

if true, the checksum field will be validated against the actual uncompressed data, and if the checksums do not match, a suitable DecompressionException will be thrown

Lz4FrameDecoderback to summary
public Lz4FrameDecoder(LZ4Factory factory, boolean validateChecksums)

Creates a new LZ4 decoder with customizable implementation.

Parameters
factory:LZ4Factory

user customizable LZ4Factory instance which may be JNI bindings to the original C implementation, a pure Java implementation or a Java implementation that uses the sun.misc.Unsafe

validateChecksums:boolean

if true, the checksum field will be validated against the actual uncompressed data, and if the checksums do not match, a suitable DecompressionException will be thrown. In this case encoder will use xxhash hashing for Java, based on Yann Collet's work available at Github.

Lz4FrameDecoderback to summary
public Lz4FrameDecoder(LZ4Factory factory, Checksum checksum)

Creates a new customizable LZ4 decoder.

Parameters
factory:LZ4Factory

user customizable LZ4Factory instance which may be JNI bindings to the original C implementation, a pure Java implementation or a Java implementation that uses the sun.misc.Unsafe

checksum:Checksum

the Checksum instance to use to check data for integrity. You may set null if you do not want to validate checksum of each block

Method Detail

decodeback to summary
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception

Implements abstract io.netty.handler.codec.ByteToMessageDecoder.decode.

Doc from io.netty.handler.codec.ByteToMessageDecoder.decode.

Decode the from one ByteBuf to an other. This method will be called till either the input ByteBuf has nothing to read when return from this method or till nothing was read from the input ByteBuf.

Parameters
ctx:ChannelHandlerContext

the ChannelHandlerContext which this ByteToMessageDecoder belongs to

in:ByteBuf

the ByteBuf from which to read data

out:List<Object>

the List to which decoded messages should be added

Annotations
@Override
Exceptions
Exception:
is thrown if an error occurs
isClosedback to summary
public boolean isClosed()

Returns true if and only if the end of the compressed stream has been reached.

io.netty.handler.codec.compression back to summary

private final Enum Lz4FrameDecoder.State

extends Enum<Lz4FrameDecoder.State>
Class Inheritance

Current state of stream.

Field Summary

Modifier and TypeField and Description
public static final Lz4FrameDecoder.State
public static final Lz4FrameDecoder.State
public static final Lz4FrameDecoder.State
public static final Lz4FrameDecoder.State

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Lz4FrameDecoder.State
public static Lz4FrameDecoder.State[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

CORRUPTEDback to summary
public static final Lz4FrameDecoder.State CORRUPTED
DECOMPRESS_DATAback to summary
public static final Lz4FrameDecoder.State DECOMPRESS_DATA
FINISHEDback to summary
public static final Lz4FrameDecoder.State FINISHED
INIT_BLOCKback to summary
public static final Lz4FrameDecoder.State INIT_BLOCK

Constructor Detail

Stateback to summary
private State()

Method Detail

valueOfback to summary
public static Lz4FrameDecoder.State valueOf(String name)
valuesback to summary
public static Lz4FrameDecoder.State[] values()