public class Lz4FrameDecoder extends ByteToMessageDecoder
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 *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *ByteToMessageDecoder.Cumulator
ChannelHandler.Sharable
COMPOSITE_CUMULATOR, MERGE_CUMULATOR
构造器和说明 |
---|
Lz4FrameDecoder()
Creates the fastest LZ4 decoder.
|
Lz4FrameDecoder(boolean validateChecksums)
Creates a LZ4 decoder with fastest decoder instance available on your machine.
|
Lz4FrameDecoder(LZ4Factory factory,
boolean validateChecksums)
Creates a new LZ4 decoder with customizable implementation.
|
Lz4FrameDecoder(LZ4Factory factory,
java.util.zip.Checksum checksum)
Creates a new customizable LZ4 decoder.
|
限定符和类型 | 方法和说明 |
---|---|
protected void |
decode(ChannelHandlerContext ctx,
ByteBuf in,
java.util.List<java.lang.Object> out)
Decode the from one
ByteBuf to an other. |
boolean |
isClosed()
Returns
true if and only if the end of the compressed stream
has been reached. |
actualReadableBytes, callDecode, channelInactive, channelRead, channelReadComplete, decodeLast, discardSomeReadBytes, handlerRemoved, handlerRemoved0, internalBuffer, isSingleDecode, setCumulator, setDiscardAfterReads, setSingleDecode, userEventTriggered
channelActive, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught
ensureNotSharable, handlerAdded, isSharable
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
handlerAdded
public Lz4FrameDecoder()
Lz4FrameDecoder(boolean)
constructor with the argument
set to true
.public Lz4FrameDecoder(boolean validateChecksums)
validateChecksums
- 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 thrownpublic Lz4FrameDecoder(LZ4Factory factory, boolean validateChecksums)
factory
- 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 Unsafe
validateChecksums
- 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.public Lz4FrameDecoder(LZ4Factory factory, java.util.zip.Checksum checksum)
factory
- 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 Unsafe
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 blockprotected void decode(ChannelHandlerContext ctx, ByteBuf in, java.util.List<java.lang.Object> out) throws java.lang.Exception
ByteToMessageDecoder
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
.decode
在类中 ByteToMessageDecoder
ctx
- the ChannelHandlerContext
which this ByteToMessageDecoder
belongs toin
- the ByteBuf
from which to read dataout
- the List
to which decoded messages should be addedjava.lang.Exception
- is thrown if an error occurspublic boolean isClosed()
true
if and only if the end of the compressed stream
has been reached.