Package com.google.common.hash
Class Fingerprint2011
java.lang.Object
com.google.common.hash.AbstractHashFunction
com.google.common.hash.AbstractNonStreamingHashFunction
com.google.common.hash.Fingerprint2011
- All Implemented Interfaces:
HashFunction
Implementation of Geoff Pike's fingerprint2011 hash function. See
Hashing.fingerprint2011()
for information on the behaviour of the algorithm.
On Intel Core2 2.66, on 1000 bytes, fingerprint2011 takes 0.9 microseconds compared to fingerprint at 4.0 microseconds and md5 at 4.5 microseconds.
Note to maintainers: This implementation relies on signed arithmetic being bit-wise equivalent to unsigned arithmetic in all cases except:
- comparisons (signed values can be negative)
- division (avoided here)
- shifting (right shift must be unsigned)
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final HashFunction
private static final long
private static final long
private static final long
private static final long
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
bits()
Returns the number of bits (a multiple of 32) that each hash code produced by this hash function has.(package private) static long
fingerprint
(byte[] bytes, int offset, int length) private static long
fullFingerprint
(byte[] bytes, int offset, int length) (package private) static long
hash128to64
(long high, long low) Implementation of Hash128to64 from util/hash/hash128to64.hhashBytes
(byte[] input, int off, int len) Shortcut fornewHasher().putBytes(input, off, len).hash()
.private static long
hashLength33To64
(byte[] bytes, int offset, int length) (package private) static long
murmurHash64WithSeed
(byte[] bytes, int offset, int length, long seed) private static long
shiftMix
(long val) toString()
private static void
weakHashLength32WithSeeds
(byte[] bytes, int offset, long seedA, long seedB, long[] output) Computes intermediate hash of 32 bytes of byte array from the given offset.Methods inherited from class com.google.common.hash.AbstractNonStreamingHashFunction
hashBytes, hashInt, hashLong, hashString, hashUnencodedChars, newHasher, newHasher
Methods inherited from class com.google.common.hash.AbstractHashFunction
hashBytes, hashObject
-
Field Details
-
FINGERPRINT_2011
-
K0
private static final long K0- See Also:
-
K1
private static final long K1- See Also:
-
K2
private static final long K2- See Also:
-
K3
private static final long K3- See Also:
-
-
Constructor Details
-
Fingerprint2011
Fingerprint2011()
-
-
Method Details
-
hashBytes
Description copied from interface:HashFunction
Shortcut fornewHasher().putBytes(input, off, len).hash()
. The implementation might perform better than its longhand equivalent, but should not perform worse.- Specified by:
hashBytes
in interfaceHashFunction
- Specified by:
hashBytes
in classAbstractNonStreamingHashFunction
-
bits
public int bits()Description copied from interface:HashFunction
Returns the number of bits (a multiple of 32) that each hash code produced by this hash function has. -
toString
-
fingerprint
static long fingerprint(byte[] bytes, int offset, int length) -
shiftMix
private static long shiftMix(long val) -
hash128to64
static long hash128to64(long high, long low) Implementation of Hash128to64 from util/hash/hash128to64.h -
weakHashLength32WithSeeds
private static void weakHashLength32WithSeeds(byte[] bytes, int offset, long seedA, long seedB, long[] output) Computes intermediate hash of 32 bytes of byte array from the given offset. Results are returned in the output array - this is 12% faster than allocating new arrays every time. -
fullFingerprint
private static long fullFingerprint(byte[] bytes, int offset, int length) -
hashLength33To64
private static long hashLength33To64(byte[] bytes, int offset, int length) -
murmurHash64WithSeed
static long murmurHash64WithSeed(byte[] bytes, int offset, int length, long seed)
-