Class StreamingXXHash32

java.lang.Object
net.jpountz.xxhash.StreamingXXHash32
All Implemented Interfaces:
Closeable, AutoCloseable

public abstract class StreamingXXHash32 extends Object implements Closeable
Streaming interface for XXHash32.

This API is compatible with the block API and the following code samples are equivalent:

   int hash(XXHashFactory xxhashFactory, byte[] buf, int off, int len, int seed) {
     return xxhashFactory.hash32().hash(buf, off, len, seed);
   }
 
   int hash(XXHashFactory xxhashFactory, byte[] buf, int off, int len, int seed) {
     StreamingXXHash32 sh32 = xxhashFactory.newStreamingHash32(seed);
     sh32.update(buf, off, len);
     return sh32.getValue();
   }
 

Instances of this class are not thread-safe.

  • Method Summary

    Modifier and Type
    Method
    Description
    final Checksum
    Returns a Checksum view of this instance.
    void
    Releases any system resources associated with this instance.
    abstract int
    Returns the value of the checksum.
    abstract void
    Resets this instance to the state it had right after instantiation.
     
    abstract void
    update(byte[] buf, int off, int len)
    Updates the value of the hash with buf[off:off+len].

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Method Details

    • getValue

      public abstract int getValue()
      Returns the value of the checksum.
      Returns:
      the checksum
    • update

      public abstract void update(byte[] buf, int off, int len)
      Updates the value of the hash with buf[off:off+len].
      Parameters:
      buf - the input data
      off - the start offset in buf
      len - the number of bytes to hash
    • reset

      public abstract void reset()
      Resets this instance to the state it had right after instantiation. The seed remains unchanged.
    • close

      public void close()
      Releases any system resources associated with this instance. It is not mandatory to call this method after using this instance because the system resources are released anyway when this instance is reclaimed by GC.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • asChecksum

      public final Checksum asChecksum()
      Returns a Checksum view of this instance. Modifications to the view will modify this instance too and vice-versa.
      Returns:
      the Checksum object representing this instance