public class KNNQueryOperation extends RankingSingleQueryOperation
k
objects that are nearest to the specified query object
(according to the distance measure).QueryOperation.DataEqualOperation
AbstractOperation.OperationConstructor, AbstractOperation.OperationName
Modifier and Type | Field and Description |
---|---|
protected int |
k
Number of nearest objects to retrieve
|
suppData, uuidOperationComparator
Constructor and Description |
---|
KNNQueryOperation(LocalAbstractObject queryObject,
int k)
Creates a new instance of kNNQueryOperation for a given query object and maximal number of objects to return.
|
KNNQueryOperation(LocalAbstractObject queryObject,
int k,
AnswerType answerType)
Creates a new instance of kNNQueryOperation for a given query object and maximal number of objects to return.
|
KNNQueryOperation(LocalAbstractObject queryObject,
int k,
boolean storeMetaDistances,
AnswerType answerType)
Creates a new instance of kNNQueryOperation for a given query object and maximal number of objects to return.
|
KNNQueryOperation(LocalAbstractObject queryObject,
int k,
boolean storeMetaDistances,
AnswerType answerType,
RankedSortedCollection answerCollection)
Creates a new instance of kNNQueryOperation for a given query object and maximal number of objects to return.
|
Modifier and Type | Method and Description |
---|---|
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.
|
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 |
getK()
Returns the number of nearest objects to retrieve.
|
addToAnswer, addToAnswer, clearSurplusData, clone, createOperation, getQueryObject, isStoringMetaDistances
addToAnswer, endOperation, 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
public KNNQueryOperation(LocalAbstractObject queryObject, int k)
no-data objects
.queryObject
- the object to which the nearest neighbors are searchedk
- the number of nearest neighbors to retrievepublic KNNQueryOperation(LocalAbstractObject queryObject, int k, AnswerType answerType)
queryObject
- the object to which the nearest neighbors are searchedk
- the number of nearest neighbors to retrieveanswerType
- the type of objects this operation stores in its answerpublic KNNQueryOperation(LocalAbstractObject queryObject, int k, boolean storeMetaDistances, AnswerType answerType)
queryObject
- the object to which the nearest neighbors are searchedk
- the number of nearest neighbors to retrievestoreMetaDistances
- if true, all processed meta objects
will
store their sub-distances
in the answeranswerType
- the type of objects this operation stores in its answerpublic KNNQueryOperation(LocalAbstractObject queryObject, int k, boolean storeMetaDistances, AnswerType answerType, RankedSortedCollection answerCollection)
queryObject
- the object to which the nearest neighbors are searchedk
- the number of nearest neighbors to retrievestoreMetaDistances
- if true, all processed meta objects
will
store their sub-distances
in the answeranswerType
- the type of objects this operation stores in its answeranswerCollection
- collection to be used as answer (it must be empty, otherwise it will be cleared)public int getK()
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 int evaluate(AbstractObjectIterator<? extends LocalAbstractObject> objects)
RankingSingleQueryOperation.addToAnswer(messif.objects.LocalAbstractObject, float)
.evaluate
in class QueryOperation<RankedAbstractObject>
objects
- the collection of objects on which to evaluate this queryprotected 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>