Package com.google.common.hash
Class FarmHashFingerprint64
- java.lang.Object
-
- com.google.common.hash.AbstractHashFunction
-
- com.google.common.hash.AbstractNonStreamingHashFunction
-
- com.google.common.hash.FarmHashFingerprint64
-
- All Implemented Interfaces:
HashFunction
final class FarmHashFingerprint64 extends AbstractNonStreamingHashFunction
Implementation of FarmHash Fingerprint64, an open-source fingerprinting algorithm for strings.Its speed is comparable to CityHash64, and its quality of hashing is at least as good.
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
Fields Modifier and Type Field Description (package private) static HashFunctionFARMHASH_FINGERPRINT_64private static longK0private static longK1private static longK2
-
Constructor Summary
Constructors Constructor Description FarmHashFingerprint64()
-
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.(package private) static longfingerprint(byte[] bytes, int offset, int length)HashCodehashBytes(byte[] input, int off, int len)Shortcut fornewHasher().putBytes(input, off, len).hash().private static longhashLength0to16(byte[] bytes, int offset, int length)private static longhashLength16(long u, long v, long mul)private static longhashLength17to32(byte[] bytes, int offset, int length)private static longhashLength33To64(byte[] bytes, int offset, int length)private static longhashLength65Plus(byte[] bytes, int offset, int length)private static longshiftMix(long val)java.lang.StringtoString()private static voidweakHashLength32WithSeeds(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 Detail
-
FARMHASH_FINGERPRINT_64
static final HashFunction FARMHASH_FINGERPRINT_64
-
K0
private static final long K0
- See Also:
- Constant Field Values
-
K1
private static final long K1
- See Also:
- Constant Field Values
-
K2
private static final long K2
- See Also:
- Constant Field Values
-
-
Method Detail
-
hashBytes
public HashCode hashBytes(byte[] input, int off, int len)
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- Specified by:
hashBytesin classAbstractNonStreamingHashFunction
-
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.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
fingerprint
static long fingerprint(byte[] bytes, int offset, int length)
-
shiftMix
private static long shiftMix(long val)
-
hashLength16
private static long hashLength16(long u, long v, long mul)
-
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 because when we last measured, this was 12% faster than allocating new arrays every time.
-
hashLength0to16
private static long hashLength0to16(byte[] bytes, int offset, int length)
-
hashLength17to32
private static long hashLength17to32(byte[] bytes, int offset, int length)
-
hashLength33To64
private static long hashLength33To64(byte[] bytes, int offset, int length)
-
hashLength65Plus
private static long hashLength65Plus(byte[] bytes, int offset, int length)
-
-