public abstract class PrecomputedDistancesFilter extends java.lang.Object implements java.lang.Cloneable, java.io.Serializable, BinarySerializable
A filter is added to a LocalAbstractObject
via its
chainFilter
method. Objects can have
several filters chained - if the first filter fails to avoid the computation,
the next is used and so on. The filters are then used automatically whenever a
distance computation
is evaluated.
Modifier | Constructor and Description |
---|---|
protected |
PrecomputedDistancesFilter()
Creates a new instance of PrecomputedDistancesFilter.
|
protected |
PrecomputedDistancesFilter(BinaryInput input,
BinarySerializator serializator)
Creates a new instance of PrecomputedDistancesFilter loaded from binary input.
|
Modifier and Type | Method and Description |
---|---|
protected abstract boolean |
addPrecomputedDistance(LocalAbstractObject obj,
float distance,
float[] metaDistances)
Adds a precomputed distance to this filter.
|
int |
binarySerialize(BinaryOutput output,
BinarySerializator serializator)
Binary-serialize this object into the
output . |
java.lang.Object |
clone()
Creates and returns a copy of this object.
|
abstract boolean |
excludeUsingPrecompDist(PrecomputedDistancesFilter targetFilter,
float radius)
Returns true if object associated with targetFilter filter can be excluded (filtered out) using this precomputed distances.
|
int |
getBinarySize(BinarySerializator serializator)
Returns the exact size of the binary-serialized version of this object in bytes.
|
float |
getPrecomputedDistance(LocalAbstractObject obj)
Returns a precomputed distance to the given object.
|
abstract float |
getPrecomputedDistance(LocalAbstractObject obj,
float[] metaDistances)
Returns a precomputed distance to the given object and the respective meta distances
array.
|
abstract boolean |
includeUsingPrecompDist(PrecomputedDistancesFilter targetFilter,
float radius)
Returns true if object associated with targetFilter filter can be included using this precomputed distances.
|
protected abstract boolean |
isDataWritable()
Returns whether this filter's data can be written to a text stream.
|
void |
write(java.io.OutputStream stream)
Writes this distances filter into the output text stream.
|
protected abstract void |
writeData(java.io.OutputStream stream)
Store this filter's data to a text stream.
|
protected PrecomputedDistancesFilter()
protected PrecomputedDistancesFilter(BinaryInput input, BinarySerializator serializator) throws java.io.IOException
input
- the input to read the PrecomputedDistancesFilter fromserializator
- the serializator used to write objectsjava.io.IOException
- if there was an I/O error reading from the inputpublic final float getPrecomputedDistance(LocalAbstractObject obj)
obj
,
an UNKNOWN_DISTANCE
is returned.obj
- the object for which the precomputed distance is returnedpublic abstract float getPrecomputedDistance(LocalAbstractObject obj, float[] metaDistances)
obj
,
an UNKNOWN_DISTANCE
is returned.
The metaDistances
are filled only if the array is not null
and this distance filter has the respective precomputed meta distances stored.obj
- the object for which the precomputed distance is returnedmetaDistances
- the array that is filled with the distances of the respective encapsulated objects, if it is not nullpublic abstract boolean excludeUsingPrecompDist(PrecomputedDistancesFilter targetFilter, float radius)
LocalAbstractObject.excludeUsingPrecompDist(messif.objects.LocalAbstractObject, float)
for full explanation.targetFilter
- the target precomputed distancesradius
- the radius to check the precomputed distances forpublic abstract boolean includeUsingPrecompDist(PrecomputedDistancesFilter targetFilter, float radius)
LocalAbstractObject.includeUsingPrecompDist(messif.objects.LocalAbstractObject, float)
for full explanation.targetFilter
- the target precomputed distancesradius
- the radius to check the precomputed distances forprotected abstract boolean addPrecomputedDistance(LocalAbstractObject obj, float distance, float[] metaDistances)
obj
- the object the distance to which is addeddistance
- the distance to addmetaDistances
- the array that is filled with the distances of the respective encapsulated objects
(it is null if the object does not have meta distances)public final void write(java.io.OutputStream stream) throws java.io.IOException
#filter filterClass filter value
stream
- the stream to write the key tojava.io.IOException
- if any problem occurs during comment writingprotected abstract void writeData(java.io.OutputStream stream) throws java.io.IOException
stream
- the stream to store this object tojava.io.IOException
- if there was an error while writing to streamprotected abstract boolean isDataWritable()
writeData(java.io.OutputStream)
should
provide a valid writing implementation.public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
- if this object cannot be cloned.public int binarySerialize(BinaryOutput output, BinarySerializator serializator) throws java.io.IOException
output
.binarySerialize
in interface BinarySerializable
output
- the output that this object is binary-serialized intoserializator
- the serializator used to write objectsjava.io.IOException
- if there was an I/O error during serializationpublic int getBinarySize(BinarySerializator serializator)
getBinarySize
in interface BinarySerializable
serializator
- the serializator used to write objects