Package smile.hash
Class MurmurHash3
java.lang.Object
smile.hash.MurmurHash3
MurmurHash is a very fast, non-cryptographic hash suitable for general hash-based
lookup. The name comes from two basic operations, multiply (MU) and rotate (R),
used in its inner loop. See http://murmurhash.googlepages.com/ for more details.
The current version is MurmurHash3, which yields a 32-bit or 128-bit hash value. When using 128-bits, the x86 and x64 versions do not produce the same values, as the algorithms are optimized for their respective platforms.
This class is adapted from Apache Cassandra.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
hash128
(ByteBuffer data, int offset, int length, long seed, long[] result) 128-bit MurmurHash3 for x64.static int
hash32
(byte[] data, int offset, int length, int seed) 32-bit MurmurHash3.static int
32-bit MurmurHash3.
-
Constructor Details
-
MurmurHash3
public MurmurHash3()
-
-
Method Details
-
hash32
32-bit MurmurHash3.- Parameters:
text
- the text string.seed
- the seed of hash code.- Returns:
- the hash code.
-
hash32
public static int hash32(byte[] data, int offset, int length, int seed) 32-bit MurmurHash3.- Parameters:
data
- the data buffer.offset
- the start offset of data in the buffer.length
- the length of data.seed
- the seed of hash code.- Returns:
- the hash code.
-
hash128
128-bit MurmurHash3 for x64. When using 128-bits, the x86 and x64 versions do not produce the same values, as the algorithms are optimized for their respective platforms.- Parameters:
data
- the data buffer.offset
- the start offset of data in the buffer.length
- the length of data.seed
- the seed of hash code.result
- the output of hash code.
-