Class Hash
- java.lang.Object
-
- org.apache.jackrabbit.oak.index.indexer.document.flatfile.analysis.utils.Hash
-
public class Hash extends Object
A hash function utility class.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static long
hash64(long x)
Calculate a 64-bit hash value from a value.static long
hash64(long x, long seed)
Calculate a 64-bit hash value from a value, using a seed.static int
reduce(int hash, int n)
Shrink the hash to a value 0..n.
-
-
-
Method Detail
-
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
-
-