Home / Class/ Lz4FrameDecoder Class — netty Architecture

Lz4FrameDecoder Class — netty Architecture

Architecture documentation for the Lz4FrameDecoder class in Lz4FrameDecoder.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  2d460c23_2951_e424_21c2_a4587a5e314f["Lz4FrameDecoder"]
  736e9973_59d0_2743_c3b8_f07480c64d7a["Lz4FrameDecoder.java"]
  2d460c23_2951_e424_21c2_a4587a5e314f -->|defined in| 736e9973_59d0_2743_c3b8_f07480c64d7a
  4db6a2d8_766f_73d3_b093_8501d3efb11c["Lz4FrameDecoder()"]
  2d460c23_2951_e424_21c2_a4587a5e314f -->|method| 4db6a2d8_766f_73d3_b093_8501d3efb11c
  6c7e5e02_2ee9_ba37_521d_ac588546a856["decode()"]
  2d460c23_2951_e424_21c2_a4587a5e314f -->|method| 6c7e5e02_2ee9_ba37_521d_ac588546a856
  78141f05_d3f2_28f2_1896_6bd7c5c1d06e["isClosed()"]
  2d460c23_2951_e424_21c2_a4587a5e314f -->|method| 78141f05_d3f2_28f2_1896_6bd7c5c1d06e

Relationship Graph

Source Code

codec-compression/src/main/java/io/netty/handler/codec/compression/Lz4FrameDecoder.java lines 53–277

public class Lz4FrameDecoder extends ByteToMessageDecoder {
    /**
     * Current state of stream.
     */
    private enum State {
        INIT_BLOCK,
        DECOMPRESS_DATA,
        FINISHED,
        CORRUPTED
    }

    private State currentState = State.INIT_BLOCK;

    /**
     * Underlying decompressor in use.
     */
    private LZ4FastDecompressor decompressor;

    /**
     * Underlying checksum calculator in use.
     */
    private ByteBufChecksum checksum;

    /**
     * Type of current block.
     */
    private int blockType;

    /**
     * Compressed length of current incoming block.
     */
    private int compressedLength;

    /**
     * Decompressed length of current incoming block.
     */
    private int decompressedLength;

    /**
     * Checksum value of current incoming block.
     */
    private int currentChecksum;

    /**
     * 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 the {@link #Lz4FrameDecoder(boolean)} constructor with the argument
     * set to {@code true}.
     */
    public Lz4FrameDecoder() {
        this(false);
    }

    /**
     * Creates a LZ4 decoder with fastest decoder instance available on your machine.
     *
     * @param validateChecksums  if {@code true}, the checksum field will be validated against the actual
     *                           uncompressed data, and if the checksums do not match, a suitable
     *                           {@link DecompressionException} will be thrown
     */
    public Lz4FrameDecoder(boolean validateChecksums) {
        this(LZ4Factory.fastestInstance(), validateChecksums);
    }

    /**
     * Creates a new LZ4 decoder with customizable implementation.
     *
     * @param factory            user customizable {@link LZ4Factory} instance
     *                           which may be JNI bindings to the original C implementation, a pure Java implementation
     *                           or a Java implementation that uses the {@link sun.misc.Unsafe}
     * @param validateChecksums  if {@code true}, the checksum field will be validated against the actual
     *                           uncompressed data, and if the checksums do not match, a suitable
     *                           {@link DecompressionException} will be thrown. In this case encoder will use
     *                           xxhash hashing for Java, based on Yann Collet's work available at
     *                           <a href="https://github.com/Cyan4973/xxHash">Github</a>.
     */
    public Lz4FrameDecoder(LZ4Factory factory, boolean validateChecksums) {
        this(factory, validateChecksums ? new Lz4XXHash32(DEFAULT_SEED) : null);

Frequently Asked Questions

What is the Lz4FrameDecoder class?
Lz4FrameDecoder is a class in the netty codebase, defined in codec-compression/src/main/java/io/netty/handler/codec/compression/Lz4FrameDecoder.java.
Where is Lz4FrameDecoder defined?
Lz4FrameDecoder is defined in codec-compression/src/main/java/io/netty/handler/codec/compression/Lz4FrameDecoder.java at line 53.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free