Class Lz4FrameEncoder

  • All Implemented Interfaces:
    ChannelHandler, ChannelOutboundHandler

    public class Lz4FrameEncoder
    extends MessageToByteEncoder<ByteBuf>
    Compresses a 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 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
    • Constructor Detail

      • Lz4FrameEncoder

        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

        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.
        Parameters:
        highCompressor - if true codec will use compressor which requires more memory and is slower but compresses more efficiently
      • Lz4FrameEncoder

        public Lz4FrameEncoder​(net.jpountz.lz4.LZ4Factory factory,
                               boolean highCompressor,
                               int blockSize,
                               java.util.zip.Checksum checksum)
        Creates a new customizable LZ4 encoder.
        Parameters:
        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
        highCompressor - if true codec will use compressor which requires more memory and is slower but compresses more efficiently
        blockSize - the maximum number of bytes to try to compress at once, must be >= 64 and <= 32 M
        checksum - the Checksum instance to use to check data for integrity
      • Lz4FrameEncoder

        public Lz4FrameEncoder​(net.jpountz.lz4.LZ4Factory factory,
                               boolean highCompressor,
                               int blockSize,
                               java.util.zip.Checksum checksum,
                               int maxEncodeSize)
        Creates a new customizable LZ4 encoder.
        Parameters:
        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
        highCompressor - if true codec will use compressor which requires more memory and is slower but compresses more efficiently
        blockSize - the maximum number of bytes to try to compress at once, must be >= 64 and <= 32 M
        checksum - the Checksum instance to use to check data for integrity
        maxEncodeSize - the maximum size for an encode (compressed) buffer