public interface SimilarityHashPolicy
A policy for similarity hashing.
-
Method Summary
Modifier and TypeMethodDescriptionCreates a newSimilarityHasherinstance.longgetComponent(byte[] signature, int idx) Returns the value of some component of a given hash signature.intThe size of one single hash signature component in bits.doublegetFractionOfEqualComponents(byte[] signature1, byte[] signature2) Returns the fraction of equal components of two given hash signatures.intReturns the number of hash signature components.intgetNumberOfEqualComponents(byte[] signature1, byte[] signature2) Returns the number of equal components of two given hash signatures.intReturns the hash signature size in bytes.
-
Method Details
-
createHasher
SimilarityHasher createHasher()Creates a newSimilarityHasherinstance.- 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 bygetSignatureSizeInBytes().- Parameters:
signature1- hash signature 1signature2- 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 bygetSignatureSizeInBytes().- Parameters:
signature1- hash signature 1signature2- 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 bygetSignatureSizeInBytes().- Parameters:
signature- a hash signatureidx- 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
-