messif.operations.query
Class AggregationFunctionQueryOperation

java.lang.Object
  extended by messif.operations.AbstractOperation
      extended by messif.operations.QueryOperation<RankedAbstractObject>
          extended by messif.operations.RankingQueryOperation
              extended by messif.operations.query.AggregationFunctionQueryOperation
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Clearable
Direct Known Subclasses:
TopCombinedQueryOperation

public class AggregationFunctionQueryOperation
extends RankingQueryOperation

Aggregation function kNN query operation. Allows to retrieve the best-matching k objects (metaobjects) from any storage using the AggregationFunction function to evalute the distance between the query object and the objects stored.

See Also:
MetaObject, AggregationFunction, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class messif.operations.AbstractOperation
AbstractOperation.DataEqualOperation, AbstractOperation.OperationConstructor, AbstractOperation.OperationName
 
Field Summary
protected  AggregationFunction aggregationFunction
          Threshold function for measuring the overall similarity
protected  int k
          Number of nearest (top) objects to retrieve
protected  MetaObject queryObject
          Query object (accessible directly)
 
Fields inherited from class messif.operations.QueryOperation
answerType
 
Fields inherited from class messif.operations.AbstractOperation
errValue, operID, suppData
 
Constructor Summary
AggregationFunctionQueryOperation(LocalAbstractObject queryObject, int k, AggregationFunction aggregationFunction)
          Creates a new instance of AggregationFunctionQueryOperation.
AggregationFunctionQueryOperation(LocalAbstractObject queryObject, int k, AggregationFunction aggregationFunction, AnswerType answerType, boolean storeMetaDistances)
          Creates a new instance of AggregationFunctionQueryOperation.
 
Method Summary
 void clearSurplusData()
          Clear non-messif data stored in operation.
protected  boolean dataEqualsImpl(AbstractOperation 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 (top) objects to retrieve.
 MetaObject getQueryObject()
          Returns the query (meta) object of this query operation.
 AggregationFunction getThresholdFunction()
          Returns the threshold function for measuring the overall similarity.
 
Methods inherited from class messif.operations.RankingQueryOperation
addToAnswer, addToAnswer, clone, getAnswer, getAnswer, getAnswerClass, getAnswerCount, getAnswerDistance, getAnswerObjects, getAnswerThreshold, getLastAnswer, isAnswerFull, isStoringMetaDistances, resetAnswer, setAnswerCollection, updateFrom, 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

queryObject

protected final MetaObject queryObject
Query object (accessible directly)


k

protected final int k
Number of nearest (top) objects to retrieve


aggregationFunction

protected final AggregationFunction aggregationFunction
Threshold function for measuring the overall similarity

Constructor Detail

AggregationFunctionQueryOperation

public AggregationFunctionQueryOperation(LocalAbstractObject queryObject,
                                         int k,
                                         AggregationFunction aggregationFunction)
Creates a new instance of AggregationFunctionQueryOperation. The query object should be MetaObject to make the agg. function meaningful The parameter names for the aggregation should match the names in the MetaObject.

Parameters:
queryObject - the query object
k - the number of results to retrieve
aggregationFunction - the aggregation function for combining the distances from sorted lists

AggregationFunctionQueryOperation

public AggregationFunctionQueryOperation(LocalAbstractObject queryObject,
                                         int k,
                                         AggregationFunction aggregationFunction,
                                         AnswerType answerType,
                                         boolean storeMetaDistances)
Creates a new instance of AggregationFunctionQueryOperation. The query object should be MetaObject to make the agg. function meaningful The parameter names for the aggregation should match the names in the MetaObject.

Parameters:
queryObject - the query object
k - the number of results to retrieve
aggregationFunction - the aggregation function for combining the distances from sorted lists
answerType - the type of objects this operation stores in its answer
storeMetaDistances - if true, all processed meta objects will
Method Detail

getArgument

public java.lang.Object getArgument(int index)
                             throws java.lang.IndexOutOfBoundsException
Returns argument that was passed while constructing instance. If the argument is not stored within operation, null is returned.

Overrides:
getArgument in class AbstractOperation
Parameters:
index - index of an argument passed to constructor
Returns:
argument that was passed while constructing instance
Throws:
java.lang.IndexOutOfBoundsException - if index parameter is out of range

getArgumentCount

public int getArgumentCount()
Returns number of arguments that were passed while constructing this instance.

Overrides:
getArgumentCount in class AbstractOperation
Returns:
number of arguments that were passed while constructing this instance

getQueryObject

public MetaObject getQueryObject()
Returns the query (meta) object of this query operation.

Returns:
the query (meta) object of this query operation

getK

public int getK()
Returns the number of nearest (top) objects to retrieve.

Returns:
the number of nearest (top) objects to retrieve

getThresholdFunction

public AggregationFunction getThresholdFunction()
Returns the threshold function for measuring the overall similarity.

Returns:
the threshold function for measuring the overall similarity

evaluate

public int evaluate(AbstractObjectIterator<? extends LocalAbstractObject> objects)
Evaluate this query on a given set of objects. The objects found by this evaluation are added to answer of this query via RankingQueryOperation.addToAnswer(messif.objects.LocalAbstractObject, messif.objects.LocalAbstractObject, float).

Specified by:
evaluate in class QueryOperation<RankedAbstractObject>
Parameters:
objects - the collection of objects on which to evaluate this query
Returns:
number of objects satisfying the query

clearSurplusData

public void clearSurplusData()
Clear non-messif data stored in operation. This method is intended to be called whenever the operation is sent back to client in order to minimize problems with unknown classes after deserialization.

Specified by:
clearSurplusData in interface Clearable
Overrides:
clearSurplusData in class RankingQueryOperation

dataEqualsImpl

protected boolean dataEqualsImpl(AbstractOperation obj)
Indicates whether some other operation has the same data as this one.

Specified by:
dataEqualsImpl in class AbstractOperation
Parameters:
obj - the reference object with which to compare.
Returns:
true if this object has the same data as the obj argument; false otherwise.

dataHashCode

public int dataHashCode()
Returns a hash code value for the data of this operation.

Specified by:
dataHashCode in class AbstractOperation
Returns:
a hash code value for the data of this operation