public class IncrementalNNQueryOperation extends RankingSingleQueryOperation
references
to the original
object.
The behavior of an algorithm implementing this operation must hold the following contract:HAS_NEXT
error code by calling
endOperation
method.RESPONSE_RETURNED
error code.
This eror code is set automaticly if endOperation
is not called with a specific value.wasSuccessful()
returns true
if the error code was set either to HAS_NEXT or RESPONSE_RETURNED.QueryOperation.DataEqualOperation
AbstractOperation.OperationConstructor, AbstractOperation.OperationName
Modifier and Type | Field and Description |
---|---|
protected int |
minNN
Minimum number of objects returned by this query.
|
protected int |
nnAddedToAnswer
The number of nearest neighbors added to the answer since the last call to endOperation().
|
suppData, uuidOperationComparator
Constructor and Description |
---|
IncrementalNNQueryOperation(LocalAbstractObject queryObject)
Creates a new instance of IncrementalNNQueryOperation.
|
IncrementalNNQueryOperation(LocalAbstractObject queryObject,
int minNN)
Creates a new instance of IncrementalNNQueryOperation.
|
IncrementalNNQueryOperation(LocalAbstractObject queryObject,
int minNN,
AnswerType answerType)
Creates a new instance of IncrementalNNQueryOperation.
|
Modifier and Type | Method and Description |
---|---|
RankedAbstractObject |
addToAnswer(LocalAbstractObject object,
float distThreshold)
Adds an object to the answer.
|
protected boolean |
dataEqualsImpl(QueryOperation obj)
Indicates whether some other operation has the same data as this one.
|
int |
dataHashCode()
Returns a hash code value for the data of this operation.
|
void |
endOperation(ErrorCode errValue)
End operation with a specific error code.
|
int |
evaluate(AbstractObjectIterator<? extends LocalAbstractObject> objects)
Evaluate this query on a given set of objects.
|
java.lang.Object |
getArgument(int index)
Returns argument that was passed while constructing instance.
|
int |
getArgumentCount()
Returns number of arguments that were passed while constructing this instance.
|
int |
getMinNN()
Returns the minimum number of objects returned by this query.
|
boolean |
isFilledEnough()
Returns true if the minimum number of objects has been inserted to
the answer during one evaluation of this operation.
|
addToAnswer, clearSurplusData, clone, createOperation, getQueryObject, isStoringMetaDistances
addToAnswer, getAnswer, getAnswer, getAnswerClass, getAnswerCollectionClass, getAnswerCollectionClone, getAnswerComparator, getAnswerCount, getAnswerDistance, getAnswerDistanceRestricted, getAnswerDistanceRestricted, getAnswerMaximalCapacity, getAnswerObjects, getAnswerThreshold, getLastAnswer, getSubAnswer, getSubAnswer, getSubAnswerCount, isAnswerFull, resetAnswer, setAnswerCollection, setAnswerIgnoringDuplicates, setAnswerThresholdComputation, setAnswerThresholdComputation, updateFrom, updateFrom
appendErrorCode, clone, dataEquals, endOperation, getAllSubAnswers, getAnswerType, getQueryAnswer, iterator, setAnswerType, wasSuccessful
appendArguments, containsParameter, createOperation, equals, getAnnotatedConstructor, getAnnotatedConstructor, getArgumentString, getConstructorArgumentDescriptions, getConstructorArgumentDescriptions, getConstructorArguments, getConstructorArguments, getConstructorDescription, getErrorCode, getName, getName, getOperationID, getParameter, getParameter, getParameter, getParameterCount, getParameterMap, getParameterNames, getRequiredParameter, getRequiredParameter, hashCode, isErrorCode, isFinished, removeParameter, setParameter, toString
protected final int minNN
protected int nnAddedToAnswer
public IncrementalNNQueryOperation(LocalAbstractObject queryObject)
AnswerType.NODATA_OBJECTS
will be returned in the result.queryObject
- the object to which the nearest neighbors are searchedpublic IncrementalNNQueryOperation(LocalAbstractObject queryObject, int minNN)
AnswerType.NODATA_OBJECTS
will be returned in the result.queryObject
- the object to which the nearest neighbors are searchedminNN
- the minimal number of nearest neighbors to retrievepublic IncrementalNNQueryOperation(LocalAbstractObject queryObject, int minNN, AnswerType answerType)
queryObject
- the object to which the nearest neighbors are searchedminNN
- the minimal number of nearest neighbors to retrieveanswerType
- the type of objects this operation stores in its answerpublic int getMinNN()
public java.lang.Object getArgument(int index) throws java.lang.IndexOutOfBoundsException
getArgument
in class AbstractOperation
index
- index of an argument passed to constructorjava.lang.IndexOutOfBoundsException
- if index parameter is out of rangepublic int getArgumentCount()
getArgumentCount
in class AbstractOperation
public void endOperation(ErrorCode errValue) throws java.lang.IllegalArgumentException
endOperation
in class RankingQueryOperation
errValue
- the error code to setjava.lang.IllegalArgumentException
- if the specified error value is null or ErrorCode.NOT_SET
public int evaluate(AbstractObjectIterator<? extends LocalAbstractObject> objects)
addToAnswer(messif.objects.LocalAbstractObject, float)
.
Note that the incremental kNN search can't use filtering, because the maximal radius is unknownevaluate
in class QueryOperation<RankedAbstractObject>
objects
- the collection of objects on which to evaluate this querypublic boolean isFilledEnough()
public RankedAbstractObject addToAnswer(LocalAbstractObject object, float distThreshold)
RankingSingleQueryOperation
query object
and the specified object.addToAnswer
in class RankingSingleQueryOperation
object
- the object to adddistThreshold
- the threshold on distance;
if the computed distance exceeds the threshold (sharply),
the object is not added to the answerprotected boolean dataEqualsImpl(QueryOperation obj)
dataEqualsImpl
in class QueryOperation<RankedAbstractObject>
obj
- the reference object with which to compare.true
if this object has the same data as the obj
argument; false
otherwise.public int dataHashCode()
dataHashCode
in class QueryOperation<RankedAbstractObject>