public class BinaryVectorDescriptorComparator extends Object implements DescriptorComparator<BinaryVectorDescriptor>
Guarded.EnsureThat, Guarded.New
Constructor and Description |
---|
BinaryVectorDescriptorComparator(DescriptorSerializer<BinaryVectorDescriptor> descriptorSerializer,
BinaryVectorComparator comparator,
int size,
UnguardedContext<BinaryVectorDescriptor,?> unguardedContext)
Create an instance.
|
Modifier and Type | Method and Description |
---|---|
double |
calculateDissimilarity(BinaryVectorDescriptor target,
BinaryVectorDescriptor query)
Compare two descriptors.
|
double |
calculateDissimilarity(byte[] target,
byte[] query)
Compare two descriptors in serialized form.
|
double |
calculateSimilarity(BinaryVectorDescriptor target,
BinaryVectorDescriptor query)
Compare two descriptors.
|
double |
calculateSimilarity(byte[] target,
byte[] query)
Compare two descriptors in serialized form.
|
ComparisonResult |
compare(BinaryVectorDescriptor target,
BinaryVectorDescriptor query)
Compare two descriptors.
|
ComparisonResult |
compare(byte[] target,
byte[] query)
Compare two descriptors in serialized form.
|
Object |
getGuardObject()
Gets the guard object associated to the generated descriptors/utilities.
|
Optional<Double> |
getLowerBound()
Get lower bound for the similarity/dissimilarity values if such one can be determined.
|
MetricMetadata |
getMetricMetadata()
Metadata about this metric.
|
Optional<Double> |
getUpperBound()
Get upper bound for the similarity/dissimilarity values if such one can be determined.
|
String |
toString() |
UnguardedContext<BinaryVectorDescriptor,?> |
unguardedContext()
Associated unguarded context.
|
public BinaryVectorDescriptorComparator(DescriptorSerializer<BinaryVectorDescriptor> descriptorSerializer, BinaryVectorComparator comparator, int size, UnguardedContext<BinaryVectorDescriptor,?> unguardedContext)
descriptorSerializer
- Underlying serializer, also source of the guard objectcomparator
- Underlying comparator.size
- Vector length.unguardedContext
- Associated unguarded contextpublic ComparisonResult compare(BinaryVectorDescriptor target, BinaryVectorDescriptor query)
DescriptorComparator
Please note that some implementation might return a result object containing additional data related to the compariosn results.
compare
in interface DescriptorComparator<BinaryVectorDescriptor>
target
- Target descriptorquery
- Query descriptorpublic ComparisonResult compare(byte[] target, byte[] query)
DescriptorComparator
Please note that some implementation might return a result object containing additional data related to the
compariosn results. This method's functionality is equivalent to comparing
(with DescriptorComparator.compare(com.chemaxon.descriptors.common.Descriptor, com.chemaxon.descriptors.common.Descriptor)
)
deserialized
(by DescriptorSerializer.fromByteArray(byte[])
) descriptors.
compare
in interface DescriptorComparator<BinaryVectorDescriptor>
target
- Target descriptor in its serialized formquery
- Query descriptor in its serialized formpublic double calculateSimilarity(BinaryVectorDescriptor target, BinaryVectorDescriptor query)
DescriptorComparator
Please note that this convenience method wraps ComparisonResult.getSimilarity()
of comparison result
constructed by
DescriptorComparator.compare(com.chemaxon.descriptors.common.Descriptor, com.chemaxon.descriptors.common.Descriptor)
calculateSimilarity
in interface DescriptorComparator<BinaryVectorDescriptor>
target
- Target descriptorquery
- Query descriptorpublic double calculateDissimilarity(BinaryVectorDescriptor target, BinaryVectorDescriptor query)
DescriptorComparator
Please note that this convenience method wraps ComparisonResult.getDissimilarity()
of comparison
result constructed by
DescriptorComparator.compare(com.chemaxon.descriptors.common.Descriptor, com.chemaxon.descriptors.common.Descriptor)
calculateDissimilarity
in interface DescriptorComparator<BinaryVectorDescriptor>
target
- Target descriptorquery
- Query descriptorpublic double calculateSimilarity(byte[] target, byte[] query)
DescriptorComparator
calculateSimilarity
in interface DescriptorComparator<BinaryVectorDescriptor>
target
- Target descriptor in its serialized formquery
- Query descriptor in its serialized formpublic double calculateDissimilarity(byte[] target, byte[] query)
DescriptorComparator
calculateDissimilarity
in interface DescriptorComparator<BinaryVectorDescriptor>
target
- Target descriptor in its serialized formquery
- Query descriptor in its serialized formpublic Optional<Double> getLowerBound()
DescriptorComparator
getLowerBound
in interface DescriptorComparator<BinaryVectorDescriptor>
public Optional<Double> getUpperBound()
DescriptorComparator
getUpperBound
in interface DescriptorComparator<BinaryVectorDescriptor>
public MetricMetadata getMetricMetadata()
DescriptorComparator
It is guaranteed that the actual instance returned can be used as a parameter of the appropriate comparator
getter method of the associated DescriptorGenerator
getMetricMetadata
in interface DescriptorComparator<BinaryVectorDescriptor>
public Object getGuardObject()
Guarded
This method is intended to use only for ensuring the compatibility of manipulated objects.
Implementations might use the associated DescriptorGenerator
or DescriptorParameters
reference as
the guard object, however it is a non recommended practice to use this method to access the associated generator
to perform further operations on it.
getGuardObject
in interface Guarded
null
.public UnguardedContext<BinaryVectorDescriptor,?> unguardedContext()
DescriptorComparator
unguardedContext
in interface DescriptorComparator<BinaryVectorDescriptor>