Class Hashing
HashFunction instances, and other static hashing-related
utilities.
A comparison of the various hash functions can be found here.
- Since:
- 11.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic HashFunctionadler32()Deprecated.static HashCodecombineOrdered(Iterable<HashCode> hashCodes) Deprecated.Returns a hash code, having the same bit length as each of the input hash codes, that combines the information of these hash codes in an ordered fashion.static HashCodecombineUnordered(Iterable<HashCode> hashCodes) Deprecated.Returns a hash code, having the same bit length as each of the input hash codes, that combines the information of these hash codes in an unordered fashion.static intconsistentHash(long input, int buckets) Deprecated.Assigns toinputa "bucket" in the range[0, buckets), in a uniform manner that minimizes the need for remapping asbucketsgrows.static intconsistentHash(HashCode hashCode, int buckets) Deprecated.Assigns tohashCodea "bucket" in the range[0, buckets), in a uniform manner that minimizes the need for remapping asbucketsgrows.static HashFunctioncrc32()Deprecated.static HashFunctiongoodFastHash(int minimumBits) Deprecated.Returns a general-purpose, temporary-use, non-cryptographic hash function.static HashFunctionmd5()Deprecated.Returns a hash function implementing the MD5 hash algorithm (128 hash bits) by delegating to the MD5MessageDigest.static HashFunctionDeprecated.Returns a hash function implementing the 128-bit murmur3 algorithm, x64 variant (little-endian variant), using a seed value of zero.static HashFunctionmurmur3_128(int seed) Deprecated.Returns a hash function implementing the 128-bit murmur3 algorithm, x64 variant (little-endian variant), using the given seed value.static HashFunctionDeprecated.Returns a hash function implementing the 32-bit murmur3 algorithm, x86 variant (little-endian variant), using a seed value of zero.static HashFunctionmurmur3_32(int seed) Deprecated.Returns a hash function implementing the 32-bit murmur3 algorithm, x86 variant (little-endian variant), using the given seed value.static HashFunctionsha1()Deprecated.Returns a hash function implementing the SHA-1 algorithm (160 hash bits) by delegating to the SHA-1MessageDigest.static HashFunctionsha256()Deprecated.Returns a hash function implementing the SHA-256 algorithm (256 hash bits) by delegating to the SHA-256MessageDigest.static HashFunctionsha512()Deprecated.Returns a hash function implementing the SHA-512 algorithm (512 hash bits) by delegating to the SHA-512MessageDigest.static HashFunctionDeprecated.Returns a hash function implementing the 64-bit SipHash-2-4 algorithm using a seed value ofk = 00 01 02 ....static HashFunctionsipHash24(long k0, long k1) Deprecated.Returns a hash function implementing the 64-bit SipHash-2-4 algorithm using the given seed.
-
Method Details
-
goodFastHash
Deprecated.Returns a general-purpose, temporary-use, non-cryptographic hash function. The algorithm the returned function implements is unspecified and subject to change without notice.Warning: a new random seed for these functions is chosen each time the
Hashingclass is loaded. Do not use this method if hash codes may escape the current process in any way, for example being sent over RPC, or saved to disk.Repeated calls to this method on the same loaded
Hashingclass, using the same value forminimumBits, will return identically-behavingHashFunctioninstances.- Parameters:
minimumBits- a positive integer (can be arbitrarily large)- Returns:
- a hash function, described above, that produces hash codes of length
minimumBitsor greater
-
murmur3_32
Deprecated.Returns a hash function implementing the 32-bit murmur3 algorithm, x86 variant (little-endian variant), using the given seed value.The exact C++ equivalent is the MurmurHash3_x86_32 function (Murmur3A).
-
murmur3_32
Deprecated.Returns a hash function implementing the 32-bit murmur3 algorithm, x86 variant (little-endian variant), using a seed value of zero.The exact C++ equivalent is the MurmurHash3_x86_32 function (Murmur3A).
-
murmur3_128
Deprecated.Returns a hash function implementing the 128-bit murmur3 algorithm, x64 variant (little-endian variant), using the given seed value.The exact C++ equivalent is the MurmurHash3_x64_128 function (Murmur3F).
-
murmur3_128
Deprecated.Returns a hash function implementing the 128-bit murmur3 algorithm, x64 variant (little-endian variant), using a seed value of zero.The exact C++ equivalent is the MurmurHash3_x64_128 function (Murmur3F).
-
sipHash24
Deprecated.Returns a hash function implementing the 64-bit SipHash-2-4 algorithm using a seed value ofk = 00 01 02 ....- Since:
- 15.0
-
sipHash24
Deprecated.Returns a hash function implementing the 64-bit SipHash-2-4 algorithm using the given seed.- Since:
- 15.0
-
md5
Deprecated.Returns a hash function implementing the MD5 hash algorithm (128 hash bits) by delegating to the MD5MessageDigest. -
sha1
Deprecated.Returns a hash function implementing the SHA-1 algorithm (160 hash bits) by delegating to the SHA-1MessageDigest. -
sha256
Deprecated.Returns a hash function implementing the SHA-256 algorithm (256 hash bits) by delegating to the SHA-256MessageDigest. -
sha512
Deprecated.Returns a hash function implementing the SHA-512 algorithm (512 hash bits) by delegating to the SHA-512MessageDigest. -
crc32
Deprecated.Returns a hash function implementing the CRC-32 checksum algorithm (32 hash bits) by delegating to theCRC32Checksum.To get the
longvalue equivalent toChecksum.getValue()for aHashCodeproduced by this function, useHashCode.padToLong().- Since:
- 14.0
-
adler32
Deprecated.Returns a hash function implementing the Adler-32 checksum algorithm (32 hash bits) by delegating to theAdler32Checksum.To get the
longvalue equivalent toChecksum.getValue()for aHashCodeproduced by this function, useHashCode.padToLong().- Since:
- 14.0
-
consistentHash
Deprecated.Assigns tohashCodea "bucket" in the range[0, buckets), in a uniform manner that minimizes the need for remapping asbucketsgrows. That is,consistentHash(h, n)equals:n - 1, with approximate probability1/nconsistentHash(h, n - 1), otherwise (probability1 - 1/n)
See the wikipedia article on consistent hashing for more information.
-
consistentHash
public static int consistentHash(long input, int buckets) Deprecated.Assigns toinputa "bucket" in the range[0, buckets), in a uniform manner that minimizes the need for remapping asbucketsgrows. That is,consistentHash(h, n)equals:n - 1, with approximate probability1/nconsistentHash(h, n - 1), otherwise (probability1 - 1/n)
See the wikipedia article on consistent hashing for more information.
-
combineOrdered
Deprecated.Returns a hash code, having the same bit length as each of the input hash codes, that combines the information of these hash codes in an ordered fashion. That is, whenever two equal hash codes are produced by two calls to this method, it is as likely as possible that each was computed from the same input hash codes in the same order.- Throws:
IllegalArgumentException- ifhashCodesis empty, or the hash codes do not all have the same bit length
-
combineUnordered
Deprecated.Returns a hash code, having the same bit length as each of the input hash codes, that combines the information of these hash codes in an unordered fashion. That is, whenever two equal hash codes are produced by two calls to this method, it is as likely as possible that each was computed from the same input hash codes in some order.- Throws:
IllegalArgumentException- ifhashCodesis empty, or the hash codes do not all have the same bit length
-