Class Lz4XXHash32

  • All Implemented Interfaces:
    Checksum

    public final class Lz4XXHash32
    extends Object
    A special-purpose BufferChecksum implementation for use with Lz4Compressor and Lz4Decompressor. StreamingXXHash32.asChecksum() has a particularly nasty implementation of Checksum.update(int) that allocates a single-element byte array for every invocation. In addition to that, it doesn't implement an overload that accepts a ByteBuffer as an argument. Combined, this means that we can't use ReflectiveByteBufChecksum at all, and can't use SlowByteBufChecksum because of its atrocious performance with direct byte buffers (allocating an array and making a JNI call for every byte checksummed might be considered sub-optimal by some). Block version of xxHash32 (XXHash32), however, does provide XXHash32.hash(ByteBuffer, int) method that is efficient and does exactly what we need, with a caveat that we can only invoke it once before having to reset. This, however, is fine for our purposes, given the way we use it in Lz4Compressor and Lz4Decompressor: reset(), followed by one update(), followed by getValue().
    • Constructor Detail

      • Lz4XXHash32

        public Lz4XXHash32​(int seed)