Class HashUtils
- java.lang.Object
-
- org.apache.jackrabbit.oak.commons.collections.HashUtils
-
public class HashUtils extends Object
A hash function utility class.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static longhash64(long x)Calculate a 64-bit hash value from a value.static longhash64(long x, long seed)Calculate a 64-bit hash value from a value, using a seed.static longhash64(String s)Calculate a 64-bit hash value from a string.static intreduce(int hash, int n)Shrink the hash to a value 0..n.
-
-
-
Method Detail
-
hash64
public static long hash64(String s)
Calculate a 64-bit hash value from a string.- Parameters:
s- the string- Returns:
- the hash value
-
hash64
public static long hash64(long x, long seed)Calculate a 64-bit hash value from a value, using a seed. The current algorithm used the finalizer of the MurmurHash3 hash function, but callers shouldn't rely on that.- Parameters:
x- the valueseed- the seed- Returns:
- the hash value
-
hash64
public static long hash64(long x)
Calculate a 64-bit hash value from a value. The input is a 64-bit value and the output is a 64-bit values. Two different inputs are never mapped to the same output. The operation is reversible.- Parameters:
x- the value- Returns:
- the hash value
-
reduce
public static int reduce(int hash, int n)Shrink the hash to a value 0..n. Kind of like modulo, but using multiplication and shift, which are faster to compute.- Parameters:
hash- the hashn- the maximum of the result- Returns:
- the reduced value
-
-