Module hash4j

Interface SimilarityHashPolicy


public interface SimilarityHashPolicy
A policy for similarity hashing.
  • Method Details

    • createHasher

      SimilarityHasher createHasher()
      Creates a new SimilarityHasher instance.
      Returns:
      a new hasher instance
    • getNumberOfComponents

      int getNumberOfComponents()
      Returns the number of hash signature components.
      Returns:
      the number of hash signature components
    • getComponentSizeInBits

      int getComponentSizeInBits()
      The size of one single hash signature component in bits.
      Returns:
      the hash signature component size in bits
    • getNumberOfEqualComponents

      int getNumberOfEqualComponents(byte[] signature1, byte[] signature2)
      Returns the number of equal components of two given hash signatures.

      Throws an IllegalArgumentException, if the hash signatures do not have the expected size as given by getSignatureSizeInBytes().

      Parameters:
      signature1 - hash signature 1
      signature2 - hash signature 2
      Returns:
      the number of equal components
      Throws:
      IllegalArgumentException - if the hash signatures are null or do not have the expected size
    • getFractionOfEqualComponents

      double getFractionOfEqualComponents(byte[] signature1, byte[] signature2)
      Returns the fraction of equal components of two given hash signatures.

      Throws an IllegalArgumentException, if the hash signatures do not have the expected size as given by getSignatureSizeInBytes().

      Parameters:
      signature1 - hash signature 1
      signature2 - hash signature 2
      Returns:
      the number of equal components
      Throws:
      IllegalArgumentException - if the hash signatures are null or do not have the expected size
    • getSignatureSizeInBytes

      int getSignatureSizeInBytes()
      Returns the hash signature size in bytes.
      Returns:
      the signature size
    • getComponent

      long getComponent(byte[] signature, int idx)
      Returns the value of some component of a given hash signature.

      Throws an IllegalArgumentException, if the hash signature does not have the expected size as given by getSignatureSizeInBytes().

      Parameters:
      signature - a hash signature
      idx - the index of the component
      Returns:
      the value of the component
      Throws:
      IllegalArgumentException - if the hash signature is null or does not have the expected size