Package net.jpountz.xxhash
Class StreamingXXHash64
java.lang.Object
net.jpountz.xxhash.StreamingXXHash64
- All Implemented Interfaces:
Closeable,AutoCloseable
Streaming interface for
XXHash64.
This API is compatible with the block API and the following
code samples are equivalent:
long hash(XXHashFactory xxhashFactory, byte[] buf, int off, int len, long seed) {
return xxhashFactory.hash64().hash(buf, off, len, seed);
}
long hash(XXHashFactory xxhashFactory, byte[] buf, int off, int len, long seed) {
StreamingXXHash64 sh64 = xxhashFactory.newStreamingHash64(seed);
sh64.update(buf, off, len);
return sh64.getValue();
}
Instances of this class are not thread-safe.
-
Method Summary
Modifier and TypeMethodDescriptionfinal ChecksumReturns aChecksumview of this instance.voidclose()Releases any system resources associated with this instance.abstract longgetValue()Returns the value of the checksum.abstract voidreset()Resets this instance to the state it had right after instantiation.toString()abstract voidupdate(byte[] buf, int off, int len) Updates the value of the hash with buf[off:off+len].
-
Method Details
-
getValue
public abstract long 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 dataoff- the start offset in buflen- 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:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
toString
-
asChecksum
Returns aChecksumview of this instance. Modifications to the view will modify this instance too and vice-versa.- Returns:
- the
Checksumobject representing this instance
-