Enum DefaultHashAlgorithm

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<DefaultHashAlgorithm>, HashAlgorithm

    public enum DefaultHashAlgorithm
    extends java.lang.Enum<DefaultHashAlgorithm>
    implements 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.
    • 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 DefaultHashAlgorithm valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static DefaultHashAlgorithm[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Enum Constant Detail

      • NATIVE_HASH

        public static final DefaultHashAlgorithm NATIVE_HASH
        Native hash (String.hashCode()).
      • CRC_HASH

        public static final DefaultHashAlgorithm CRC_HASH
        CRC_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 DefaultHashAlgorithm 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.
        See Also:
        fnv comparisons, fnv at wikipedia
      • KETAMA_HASH

        public static final DefaultHashAlgorithm KETAMA_HASH
        MD5-based hash algorithm used by ketama.
    • Constructor Detail

      • DefaultHashAlgorithm

        private DefaultHashAlgorithm()
    • Method Detail

      • values

        public static DefaultHashAlgorithm[] 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 (DefaultHashAlgorithm c : DefaultHashAlgorithm.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static DefaultHashAlgorithm 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 name
        java.lang.NullPointerException - if the argument is null
      • hash

        public long hash​(java.lang.String k)
        Compute the hash for the given key.
        Specified by:
        hash in interface HashAlgorithm
        Returns:
        a positive integer hash
      • computeMd5

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