Package net.rubyeye.xmemcached
Enum HashAlgorithm
- java.lang.Object
-
- java.lang.Enum<HashAlgorithm>
-
- net.rubyeye.xmemcached.HashAlgorithm
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<HashAlgorithm>
public enum HashAlgorithm extends java.lang.Enum<HashAlgorithm>
Known hashing algorithms for locating a server for a key. Note that all hash algorithms return 64-bits of hash, but only the lower 32-bits are significant. This allows a positive 32-bit number to be returned for all cases.
-
-
Enum Constant Summary
Enum Constants Enum Constant Description CRC32_HASH
CRC32_HASH as used by the perl API.ELECTION_HASH
ELF_HASH
FNV1_32_HASH
32-bit FNV1.FNV1_64_HASH
FNV hashes are designed to be fast while maintaining a low collision rate.FNV1A_32_HASH
32-bit FNV1a.FNV1A_64_HASH
Variation of FNV.KETAMA_HASH
MD5-based hash algorithm used by ketama.LUA_HASH
From lua source,it is used for long keyMYSQL_HASH
From mysql sourceNATIVE_HASH
Native hash (String.hashCode()).ONE_AT_A_TIME
The Jenkins One-at-a-time hash ,please see http://www.burtleburtle.net/bob/hash/doobs.htmlRS_HASH
-
Field Summary
Fields Modifier and Type Field Description private static long
FNV_32_INIT
private static long
FNV_32_PRIME
private static long
FNV_64_INIT
private static long
FNV_64_PRIME
private static java.lang.ThreadLocal<java.security.MessageDigest>
md5Local
-
Constructor Summary
Constructors Modifier Constructor Description private
HashAlgorithm()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static byte[]
computeMd5(java.lang.String k)
Get the md5 of the given key.long
hash(java.lang.String k)
Compute the hash for the given key.static HashAlgorithm
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static HashAlgorithm[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
NATIVE_HASH
public static final HashAlgorithm NATIVE_HASH
Native hash (String.hashCode()).
-
CRC32_HASH
public static final HashAlgorithm CRC32_HASH
CRC32_HASH as used by the perl API. This will be more consistent both across multiple API users as well as java versions, but is mostly likely significantly slower.
-
FNV1_64_HASH
public static final HashAlgorithm FNV1_64_HASH
FNV hashes are designed to be fast while maintaining a low collision rate. The FNV speed allows one to quickly hash lots of data while maintaining a reasonable collision rate.
-
FNV1A_64_HASH
public static final HashAlgorithm FNV1A_64_HASH
Variation of FNV.
-
FNV1_32_HASH
public static final HashAlgorithm FNV1_32_HASH
32-bit FNV1.
-
FNV1A_32_HASH
public static final HashAlgorithm FNV1A_32_HASH
32-bit FNV1a.
-
KETAMA_HASH
public static final HashAlgorithm KETAMA_HASH
MD5-based hash algorithm used by ketama.
-
MYSQL_HASH
public static final HashAlgorithm MYSQL_HASH
From mysql source
-
ELF_HASH
public static final HashAlgorithm ELF_HASH
-
RS_HASH
public static final HashAlgorithm RS_HASH
-
LUA_HASH
public static final HashAlgorithm LUA_HASH
From lua source,it is used for long key
-
ELECTION_HASH
public static final HashAlgorithm ELECTION_HASH
-
ONE_AT_A_TIME
public static final HashAlgorithm ONE_AT_A_TIME
The Jenkins One-at-a-time hash ,please see http://www.burtleburtle.net/bob/hash/doobs.html
-
-
Field Detail
-
FNV_64_INIT
private static final long FNV_64_INIT
- See Also:
- Constant Field Values
-
FNV_64_PRIME
private static final long FNV_64_PRIME
- See Also:
- Constant Field Values
-
FNV_32_INIT
private static final long FNV_32_INIT
- See Also:
- Constant Field Values
-
FNV_32_PRIME
private static final long FNV_32_PRIME
- See Also:
- Constant Field Values
-
md5Local
private static java.lang.ThreadLocal<java.security.MessageDigest> md5Local
-
-
Method Detail
-
values
public static HashAlgorithm[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (HashAlgorithm c : HashAlgorithm.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static HashAlgorithm valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is null
-
hash
public long hash(java.lang.String k)
Compute the hash for the given key.- Returns:
- a positive integer hash
-
computeMd5
public static byte[] computeMd5(java.lang.String k)
Get the md5 of the given key.
-
-