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
public class Lz4FrameDecoder extends ByteToMessageDecoder
Uncompresses aByteBufencoded 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 io.netty.handler.codec.ByteToMessageDecoder
ByteToMessageDecoder.Cumulator
-
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
ChannelHandler.Sharable
-
-
Field Summary
-
Fields inherited from class io.netty.handler.codec.ByteToMessageDecoder
COMPOSITE_CUMULATOR, MERGE_CUMULATOR
-
-
Constructor Summary
Constructors Constructor Description Lz4FrameDecoder()Creates 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, java.util.zip.Checksum checksum)Creates a new customizable LZ4 decoder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddecode(ChannelHandlerContext ctx, ByteBuf in, java.util.List<java.lang.Object> out)Decode the from oneByteBufto an other.booleanisClosed()Returnstrueif and only if the end of the compressed stream has been reached.-
Methods inherited from class io.netty.handler.codec.ByteToMessageDecoder
actualReadableBytes, callDecode, channelInactive, channelRead, channelReadComplete, decodeLast, discardSomeReadBytes, handlerRemoved, handlerRemoved0, internalBuffer, isSingleDecode, setCumulator, setDiscardAfterReads, setSingleDecode, userEventTriggered
-
Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught
-
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, isSharable
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.netty.channel.ChannelHandler
handlerAdded
-
-
-
-
Constructor Detail
-
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
public Lz4FrameDecoder(net.jpountz.lz4.LZ4Factory factory, java.util.zip.Checksum checksum)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 Detail
-
decode
protected void decode(ChannelHandlerContext ctx, ByteBuf in, java.util.List<java.lang.Object> out) throws java.lang.Exception
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:
java.lang.Exception- is thrown if an error occurs
-
isClosed
public boolean isClosed()
Returnstrueif and only if the end of the compressed stream has been reached.
-
-