Class XXHash
- java.lang.Object
-
- org.lwjgl.util.xxhash.XXHash
-
public class XXHash extends java.lang.Object
Native bindings to xxhash.xxHash is an extremely fast Hash algorithm, running at RAM speed limits. It also successfully passes all tests from the SMHasher suite.
-
-
Field Summary
Fields Modifier and Type Field and Description static int
XXH_ERROR
XXH_OKError codes.static int
XXH_VERSION_MAJOR
The major version number.static int
XXH_VERSION_MINOR
The minor version number.static int
XXH_VERSION_NUMBER
The version numberstatic int
XXH_VERSION_RELEASE
The release version number.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static void
XXH32_canonicalFromHash(XXH32Canonical dst, int hash)
Default result type for XXH functions are primitive unsigned 32 and 64 bits.static long
XXH32_createState()
Creates memory forXXH32_state_t
.static int
XXH32_digest(long statePtr)
Returns the final 32-bits hash of the specifiedXXH32_state_t
.static int
XXH32_freeState(long statePtr)
Frees the specifiedXXH32_state_t
.static int
XXH32_hashFromCanonical(XXH32Canonical src)
Transforms the specified canonical representation to a primitive value.static int
XXH32_reset(long statePtr, int seed)
Resets the specifiedXXH32_state_t
.static int
XXH32_update(long statePtr, java.nio.ByteBuffer input)
Calculates the xxHash of an input provided in multiple segments, as opposed to provided as a single block.static int
XXH32(java.nio.ByteBuffer input, int seed)
Calculates the 32-bits hash of sequencelength
bytes stored at memory addressinput
.static void
XXH64_canonicalFromHash(XXH64Canonical dst, long hash)
64-bit version of32_canonicalFromHash
.static long
XXH64_createState()
64-bit version of32_createState
.static long
XXH64_digest(long statePtr)
64-bit version of32_digest
.static int
XXH64_freeState(long statePtr)
64-bit version of32_freeState
.static long
XXH64_hashFromCanonical(XXH64Canonical src)
64-bit version of32_hashFromCanonical
.static int
XXH64_reset(long statePtr, long seed)
64-bit version of32_reset
.static int
XXH64_update(long statePtr, java.nio.ByteBuffer input)
64-bit version of32_update
.static long
XXH64(java.nio.ByteBuffer input, long seed)
64-bit version of32
.
-
-
-
Field Detail
-
XXH_OK
public static final int XXH_OK
Error codes.- See Also:
- Constant Field Values
-
XXH_ERROR
public static final int XXH_ERROR
Error codes.- See Also:
- Constant Field Values
-
XXH_VERSION_MAJOR
public static final int XXH_VERSION_MAJOR
The major version number.- See Also:
- Constant Field Values
-
XXH_VERSION_MINOR
public static final int XXH_VERSION_MINOR
The minor version number.- See Also:
- Constant Field Values
-
XXH_VERSION_RELEASE
public static final int XXH_VERSION_RELEASE
The release version number.- See Also:
- Constant Field Values
-
XXH_VERSION_NUMBER
public static final int XXH_VERSION_NUMBER
The version number- See Also:
- Constant Field Values
-
-
Method Detail
-
XXH32
public static int XXH32(java.nio.ByteBuffer input, int seed)
Calculates the 32-bits hash of sequencelength
bytes stored at memory addressinput
.- Parameters:
input
- the bytes to hash. The memory betweeninput
&input+length
must be valid (allocated and read-accessible).seed
- the seed that can be used to alter the result predictably
-
XXH64
public static long XXH64(java.nio.ByteBuffer input, long seed)
64-bit version of32
.This function runs faster on 64-bits systems, but slower on 32-bits systems.
- Parameters:
input
- the bytes to hash. The memory betweeninput
&input+length
must be valid (allocated and read-accessible).seed
- the seed that can be used to alter the result predictably
-
XXH32_createState
public static long XXH32_createState()
Creates memory forXXH32_state_t
. The state must then be initialized using32_reset
before first use.LWJGL note: This function simply delegates to the system
malloc()
function.
-
XXH32_freeState
public static int XXH32_freeState(long statePtr)
Frees the specifiedXXH32_state_t
.- Parameters:
statePtr
- the state to free
-
XXH64_createState
public static long XXH64_createState()
64-bit version of32_createState
.
-
XXH64_freeState
public static int XXH64_freeState(long statePtr)
64-bit version of32_freeState
.- Parameters:
statePtr
- the state to free
-
XXH32_reset
public static int XXH32_reset(long statePtr, int seed)
Resets the specifiedXXH32_state_t
.- Parameters:
statePtr
- theXXH32_state_t
to resetseed
- the seed that can be used to alter the hashing result predictably
-
XXH32_update
public static int XXH32_update(long statePtr, java.nio.ByteBuffer input)
Calculates the xxHash of an input provided in multiple segments, as opposed to provided as a single block.XXH state must first be allocated.
Start a new hash by initializing state with a seed, using
32_reset
.Then, feed the hash state by calling
32_update
as many times as necessary. Obviously, input must be valid, hence allocated and read accessible. The function returns an error code, with 0 meaning OK, and any other value meaning there is an error.Finally, a hash value can be produced anytime, by using
32_digest
. This function returns the 32-bits hash as an int.It's still possible to continue inserting input into the hash state after a digest, and later on generate some new hashes, by calling again
32_digest
.When done, free XXH state space.
- Parameters:
statePtr
- theXXH32_state_t
to useinput
- the bytes to hash. The memory betweeninput
&input+length
must be valid (allocated and read-accessible).
-
XXH32_digest
public static int XXH32_digest(long statePtr)
Returns the final 32-bits hash of the specifiedXXH32_state_t
.- Parameters:
statePtr
- theXXH32_state_t
to use
-
XXH64_reset
public static int XXH64_reset(long statePtr, long seed)
64-bit version of32_reset
.- Parameters:
statePtr
- theXXH64_state_t
to resetseed
- the seed that can be used to alter the hashing result predictably
-
XXH64_update
public static int XXH64_update(long statePtr, java.nio.ByteBuffer input)
64-bit version of32_update
.- Parameters:
statePtr
- theXXH64_state_t
to useinput
- the bytes to hash. The memory betweeninput
&input+length
must be valid (allocated and read-accessible).
-
XXH64_digest
public static long XXH64_digest(long statePtr)
64-bit version of32_digest
.- Parameters:
statePtr
- theXXH64_state_t
to use
-
XXH32_canonicalFromHash
public static void XXH32_canonicalFromHash(XXH32Canonical dst, int hash)
Default result type for XXH functions are primitive unsigned 32 and 64 bits.The canonical representation uses human-readable write convention, aka big-endian (large digits first). These functions allow transformation of hash result into and from its canonical format. This way, hash values can be written into a file / memory, and remain comparable on different systems and programs.
- Parameters:
dst
- the destination canonical representationhash
- the source hash
-
XXH64_canonicalFromHash
public static void XXH64_canonicalFromHash(XXH64Canonical dst, long hash)
64-bit version of32_canonicalFromHash
.- Parameters:
dst
- the destination canonical representationhash
- the source hash
-
XXH32_hashFromCanonical
public static int XXH32_hashFromCanonical(XXH32Canonical src)
Transforms the specified canonical representation to a primitive value.- Parameters:
src
- the source canonical representation
-
XXH64_hashFromCanonical
public static long XXH64_hashFromCanonical(XXH64Canonical src)
64-bit version of32_hashFromCanonical
.- Parameters:
src
- the source canonical representation
-
-