Package com.google.common.hash
Class Murmur3_32HashFunction
- java.lang.Object
-
- com.google.common.hash.AbstractStreamingHashFunction
-
- com.google.common.hash.Murmur3_32HashFunction
-
- All Implemented Interfaces:
HashFunction,java.io.Serializable
final class Murmur3_32HashFunction extends AbstractStreamingHashFunction implements java.io.Serializable
See MurmurHash3_x86_32 in the C++ implementation.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classMurmur3_32HashFunction.Murmur3_32Hasher-
Nested classes/interfaces inherited from class com.google.common.hash.AbstractStreamingHashFunction
AbstractStreamingHashFunction.AbstractStreamingHasher
-
-
Field Summary
Fields Modifier and Type Field Description private static intC1private static intC2private intseedprivate static longserialVersionUID
-
Constructor Summary
Constructors Constructor Description Murmur3_32HashFunction(int seed)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intbits()Returns the number of bits (a multiple of 32) that each hash code produced by this hash function has.booleanequals(java.lang.Object object)private static HashCodefmix(int h1, int length)inthashCode()HashCodehashInt(int input)Shortcut fornewHasher().putInt(input).hash(); returns the hash code for the givenintvalue, interpreted in little-endian byte order.HashCodehashLong(long input)Shortcut fornewHasher().putLong(input).hash(); returns the hash code for the givenlongvalue, interpreted in little-endian byte order.HashCodehashUnencodedChars(java.lang.CharSequence input)Shortcut fornewHasher().putUnencodedChars(input).hash().private static intmixH1(int h1, int k1)private static intmixK1(int k1)HashernewHasher()Begins a new hash code computation by returning an initialized, statefulHasherinstance that is ready to receive data.java.lang.StringtoString()-
Methods inherited from class com.google.common.hash.AbstractStreamingHashFunction
hashBytes, hashBytes, hashObject, hashString, newHasher
-
-
-
-
Field Detail
-
C1
private static final int C1
- See Also:
- Constant Field Values
-
C2
private static final int C2
- See Also:
- Constant Field Values
-
seed
private final int seed
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
-
Method Detail
-
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
public Hasher 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
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
equals
public boolean equals(@Nullable java.lang.Object object)- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
hashInt
public HashCode hashInt(int input)
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 classAbstractStreamingHashFunction
-
hashLong
public HashCode hashLong(long input)
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 classAbstractStreamingHashFunction
-
hashUnencodedChars
public HashCode hashUnencodedChars(java.lang.CharSequence input)
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 classAbstractStreamingHashFunction
-
mixK1
private static int mixK1(int k1)
-
mixH1
private static int mixH1(int h1, int k1)
-
fmix
private static HashCode fmix(int h1, int length)
-
-