Class KetamaHash

java.lang.Object
org.miaixz.bus.core.codec.hash.KetamaHash
All Implemented Interfaces:
Encoder<byte[],Number>, Hash32<byte[]>, Hash64<byte[]>

public class KetamaHash extends Object implements Hash64<byte[]>, Hash32<byte[]>
Ketama算法,用于在一致性Hash中快速定位服务器位置
Since:
Java 17+
Author:
Kimi Liu
  • 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:
      编码后的数据