Class Hasher

java.lang.Object
org.tribuo.hash.Hasher
All Implemented Interfaces:
com.oracle.labs.mlrg.olcut.config.Configurable, com.oracle.labs.mlrg.olcut.provenance.Provenancable<com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance>, Serializable
Direct Known Subclasses:
HashCodeHasher, MessageDigestHasher, ModHashCodeHasher

public abstract class Hasher extends Object implements com.oracle.labs.mlrg.olcut.config.Configurable, com.oracle.labs.mlrg.olcut.provenance.Provenancable<com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance>, Serializable
An abstract base class for hash functions used to hash the names of features.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The minimum length of the salt.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract String
    hash(String input)
    Hashes the supplied input using the hashing function.
    abstract void
    The salt is transient, it must be set **to the same value as it was trained with** after the Model is deserialized.
    static boolean
    Salt validation is currently a test to see if the string is longer than MIN_LENGTH.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.oracle.labs.mlrg.olcut.config.Configurable

    postConfig

    Methods inherited from interface com.oracle.labs.mlrg.olcut.provenance.Provenancable

    getProvenance
  • Field Details

    • MIN_LENGTH

      public static final int MIN_LENGTH
      The minimum length of the salt. Salts shorter than this will not validate.
      See Also:
  • Constructor Details

    • Hasher

      public Hasher()
  • Method Details

    • hash

      public abstract String hash(String input)
      Hashes the supplied input using the hashing function.
      Parameters:
      input - The input to hash.
      Returns:
      A String representation of the hashed output.
    • setSalt

      public abstract void setSalt(String salt)
      The salt is transient, it must be set **to the same value as it was trained with** after the Model is deserialized.
      Parameters:
      salt - Salt value.
    • validateSalt

      public static boolean validateSalt(String salt)
      Salt validation is currently a test to see if the string is longer than MIN_LENGTH.

      When this method is updated Hasher must update it's serialVersionUID, this ensures that serialised instances of downstream classes which call this method are invalidated, as changes to validateSalt may invalidate old salts, and there is no other way to communicate this to the developer.

      Parameters:
      salt - String to validate.
      Returns:
      True if the salt is valid, false otherwise.