Package com.google.common.hash
Class Murmur3_32HashFunction.Murmur3_32Hasher
- java.lang.Object
-
- com.google.common.hash.AbstractHasher
-
- com.google.common.hash.Murmur3_32HashFunction.Murmur3_32Hasher
-
- All Implemented Interfaces:
Hasher
,PrimitiveSink
- Enclosing class:
- Murmur3_32HashFunction
private static final class Murmur3_32HashFunction.Murmur3_32Hasher extends AbstractHasher
-
-
Constructor Summary
Constructors Constructor Description Murmur3_32Hasher(int seed)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description HashCode
hash()
Computes a hash code based on the data that have been provided to this hasher.Hasher
putByte(byte b)
Puts a byte into this sink.Hasher
putBytes(byte[] bytes, int off, int len)
Puts a chunk of an array of bytes into this sink.Hasher
putBytes(java.nio.ByteBuffer buffer)
Puts the remaining bytes of a byte buffer into this sink.Hasher
putChar(char c)
Puts a character into this sink.Hasher
putInt(int i)
Puts an int into this sink.Hasher
putLong(long l)
Puts a long into this sink.Hasher
putString(java.lang.CharSequence input, java.nio.charset.Charset charset)
Equivalent toputBytes(charSequence.toString().getBytes(charset))
.private void
update(int nBytes, long update)
-
Methods inherited from class com.google.common.hash.AbstractHasher
putBoolean, putBytes, putDouble, putFloat, putObject, putShort, putUnencodedChars
-
-
-
-
Method Detail
-
update
private void update(int nBytes, long update)
-
putByte
public Hasher putByte(byte b)
Description copied from interface:PrimitiveSink
Puts a byte into this sink.- Parameters:
b
- a byte- Returns:
- this instance
-
putBytes
public Hasher putBytes(byte[] bytes, int off, int len)
Description copied from interface:PrimitiveSink
Puts a chunk of an array of bytes into this sink.bytes[off]
is the first byte written,bytes[off + len - 1]
is the last.- Specified by:
putBytes
in interfaceHasher
- Specified by:
putBytes
in interfacePrimitiveSink
- Overrides:
putBytes
in classAbstractHasher
- Parameters:
bytes
- a byte arrayoff
- the start offset in the arraylen
- the number of bytes to write- Returns:
- this instance
-
putBytes
public Hasher putBytes(java.nio.ByteBuffer buffer)
Description copied from interface:PrimitiveSink
Puts the remaining bytes of a byte buffer into this sink.bytes.position()
is the first byte written,bytes.limit() - 1
is the last. The position of the buffer will be equal to the limit when this method returns.- Specified by:
putBytes
in interfaceHasher
- Specified by:
putBytes
in interfacePrimitiveSink
- Overrides:
putBytes
in classAbstractHasher
- Parameters:
buffer
- a byte buffer- Returns:
- this instance
-
putInt
public Hasher putInt(int i)
Description copied from interface:PrimitiveSink
Puts an int into this sink.- Specified by:
putInt
in interfaceHasher
- Specified by:
putInt
in interfacePrimitiveSink
- Overrides:
putInt
in classAbstractHasher
-
putLong
public Hasher putLong(long l)
Description copied from interface:PrimitiveSink
Puts a long into this sink.- Specified by:
putLong
in interfaceHasher
- Specified by:
putLong
in interfacePrimitiveSink
- Overrides:
putLong
in classAbstractHasher
-
putChar
public Hasher putChar(char c)
Description copied from interface:PrimitiveSink
Puts a character into this sink.- Specified by:
putChar
in interfaceHasher
- Specified by:
putChar
in interfacePrimitiveSink
- Overrides:
putChar
in classAbstractHasher
-
putString
public Hasher putString(java.lang.CharSequence input, java.nio.charset.Charset charset)
Description copied from interface:Hasher
Equivalent toputBytes(charSequence.toString().getBytes(charset))
.Warning: This method, which reencodes the input before hashing it, is useful only for cross-language compatibility. For other use cases, prefer
Hasher.putUnencodedChars(java.lang.CharSequence)
, which is faster, produces the same output across Java releases, and hashes everychar
in the input, even if some are invalid.- Specified by:
putString
in interfaceHasher
- Specified by:
putString
in interfacePrimitiveSink
- Overrides:
putString
in classAbstractHasher
-
-