ByteBuf using 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 *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
| Modifier and Type | Field and Description |
|---|---|
| private final int | |
| private ByteBuf | buffer
Inner byte buffer for outgoing data. |
| private final ByteBufChecksum | checksum
Underlying checksum calculator in use. |
| private final int | compressionLevel
Compression level of current LZ4 encoder (depends on |
| private final LZ4Compressor | compressor
Underlying compressor in use. |
| private volatile ChannelHandlerContext | ctx
Used to interact with its |
| pack-priv static final int | |
| private volatile boolean | finished
Indicates if the compressed stream has been finished. |
| private final int | maxEncodeSize
Maximum size for any buffer to write encoded (compressed) data into. |
| Access | Constructor and Description |
|---|---|
| public | Lz4FrameEncoder()
Creates the fastest LZ4 encoder with default block size (64 KB) and xxhash hashing for Java, based on Yann Collet's work available at Github. |
| public | Lz4FrameEncoder(boolean
if highCompressor)true codec will use compressor which requires more memory
and is slower but compresses more efficientlyCreates a new LZ4 encoder with hight or fast compression, default block size (64 KB) and xxhash hashing for Java, based on Yann Collet's work available at Github. |
| public | Lz4FrameEncoder(LZ4Factory
user customizable factory, boolean LZ4Factory instance
which may be JNI bindings to the original C implementation, a pure Java implementation
or a Java implementation that uses the sun.if highCompressor, int true codec will use compressor which requires more memory
and is slower but compresses more efficientlythe maximum number of bytes to try to compress at once,
must be >= 64 and <= 32 M blockSize, Checksum the checksum)Checksum instance to use to check data for integrityCreates a new customizable LZ4 encoder. |
| public | Lz4FrameEncoder(LZ4Factory
user customizable factory, boolean LZ4Factory instance
which may be JNI bindings to the original C implementation, a pure Java implementation
or a Java implementation that uses the sun.if highCompressor, int true codec will use compressor which requires more memory
and is slower but compresses more efficientlythe maximum number of bytes to try to compress at once,
must be >= 64 and <= 32 M blockSize, Checksum the checksum, int Checksum instance to use to check data for integritythe maximum size for an encode (compressed) buffer maxEncodeSize)Creates a new customizable LZ4 encoder. |
| blockSize | back to summary |
|---|---|
| private final int blockSize | |
| buffer | back to summary |
|---|---|
| private ByteBuf buffer Inner byte buffer for outgoing data. It's capacity will be | |
| checksum | back to summary |
|---|---|
| private final ByteBufChecksum checksum Underlying checksum calculator in use. | |
| compressionLevel | back to summary |
|---|---|
| private final int compressionLevel Compression level of current LZ4 encoder (depends on | |
| compressor | back to summary |
|---|---|
| private final LZ4Compressor compressor Underlying compressor in use. | |
| ctx | back to summary |
|---|---|
| private volatile ChannelHandlerContext ctx Used to interact with its | |
| DEFAULT_MAX_ENCODE_SIZE | back to summary |
|---|---|
| pack-priv static final int DEFAULT_MAX_ENCODE_SIZE | |
| finished | back to summary |
|---|---|
| private volatile boolean finished Indicates if the compressed stream has been finished. | |
| maxEncodeSize | back to summary |
|---|---|
| private final int maxEncodeSize Maximum size for any buffer to write encoded (compressed) data into. | |
| Lz4FrameEncoder | back to summary |
|---|---|
| public Lz4FrameEncoder() Creates the fastest LZ4 encoder with default block size (64 KB) and xxhash hashing for Java, based on Yann Collet's work available at Github. | |
| Lz4FrameEncoder | back to summary |
|---|---|
| public Lz4FrameEncoder(boolean highCompressor) Creates a new LZ4 encoder with hight or fast compression, default block size (64 KB) and xxhash hashing for Java, based on Yann Collet's work available at Github.
| |
| Lz4FrameEncoder | back to summary |
|---|---|
| public Lz4FrameEncoder(LZ4Factory factory, boolean highCompressor, int blockSize, Checksum checksum) Creates a new customizable LZ4 encoder.
| |
| Lz4FrameEncoder | back to summary |
|---|---|
| public Lz4FrameEncoder(LZ4Factory factory, boolean highCompressor, int blockSize, Checksum checksum, int maxEncodeSize) Creates a new customizable LZ4 encoder.
| |
| allocateBuffer | back to summary |
|---|---|
| protected ByteBuf allocateBuffer(ChannelHandlerContext ctx, ByteBuf msg, boolean preferDirect) Overrides io. Doc from io. Allocate a
| |
| allocateBuffer | back to summary |
|---|---|
| private ByteBuf allocateBuffer(ChannelHandlerContext ctx, ByteBuf msg, boolean preferDirect, boolean allowEmptyReturn) | |
| close | back to summary |
|---|---|
| public ChannelFuture close() Close this | |
| close | back to summary |
|---|---|
| public ChannelFuture close(final ChannelPromise promise) Close this | |
| close | back to summary |
|---|---|
| public void close(final ChannelHandlerContext ctx, final ChannelPromise promise) throws Exception Overrides io. Implements io. Doc from io. Calls
| |
| compressionLevel | back to summary |
|---|---|
| private static int compressionLevel(int blockSize) Calculates compression level on the basis of block size. | |
| ctx | back to summary |
|---|---|
| private ChannelHandlerContext ctx() | |
| encode | back to summary |
|---|---|
| protected void encode(ChannelHandlerContext ctx, ByteBuf in, ByteBuf out) throws Exception Implements abstract io. Doc from io. Encode a message into a
| |
| finishEncode | back to summary |
|---|---|
| private ChannelFuture finishEncode(final ChannelHandlerContext ctx, ChannelPromise promise) | |
| flush | back to summary |
|---|---|
| public void flush(final ChannelHandlerContext ctx) throws Exception Overrides io. Implements io. Doc from io. Calls
| |
| flushBufferedData | back to summary |
|---|---|
| private void flushBufferedData(ByteBuf out) | |
| getBackingBuffer | back to summary |
|---|---|
| pack-priv final ByteBuf getBackingBuffer() | |
| handlerAdded | back to summary |
|---|---|
| public void handlerAdded(ChannelHandlerContext ctx) Overrides io. Implements io. Doc from io. Gets called after the
| |
| handlerRemoved | back to summary |
|---|---|
| public void handlerRemoved(ChannelHandlerContext ctx) throws Exception Overrides io. Implements io. Doc from io. Gets called after the
| |
| isClosed | back to summary |
|---|---|
| public boolean isClosed() Returns | |