Top Description Fields Constructors Methods
com.google.common.hash

pack-priv final Class FarmHashFingerprint64

extends AbstractNonStreamingHashFunction
Class Inheritance
Annotations
@ElementTypesAreNonnullByDefault
Static Imports
com.google.common.base.Preconditions.checkPositionIndexes, com.google.common.hash.LittleEndianByteArray.load32, .LittleEndianByteArray.load64, java.lang.Long.rotateRight

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:

Authors
Kyle Maddison, Geoff Pike

Field Summary

Modifier and TypeField and Description
pack-priv static final HashFunction
private static final long
private static final long
private static final long

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public int
bits()

Implements com.google.common.hash.HashFunction.bits.

Returns the number of bits (a multiple of 32) that each hash code produced by this hash function has.
pack-priv static long
fingerprint(byte[] bytes, int offset, int length)

public HashCode
hashBytes(byte[] input, int off, int len)

Implements abstract com.google.common.hash.AbstractNonStreamingHashFunction.hashBytes.

Implements com.google.common.hash.HashFunction.hashBytes.

Shortcut for newHasher().putBytes(input, off, len).hash().
private static long
hashLength0to16(byte[] bytes, int offset, int length)

private static long
hashLength16(long u, long v, long mul)

private static long
hashLength17to32(byte[] bytes, int offset, int length)

private static long
hashLength33To64(byte[] bytes, int offset, int length)

private static long
hashLength65Plus(byte[] bytes, int offset, int length)

private static long
shiftMix(long val)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
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.

Inherited from com.google.common.hash.AbstractNonStreamingHashFunction:
hashByteshashInthashLonghashStringhashUnencodedCharsnewHashernewHasher

Field Detail

FARMHASH_FINGERPRINT_64back to summary
pack-priv static final HashFunction FARMHASH_FINGERPRINT_64
K0back to summary
private static final long K0
K1back to summary
private static final long K1
K2back to summary
private static final long K2

Constructor Detail

FarmHashFingerprint64back to summary
pack-priv FarmHashFingerprint64()

Method Detail

bitsback to summary
public int bits()

Implements com.google.common.hash.HashFunction.bits.

Doc from com.google.common.hash.HashFunction.bits.

Returns the number of bits (a multiple of 32) that each hash code produced by this hash function has.

Annotations
@Override
fingerprintback to summary
pack-priv static long fingerprint(byte[] bytes, int offset, int length)
Annotations
@VisibleForTesting
hashBytesback to summary
public HashCode hashBytes(byte[] input, int off, int len)

Implements abstract com.google.common.hash.AbstractNonStreamingHashFunction.hashBytes.

Implements com.google.common.hash.HashFunction.hashBytes.

Doc from com.google.common.hash.HashFunction.hashBytes.

Shortcut for newHasher().putBytes(input, off, len).hash(). The implementation might perform better than its longhand equivalent, but should not perform worse.

Annotations
@Override
hashLength0to16back to summary
private static long hashLength0to16(byte[] bytes, int offset, int length)
hashLength16back to summary
private static long hashLength16(long u, long v, long mul)
hashLength17to32back to summary
private static long hashLength17to32(byte[] bytes, int offset, int length)
hashLength33To64back to summary
private static long hashLength33To64(byte[] bytes, int offset, int length)
hashLength65Plusback to summary
private static long hashLength65Plus(byte[] bytes, int offset, int length)
shiftMixback to summary
private static long shiftMix(long val)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
weakHashLength32WithSeedsback to summary
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.