com.taobao.metamorphosis.client.consumer
枚举 HashAlgorithm

java.lang.Object
  继承者 java.lang.Enum<HashAlgorithm>
      继承者 com.taobao.metamorphosis.client.consumer.HashAlgorithm
所有已实现的接口:
Serializable, Comparable<HashAlgorithm>

public enum HashAlgorithm
extends 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.


枚举常量摘要
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 key
MYSQL_HASH
          From mysql source
NATIVE_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.html
RS_HASH
           
 
方法摘要
static byte[] computeMd5(String k)
          Get the md5 of the given key.
 long hash(String k)
          Compute the hash for the given key.
static HashAlgorithm valueOf(String name)
          返回带有指定名称的该类型的枚举常量。
static HashAlgorithm[] values()
          按照声明该枚举类型的常量的顺序,返回 包含这些常量的数组。
 
从类 java.lang.Enum 继承的方法
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
从类 java.lang.Object 继承的方法
getClass, notify, notifyAll, wait, wait, wait
 

枚举常量详细信息

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.

另请参见:
http://www.isthe.com/chongo/tech/comp/fnv/, http://en.wikipedia.org/wiki/Fowler_Noll_Vo_hash

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

方法详细信息

values

public static HashAlgorithm[] values()
按照声明该枚举类型的常量的顺序,返回 包含这些常量的数组。该方法可用于迭代 常量,如下所示:
for (HashAlgorithm c : HashAlgorithm.values())
    System.out.println(c);


valueOf

public static HashAlgorithm valueOf(String name)
返回带有指定名称的该类型的枚举常量。 字符串必须与用于声明该类型的枚举常量的 标识符完全匹配。(不允许有多余 的空格。)

参数:
name - 要返回的枚举常量的名称。
返回:
返回带有指定名称的枚举常量
抛出:
如果该枚举类型没有带有指定名称的常量, - 则抛出 IllegalArgumentException

hash

public long hash(String k)
Compute the hash for the given key.

返回:
a positive integer hash

computeMd5

public static byte[] computeMd5(String k)
Get the md5 of the given key.



Copyright © 2010–2013. All rights reserved.