- All Implemented Interfaces:
Encoder<byte[],Number>, Hash32<byte[]>, Hash64<byte[]>
Ketama算法,用于在一致性Hash中快速定位服务器位置
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Constructor Summary
Constructors
-
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
KetamaHash
public KetamaHash()
-
Method Details
-
hash64
public long hash64(byte[] key)
Description copied from interface: Hash64
计算Hash值
- Specified by:
hash64 in interface Hash64<byte[]>
- Parameters:
key - 对象
- Returns:
- hash
-
hash32
public int hash32(byte[] key)
Description copied from interface: Hash32
计算Hash值
- Specified by:
hash32 in interface Hash32<byte[]>
- Parameters:
key - 对象
- Returns:
- hash
-
encode
public Number encode(byte[] key)
Description copied from interface: Encoder
执行编码
- Specified by:
encode in interface Encoder<byte[],Number>
- Specified by:
encode in interface Hash32<byte[]>
- Specified by:
encode in interface Hash64<byte[]>
- Parameters:
key - 被编码的数据
- Returns:
- 编码后的数据