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

pack-priv final Class Fingerprint2011

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

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:

Authors
[email protected] (Kyle Maddison), [email protected] (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
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)

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

pack-priv static long
hash128to64(long high, long low)

Implementation of Hash128to64 from util/hash/hash128to64.h

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
hashLength33To64(byte[] bytes, int offset, int length)

pack-priv static long
murmurHash64WithSeed(byte[] bytes, int offset, int length, long seed)

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

FINGERPRINT_2011back to summary
pack-priv static final HashFunction FINGERPRINT_2011
K0back to summary
private static final long K0
K1back to summary
private static final long K1
K2back to summary
private static final long K2
K3back to summary
private static final long K3

Constructor Detail

Fingerprint2011back to summary
pack-priv Fingerprint2011()

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
fullFingerprintback to summary
private static long fullFingerprint(byte[] bytes, int offset, int length)
hash128to64back to summary
pack-priv static long hash128to64(long high, long low)

Implementation of Hash128to64 from util/hash/hash128to64.h

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
hashLength33To64back to summary
private static long hashLength33To64(byte[] bytes, int offset, int length)
murmurHash64WithSeedback to summary
pack-priv static long murmurHash64WithSeed(byte[] bytes, int offset, int length, long seed)
Annotations
@VisibleForTesting
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 - this is 12% faster than allocating new arrays every time.