Class Lz4FrameDecoder
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.handler.codec.ByteToMessageDecoder
io.netty.handler.codec.compression.Lz4FrameDecoder
- All Implemented Interfaces:
ChannelHandler, ChannelInboundHandler
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 Class Summary
Nested classes/interfaces inherited from class ByteToMessageDecoder
ByteToMessageDecoder.CumulatorNested classes/interfaces inherited from interface ChannelHandler
ChannelHandler.Sharable -
Field Summary
Fields inherited from class ByteToMessageDecoder
COMPOSITE_CUMULATOR, MERGE_CUMULATOR -
Constructor Summary
ConstructorsConstructorDescriptionCreates the fastest LZ4 decoder.Lz4FrameDecoder(boolean validateChecksums) Creates a LZ4 decoder with fastest decoder instance available on your machine.Lz4FrameDecoder(net.jpountz.lz4.LZ4Factory factory, boolean validateChecksums) Creates a new LZ4 decoder with customizable implementation.Lz4FrameDecoder(net.jpountz.lz4.LZ4Factory factory, Checksum checksum) Creates a new customizable LZ4 decoder. -
Method Summary
Methods inherited from class ByteToMessageDecoder
actualReadableBytes, callDecode, channelInactive, channelRead, channelReadComplete, decodeLast, discardSomeReadBytes, handlerRemoved, handlerRemoved0, internalBuffer, isSingleDecode, setCumulator, setDiscardAfterReads, setSingleDecode, userEventTriggeredMethods inherited from class ChannelInboundHandlerAdapter
channelActive, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaughtMethods inherited from class ChannelHandlerAdapter
ensureNotSharable, handlerAdded, isSharableMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ChannelHandler
handlerAdded
-
Constructor Details
-
Lz4FrameDecoder
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 theLz4FrameDecoder(boolean)constructor with the argument set totrue. -
Lz4FrameDecoder
public Lz4FrameDecoder(boolean validateChecksums) Creates a LZ4 decoder with fastest decoder instance available on your machine.- Parameters:
validateChecksums- iftrue, the checksum field will be validated against the actual uncompressed data, and if the checksums do not match, a suitableDecompressionExceptionwill be thrown
-
Lz4FrameDecoder
public Lz4FrameDecoder(net.jpountz.lz4.LZ4Factory factory, boolean validateChecksums) Creates a new LZ4 decoder with customizable implementation.- Parameters:
factory- user customizableLZ4Factoryinstance which may be JNI bindings to the original C implementation, a pure Java implementation or a Java implementation that uses theUnsafevalidateChecksums- iftrue, the checksum field will be validated against the actual uncompressed data, and if the checksums do not match, a suitableDecompressionExceptionwill be thrown. In this case encoder will use xxhash hashing for Java, based on Yann Collet's work available at Github.
-
Lz4FrameDecoder
Creates a new customizable LZ4 decoder.- Parameters:
factory- user customizableLZ4Factoryinstance which may be JNI bindings to the original C implementation, a pure Java implementation or a Java implementation that uses theUnsafechecksum- theChecksuminstance to use to check data for integrity. You may setnullif you do not want to validate checksum of each block
-
-
Method Details
-
decode
Description copied from class:ByteToMessageDecoderDecode the from oneByteBufto an other. This method will be called till either the inputByteBufhas nothing to read when return from this method or till nothing was read from the inputByteBuf.- Specified by:
decodein classByteToMessageDecoder- Parameters:
ctx- theChannelHandlerContextwhich thisByteToMessageDecoderbelongs toin- theByteBuffrom which to read dataout- theListto which decoded messages should be added- Throws:
Exception- is thrown if an error occurs
-
isClosed
public boolean isClosed()Returnstrueif and only if the end of the compressed stream has been reached.
-