public class PrecomputedDistancesPivotMapFilter extends PrecomputedDistancesFilter
LocalAbstractObject
.
While filtering, this filter uses one stored distance against the respective
object from the map.
Note that this filter should not be used when the instances of referenced objects
are not in memory. Moreover, this filter cannot be written to text stream, since
the reference objects cannot be correctly resolved. However, a java serialization
or binary serialization
can be used.Modifier and Type | Field and Description |
---|---|
protected java.util.Map<LocalAbstractObject,java.lang.Float> |
precompDistMapping
The hash table of precomputed distances
|
Modifier | Constructor and Description |
---|---|
|
PrecomputedDistancesPivotMapFilter()
Creates a new instance of PrecomputedDistancesPivotMapFilter
|
protected |
PrecomputedDistancesPivotMapFilter(BinaryInput input,
BinarySerializator serializator)
Creates a new instance of PrecomputedDistancesPivotMapFilter loaded from binary input.
|
|
PrecomputedDistancesPivotMapFilter(LocalAbstractObject object)
Creates a new instance of PrecomputedDistancesPivotMapFilter
|
Modifier and Type | Method and Description |
---|---|
protected 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.
|
boolean |
excludeUsingPrecompDist(PrecomputedDistancesFilter targetFilter,
float radius)
Returns true if object associated with targetFilter filter can be excluded (filtered out) using this precomputed distances.
|
boolean |
excludeUsingPrecompDist(PrecomputedDistancesPivotMapFilter targetFilter,
float radius)
Return true if the obj has been filtered out using stored precomputed distance.
|
int |
getBinarySize(BinarySerializator serializator)
Returns the exact size of the binary-serialized version of this object in bytes.
|
int |
getPrecompDistSize()
Returns the number of stored precomputed distances.
|
java.util.Set<LocalAbstractObject> |
getPrecompObjects()
Return all objects to which this object has precomputed distances.
|
float |
getPrecomputedDistance(LocalAbstractObject obj,
float[] metaDistances)
Returns a precomputed distance to the given object and the respective meta distances
array.
|
boolean |
includeUsingPrecompDist(PrecomputedDistancesFilter targetFilter,
float radius)
Returns true if object associated with targetFilter filter can be included using this precomputed distances.
|
boolean |
includeUsingPrecompDist(PrecomputedDistancesPivotMapFilter targetFilter,
float radius)
Returns true if object associated with targetFilter filter can be included using this precomputed distances.
|
protected boolean |
isDataWritable()
Returns whether this filter's data can be written to a text stream.
|
void |
resetAllPrecompDist()
Removes all precomputed distances.
|
boolean |
resetPrecompDist(LocalAbstractObject obj)
Resets the precomputed distance to given object (pivot).
|
boolean |
setPrecompDist(LocalAbstractObject obj,
float dist)
Associates a precomputed distance to an object with this object
Function appends the new distance 'dist' from the object 'obj'
or replaces the old value of distance.
|
protected void |
writeData(java.io.OutputStream stream)
Store this filter's data to a text stream.
|
getPrecomputedDistance, write
protected final java.util.Map<LocalAbstractObject,java.lang.Float> precompDistMapping
public PrecomputedDistancesPivotMapFilter()
public PrecomputedDistancesPivotMapFilter(LocalAbstractObject object)
object
- the object to which to add this filterprotected PrecomputedDistancesPivotMapFilter(BinaryInput input, BinarySerializator serializator) throws java.io.IOException
input
- the input to read the PrecomputedDistancesPivotMapFilter fromserializator
- the serializator used to write objectsjava.io.IOException
- if there was an I/O error reading from the inputprotected boolean isDataWritable()
PrecomputedDistancesFilter
PrecomputedDistancesFilter.writeData(java.io.OutputStream)
should
provide a valid writing implementation.isDataWritable
in class PrecomputedDistancesFilter
protected void writeData(java.io.OutputStream stream) throws java.io.IOException
PrecomputedDistancesFilter
writeData
in class PrecomputedDistancesFilter
stream
- the stream to store this object tojava.io.IOException
- if there was an error while writing to streampublic boolean setPrecompDist(LocalAbstractObject obj, float dist)
obj
- the object for which to add distancedist
- the distance to addprotected boolean addPrecomputedDistance(LocalAbstractObject obj, float distance, float[] metaDistances)
PrecomputedDistancesFilter
addPrecomputedDistance
in class PrecomputedDistancesFilter
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 boolean resetPrecompDist(LocalAbstractObject obj)
obj
- Object to which the precomputed distance is stored.public void resetAllPrecompDist()
public int getPrecompDistSize()
public final boolean excludeUsingPrecompDist(PrecomputedDistancesFilter targetFilter, float radius)
PrecomputedDistancesFilter
LocalAbstractObject.excludeUsingPrecompDist(messif.objects.LocalAbstractObject, float)
for full explanation.excludeUsingPrecompDist
in class PrecomputedDistancesFilter
targetFilter
- the target precomputed distancesradius
- the radius to check the precomputed distances forpublic boolean excludeUsingPrecompDist(PrecomputedDistancesPivotMapFilter targetFilter, float radius)
targetFilter
- the target precomputed distancesradius
- the radius to check the precomputed distances forpublic final boolean includeUsingPrecompDist(PrecomputedDistancesFilter targetFilter, float radius)
PrecomputedDistancesFilter
LocalAbstractObject.includeUsingPrecompDist(messif.objects.LocalAbstractObject, float)
for full explanation.includeUsingPrecompDist
in class PrecomputedDistancesFilter
targetFilter
- the target precomputed distancesradius
- the radius to check the precomputed distances forpublic boolean includeUsingPrecompDist(PrecomputedDistancesPivotMapFilter targetFilter, float radius)
LocalAbstractObject.includeUsingPrecompDist(messif.objects.LocalAbstractObject, float)
for full explanation.targetFilter
- the target precomputed distancesradius
- the radius to check the precomputed distances forpublic float getPrecomputedDistance(LocalAbstractObject obj, float[] metaDistances)
PrecomputedDistancesFilter
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.getPrecomputedDistance
in class PrecomputedDistancesFilter
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 java.util.Set<LocalAbstractObject> getPrecompObjects()
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
PrecomputedDistancesFilter
clone
in class PrecomputedDistancesFilter
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
binarySerialize
in class PrecomputedDistancesFilter
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
getBinarySize
in class PrecomputedDistancesFilter
serializator
- the serializator used to write objects