messif.operations.query
Class ApproxKNNQueryOperation

java.lang.Object
  extended by messif.operations.AbstractOperation
      extended by messif.operations.QueryOperation<RankedAbstractObject>
          extended by messif.operations.RankingQueryOperation
              extended by messif.operations.query.KNNQueryOperation
                  extended by messif.operations.query.ApproxKNNQueryOperation
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Clearable

public class ApproxKNNQueryOperation
extends KNNQueryOperation

Approximate k-nearest neighbors query with specific early termination parameters and support for obtaining some guarantees on results.

See Also:
Serialized Form

Nested Class Summary
static class ApproxKNNQueryOperation.LocalSearchType
          Enumeration of types of the stop condition for approximation's early termination strategy.
 
Nested classes/interfaces inherited from class messif.operations.AbstractOperation
AbstractOperation.DataEqualOperation, AbstractOperation.OperationConstructor, AbstractOperation.OperationName
 
Field Summary
protected  int localSearchParam
          Value of the local approximation parameter.
protected  ApproxKNNQueryOperation.LocalSearchType localSearchType
          Type of the local approximation parameter used.
protected  float radiusGuaranteed
          Radius for which the answer is guaranteed as correct.
 
Fields inherited from class messif.operations.query.KNNQueryOperation
k, queryObject
 
Fields inherited from class messif.operations.QueryOperation
answerType
 
Fields inherited from class messif.operations.AbstractOperation
errValue, operID, suppData
 
Constructor Summary
ApproxKNNQueryOperation(LocalAbstractObject queryObject, int k)
          Creates a new instance of ApproxkNNQueryOperation for a given query object and maximal number of objects to return.
ApproxKNNQueryOperation(LocalAbstractObject queryObject, int k, AnswerType answerType)
          Creates a new instance of ApproxkNNQueryOperation for a given query object and maximal number of objects to return.
ApproxKNNQueryOperation(LocalAbstractObject queryObject, int k, AnswerType answerType, int localSearchParam, ApproxKNNQueryOperation.LocalSearchType localSearchType, float radiusGuaranteed)
          Creates a new instance of ApproxKNNQueryOperation for a given query object, maximal number of objects to return and parameters that control the approximation.
ApproxKNNQueryOperation(LocalAbstractObject queryObject, int k, boolean storeMetaDistances, AnswerType answerType, int localSearchParam, ApproxKNNQueryOperation.LocalSearchType localSearchType, float radiusGuaranteed)
          Creates a new instance of ApproxKNNQueryOperation for a given query object, maximal number of objects to return and parameters that control the approximation.
ApproxKNNQueryOperation(LocalAbstractObject queryObject, int k, int localSearchParam, ApproxKNNQueryOperation.LocalSearchType localSearchType, float radiusGuaranteed)
          Creates a new instance of ApproxKNNQueryOperation for a given query object, maximal number of objects to return and parameters that control the approximation.
 
Method Summary
 int getLocalSearchParam()
          Returns the value of the local approximation parameter.
 ApproxKNNQueryOperation.LocalSearchType getLocalSearchType()
          Returns the type of the local approximation parameter used.
 float getRadiusGuaranteed()
          Returns a currently set value of radius within which the results are guaranteed as correct.
 void setLocalSearchParam(int localSearchParam)
          Setter for the local search parameter localSearchParam
 void setLocalSearchType(ApproxKNNQueryOperation.LocalSearchType localSearchType)
          Setter for the type of the local search parameter localSearchType
 void setRadiusGuaranteed(float radiusGuaranteed)
          Set a different value of radius within which the results are guaranteed as correct.
protected  void updateFrom(ApproxKNNQueryOperation operation)
          Updates the guaranteed radius from another approximate kNN query.
protected  void updateFrom(RankingQueryOperation operation)
          Update query answer data of this operation from another query operation.
 
Methods inherited from class messif.operations.query.KNNQueryOperation
clearSurplusData, dataEqualsImpl, dataHashCode, evaluate, getArgument, getArgumentCount, getK, getQueryObject
 
Methods inherited from class messif.operations.RankingQueryOperation
addToAnswer, addToAnswer, clone, getAnswer, getAnswer, getAnswerClass, getAnswerCount, getAnswerDistance, getAnswerObjects, getAnswerThreshold, getLastAnswer, isAnswerFull, isStoringMetaDistances, resetAnswer, setAnswerCollection, updateFrom
 
Methods inherited from class messif.operations.QueryOperation
appendErrorCode, endOperation, getAnswerType, wasSuccessful
 
Methods inherited from class messif.operations.AbstractOperation
appendArguments, createOperation, dataEquals, endOperation, equals, getAnnotatedConstructor, getAnnotatedConstructor, getConstructorArgumentDescriptions, getConstructorArgumentDescriptions, getConstructorArguments, getConstructorArguments, getConstructorDescription, getErrorCode, getName, getName, getOperationID, hashCode, isFinished, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

localSearchType

protected ApproxKNNQueryOperation.LocalSearchType localSearchType
Type of the local approximation parameter used.


localSearchParam

protected int localSearchParam
Value of the local approximation parameter. Its interpretation depends on the value of localSearchType.


