Home / Class/ Lz4XXHash32 Class — netty Architecture

Lz4XXHash32 Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  7fa152c6_bd73_29ce_b041_59092999242f["Lz4XXHash32"]
  97e89177_79e0_9545_eb48_1285f5e71f8d["Lz4XXHash32.java"]
  7fa152c6_bd73_29ce_b041_59092999242f -->|defined in| 97e89177_79e0_9545_eb48_1285f5e71f8d
  36007a15_bbf3_00e2_4273_fb8f038d4e45["Lz4XXHash32()"]
  7fa152c6_bd73_29ce_b041_59092999242f -->|method| 36007a15_bbf3_00e2_4273_fb8f038d4e45
  788455de_7b19_3893_feef_dba8a9404d29["update()"]
  7fa152c6_bd73_29ce_b041_59092999242f -->|method| 788455de_7b19_3893_feef_dba8a9404d29
  33b2a984_fe94_131e_cf4f_01e98fd1c730["getValue()"]
  7fa152c6_bd73_29ce_b041_59092999242f -->|method| 33b2a984_fe94_131e_cf4f_01e98fd1c730
  7c40ca87_4e9d_1c12_24ea_5abdc061dd8c["reset()"]
  7fa152c6_bd73_29ce_b041_59092999242f -->|method| 7c40ca87_4e9d_1c12_24ea_5abdc061dd8c

Relationship Graph

Source Code

codec-compression/src/main/java/io/netty/handler/codec/compression/Lz4XXHash32.java lines 49–107

public final class Lz4XXHash32 extends ByteBufChecksum {

    private static final XXHash32 XXHASH32 = XXHashFactory.fastestInstance().hash32();

    private final int seed;
    private boolean used;
    private int value;

    @SuppressWarnings("WeakerAccess")
    public Lz4XXHash32(int seed) {
        this.seed = seed;
    }

    @Override
    public void update(int b) {
        throw new UnsupportedOperationException();
    }

    @Override
    public void update(byte[] b, int off, int len) {
        if (used) {
            throw new IllegalStateException();
        }
        value = XXHASH32.hash(b, off, len, seed);
        used = true;
    }

    @Override
    public void update(ByteBuf b, int off, int len) {
        if (used) {
            throw new IllegalStateException();
        }
        if (b.hasArray()) {
            value = XXHASH32.hash(b.array(), b.arrayOffset() + off, len, seed);
        } else {
            value = XXHASH32.hash(CompressionUtil.safeNioBuffer(b, off, len), seed);
        }
        used = true;
    }

    @Override
    public long getValue() {
        if (!used) {
            throw new IllegalStateException();
        }
        /*
         * If you look carefully, you'll notice that the most significant nibble
         * is being discarded; we believe this to be a bug, but this is what
         * StreamingXXHash32#asChecksum() implementation of getValue() does,
         * so we have to retain this behaviour for compatibility reasons.
         */
        return value & 0xFFFFFFFL;
    }

    @Override
    public void reset() {
        used = false;
    }
}

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free