Package com.google.common.hash
Class Murmur3_32HashFunction
java.lang.Object
com.google.common.hash.AbstractHashFunction
com.google.common.hash.Murmur3_32HashFunction
- All Implemented Interfaces:
HashFunction,Serializable
See MurmurHash3_x86_32 in the C++
implementation.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intprivate static final intprivate static final int(package private) static final HashFunction(package private) static final HashFunction(package private) static final HashFunctionprivate final intprivate static final longprivate final boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintbits()Returns the number of bits (a multiple of 32) that each hash code produced by this hash function has.private static longcharToThreeUtf8Bytes(char c) private static longcharToTwoUtf8Bytes(char c) private static longcodePointToFourUtf8Bytes(int codePoint) booleanprivate static HashCodefmix(int h1, int length) private static intgetIntLittleEndian(byte[] input, int offset) hashBytes(byte[] input, int off, int len) Shortcut fornewHasher().putBytes(input, off, len).hash().inthashCode()hashInt(int input) Shortcut fornewHasher().putInt(input).hash(); returns the hash code for the givenintvalue, interpreted in little-endian byte order.hashLong(long input) Shortcut fornewHasher().putLong(input).hash(); returns the hash code for the givenlongvalue, interpreted in little-endian byte order.hashString(CharSequence input, Charset charset) Shortcut fornewHasher().putString(input, charset).hash().hashUnencodedChars(CharSequence input) Shortcut fornewHasher().putUnencodedChars(input).hash().private static intmixH1(int h1, int k1) private static intmixK1(int k1) Begins a new hash code computation by returning an initialized, statefulHasherinstance that is ready to receive data.toString()Methods inherited from class com.google.common.hash.AbstractHashFunction
hashBytes, hashBytes, hashObject, newHasher
-
Field Details
-
MURMUR3_32
-
MURMUR3_32_FIXED
-
GOOD_FAST_HASH_32
-
CHUNK_SIZE
private static final int CHUNK_SIZE- See Also:
-
C1
private static final int C1- See Also:
-
C2
private static final int C2- See Also:
-
seed
private final int seed -
supplementaryPlaneFix
private final boolean supplementaryPlaneFix -
serialVersionUID
private static final long serialVersionUID- See Also:
-
-
Constructor Details
-
Murmur3_32HashFunction
Murmur3_32HashFunction(int seed, boolean supplementaryPlaneFix)
-
-
Method Details
-
bits
public int bits()Description copied from interface:HashFunctionReturns the number of bits (a multiple of 32) that each hash code produced by this hash function has.- Specified by:
bitsin interfaceHashFunction
-
newHasher
Description copied from interface:HashFunctionBegins a new hash code computation by returning an initialized, statefulHasherinstance that is ready to receive data. Example:HashFunction hf = Hashing.md5(); HashCode hc = hf.newHasher() .putLong(id) .putBoolean(isActive) .hash();- Specified by:
newHasherin interfaceHashFunction
-
toString
-
equals
-
hashCode
public int hashCode() -
hashInt
Description copied from interface:HashFunctionShortcut fornewHasher().putInt(input).hash(); returns the hash code for the givenintvalue, interpreted in little-endian byte order. The implementation might perform better than its longhand equivalent, but should not perform worse.- Specified by:
hashIntin interfaceHashFunction- Overrides:
hashIntin classAbstractHashFunction
-
hashLong
Description copied from interface:HashFunctionShortcut fornewHasher().putLong(input).hash(); returns the hash code for the givenlongvalue, interpreted in little-endian byte order. The implementation might perform better than its longhand equivalent, but should not perform worse.- Specified by:
hashLongin interfaceHashFunction- Overrides:
hashLongin classAbstractHashFunction
-
hashUnencodedChars
Description copied from interface:HashFunctionShortcut fornewHasher().putUnencodedChars(input).hash(). The implementation might perform better than its longhand equivalent, but should not perform worse. Note that no character encoding is performed; the low byte and high byte of eachcharare hashed directly (in that order).Warning: This method will produce different output than most other languages do when running the same hash function on the equivalent input. For cross-language compatibility, use
HashFunction.hashString(java.lang.CharSequence, java.nio.charset.Charset), usually with a charset of UTF-8. For other use cases, usehashUnencodedChars.- Specified by:
hashUnencodedCharsin interfaceHashFunction- Overrides:
hashUnencodedCharsin classAbstractHashFunction
-
hashString
Description copied from interface:HashFunctionShortcut fornewHasher().putString(input, charset).hash(). Characters are encoded using the givenCharset. The implementation might perform better than its longhand equivalent, but should not perform worse.Warning: This method, which reencodes the input before hashing it, is useful only for cross-language compatibility. For other use cases, prefer
HashFunction.hashUnencodedChars(java.lang.CharSequence), which is faster, produces the same output across Java releases, and hashes everycharin the input, even if some are invalid.- Specified by:
hashStringin interfaceHashFunction- Overrides:
hashStringin classAbstractHashFunction
-
hashBytes
Description copied from interface:HashFunctionShortcut fornewHasher().putBytes(input, off, len).hash(). The implementation might perform better than its longhand equivalent, but should not perform worse.- Specified by:
hashBytesin interfaceHashFunction- Overrides:
hashBytesin classAbstractHashFunction
-
getIntLittleEndian
private static int getIntLittleEndian(byte[] input, int offset) -
mixK1
private static int mixK1(int k1) -
mixH1
private static int mixH1(int h1, int k1) -
fmix
-
codePointToFourUtf8Bytes
private static long codePointToFourUtf8Bytes(int codePoint) -
charToThreeUtf8Bytes
private static long charToThreeUtf8Bytes(char c) -
charToTwoUtf8Bytes
private static long charToTwoUtf8Bytes(char c)
-