radiusGuaranteed

protected float radiusGuaranteed
Radius for which the answer is guaranteed as correct. It is specified in the constructor and can influence the level of approximation. An algorithm evaluating this query can also change this value, so it can notify about the guarantees of evaluation.

Constructor Detail

ApproxKNNQueryOperation

public ApproxKNNQueryOperation(LocalAbstractObject queryObject,
                               int k)
Creates a new instance of ApproxkNNQueryOperation for a given query object and maximal number of objects to return. The approximation parameters are set to reasonable default values. AnswerType.NODATA_OBJECTS will be returned in the result.

Parameters:
queryObject - query object
k - number of objects to be returned

ApproxKNNQueryOperation

public ApproxKNNQueryOperation(LocalAbstractObject queryObject,
                               int k,
                               AnswerType answerType)
Creates a new instance of ApproxkNNQueryOperation for a given query object and maximal number of objects to return. The approximation parameters are set to reasonable default values.

Parameters:
queryObject - the object to which the nearest neighbors are searched
k - the number of nearest neighbors to retrieve
answerType - the type of objects this operation stores in its answer

ApproxKNNQueryOperation

public ApproxKNNQueryOperation(LocalAbstractObject queryObject,
                               int k,
                               int localSearchParam,
                               ApproxKNNQueryOperation.LocalSearchType localSearchType,
                               float radiusGuaranteed)
Creates a new instance of ApproxKNNQueryOperation for a given query object, maximal number of objects to return and parameters that control the approximation.

Parameters:
queryObject - query object
k - number of objects to be returned
localSearchParam - local search parameter - typically approximation parameter
localSearchType - type of the local search parameter
radiusGuaranteed - radius within which the answer is required to be guaranteed as correct

ApproxKNNQueryOperation

public ApproxKNNQueryOperation(LocalAbstractObject queryObject,
                               int k,
                               AnswerType answerType,
                               int localSearchParam,
                               ApproxKNNQueryOperation.LocalSearchType localSearchType,
                               float radiusGuaranteed)
Creates a new instance of ApproxKNNQueryOperation for a given query object, maximal number of objects to return and parameters that control the approximation.

Parameters:
queryObject - query object
k - number of objects to be returned
answerType - the type of objects this operation stores in its answer
localSearchParam - local search parameter - typically approximation parameter
localSearchType - type of the local search parameter
radiusGuaranteed - radius within which the answer is required to be guaranteed as correct

ApproxKNNQueryOperation

public ApproxKNNQueryOperation(LocalAbstractObject queryObject,
                               int k,
                               boolean storeMetaDistances,
                               AnswerType answerType,
                               int localSearchParam,
                               ApproxKNNQueryOperation.LocalSearchType localSearchType,
                               float radiusGuaranteed)
Creates a new instance of ApproxKNNQueryOperation for a given query object, maximal number of objects to return and parameters that control the approximation.

Parameters:
queryObject - query object
k - number of objects to be returned
storeMetaDistances - if true, all processed meta objects will store their sub-distances in the answer
answerType - the type of objects this operation stores in its answer
localSearchParam - local search parameter - typically approximation parameter
localSearchType - type of the local search parameter
radiusGuaranteed - radius within which the answer is required to be guaranteed as correct
Method Detail

getLocalSearchType

public ApproxKNNQueryOperation.LocalSearchType getLocalSearchType()
Returns the type of the local approximation parameter used.

Returns:
the type of the local approximation parameter used

setLocalSearchParam

public void setLocalSearchParam(int localSearchParam)
Setter for the local search parameter localSearchParam

Parameters:
localSearchParam - new local search parameter localSearchParam

setLocalSearchType

public void setLocalSearchType(ApproxKNNQueryOperation.LocalSearchType localSearchType)
Setter for the type of the local search parameter localSearchType

Parameters:
localSearchType - new localSearchType

getLocalSearchParam

public int getLocalSearchParam()
Returns the value of the local approximation parameter. Its interpretation depends on the value of local search type.

Returns:
the value of the local approximation parameter

setRadiusGuaranteed

public void setRadiusGuaranteed(float radiusGuaranteed)
Set a different value of radius within which the results are guaranteed as correct. An evaluation algorithm is completely responsible for setting the correct value.

Parameters:
radiusGuaranteed - new guaranteed radius value

getRadiusGuaranteed

public float getRadiusGuaranteed()
Returns a currently set value of radius within which the results are guaranteed as correct. An evaluation algorithm is completely responsible for setting the correct value.

Returns:
the value of the currently guaranteed radius

updateFrom

protected void updateFrom(RankingQueryOperation operation)
Update query answer data of this operation from another query operation. Additionally, if the operation is approximate kNN query, the radius guaranteed is also updated.

Overrides:
updateFrom in class RankingQueryOperation
Parameters:
operation - the operation to update answer from

updateFrom

protected void updateFrom(ApproxKNNQueryOperation operation)
Updates the guaranteed radius from another approximate kNN query. That is, if the guaranteed radius of the other query is smaller, this query's one is reduced.

Parameters:
operation - the operation to update answer from