messif.operations.query
Class RangeQueryOperation

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

public class RangeQueryOperation
extends RankingQueryOperation

Range query operation. Retrieves all objects that have their distances to the specified query object less than or equal to the specified radius.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class messif.operations.AbstractOperation
AbstractOperation.DataEqualOperation, AbstractOperation.OperationConstructor, AbstractOperation.OperationName
 
Field Summary
protected  LocalAbstractObject queryObject
          Range query object
protected  float radius
          Range query radius
 
Fields inherited from class messif.operations.QueryOperation
answerType
 
Fields inherited from class messif.operations.AbstractOperation
errValue, operID, suppData
 
Constructor Summary
RangeQueryOperation(LocalAbstractObject queryObject, float radius)
          Creates a new instance of RangeQueryOperation for a given query object and radius.
RangeQueryOperation(LocalAbstractObject queryObject, float radius, AnswerType answerType)
          Creates a new instance of RangeQueryOperation for a given query object and radius.
RangeQueryOperation(LocalAbstractObject queryObject, float radius, AnswerType answerType, boolean storeMetaDistances)
          Creates a new instance of RangeQueryOperation for a given query object and radius.
RangeQueryOperation(LocalAbstractObject queryObject, float radius, AnswerType answerType, int maxAnswerSize)
          Creates a new instance of RangeQueryOperation for a given query object, radius and maximal number of objects to return.
RangeQueryOperation(LocalAbstractObject queryObject, float radius, AnswerType answerType, int maxAnswerSize, boolean storeMetaDistances)
          Creates a new instance of RangeQueryOperation for a given query object, radius and maximal number of objects to return.
RangeQueryOperation(LocalAbstractObject queryObject, float radius, boolean storeMetaDistances)
          Creates a new instance of RangeQueryOperation for a given query object and radius.
RangeQueryOperation(LocalAbstractObject queryObject, float radius, int maxAnswerSize)
          Creates a new instance of RangeQueryOperation for a given query object, radius and maximal number of objects to return.
 
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.Class<? extends RankedAbstractObject> getAnswerClass()
          Returns the class of objects this operation stores in its answer.
 float getAnswerThreshold()
          Returns the threshold distance for the current answer of this query.
 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.
 LocalAbstractObject getQueryObject()
          Returns the query object of this range query.
 float getRadius()
          Returns the radius of this range query.
 
Methods inherited from class messif.operations.RankingQueryOperation
addToAnswer, addToAnswer, clone, getAnswer, getAnswer, getAnswerCount, getAnswerDistance, getAnswerObjects, 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 LocalAbstractObject queryObject
Range query object


radius

protected final float radius
Range query radius

Constructor Detail

RangeQueryOperation

public RangeQueryOperation(LocalAbstractObject queryObject,
                           float radius)
Creates a new instance of RangeQueryOperation for a given query object and radius. Reduced objects (NoDataObject) will be used.

Parameters:
queryObject - the query object
radius - the query radius

RangeQueryOperation

public RangeQueryOperation(LocalAbstractObject queryObject,
                           float radius,
                           boolean storeMetaDistances)
Creates a new instance of RangeQueryOperation for a given query object and radius. Reduced objects (NoDataObject) will be used.

Parameters:
queryObject - the query object
radius - the query radius
storeMetaDistances - if true, all processed meta objects will store their sub-distances in the answer

RangeQueryOperation

public RangeQueryOperation(LocalAbstractObject queryObject,
                           float radius,
                           AnswerType answerType)
Creates a new instance of RangeQueryOperation for a given query object and radius.

Parameters:
queryObject - the query object
radius - the query radius
answerType - the type of objects this operation stores in its answer

RangeQueryOperation

public RangeQueryOperation(LocalAbstractObject queryObject,
                           float radius,
                           AnswerType answerType,
                           boolean storeMetaDistances)
Creates a new instance of RangeQueryOperation for a given query object and radius.

Parameters:
queryObject - the query object
radius - the query radius
answerType - the type of objects this operation stores in its answer
storeMetaDistances - if true, all processed meta objects will store their sub-distances in the answer

RangeQueryOperation

public RangeQueryOperation(LocalAbstractObject queryObject,
                           float radius,
                           int maxAnswerSize)
Creates a new instance of RangeQueryOperation for a given query object, radius and maximal number of objects to return. Reduced objects (NoDataObject) will be used.

Parameters:
queryObject - the query object
radius - the query radius
maxAnswerSize - sets the maximal answer size

RangeQueryOperation

public RangeQueryOperation(LocalAbstractObject queryObject,
                           float radius,
                           AnswerType answerType,
                           int maxAnswerSize)
Creates a new instance of RangeQueryOperation for a given query object, radius and maximal number of objects to return.

Parameters:
queryObject - the query object
radius - the query radius
answerType - the type of objects this operation stores in its answer
maxAnswerSize - sets the maximal answer size

RangeQueryOperation

public RangeQueryOperation(LocalAbstractObject queryObject,
                           float radius,
                           AnswerType answerType,
                           int maxAnswerSize,
                           boolean storeMetaDistances)
Creates a new instance of RangeQueryOperation for a given query object, radius and maximal number of objects to return.

Parameters:
queryObject - the query object
radius - the query radius
answerType - the type of objects this operation stores in its answer
maxAnswerSize - sets the maximal answer size
storeMetaDistances - if true, all processed meta objects will store their sub-distances in the answer
Method Detail

getQueryObject

public LocalAbstractObject getQueryObject()
Returns the query object of this range query.

Returns:
the query object of this range query

getRadius

public float getRadius()
Returns the radius of this range query.

Returns:
the radius of this range query

getAnswerThreshold

public float getAnswerThreshold()
Returns the threshold distance for the current answer of this query. If the answer has not reached the maximal size (specified in constructor) yet, getRadius() is returned. Otherwise, the distance of the last answer's object is returned.

Overrides:
getAnswerThreshold in class RankingQueryOperation
Returns:
the distance to last object in the answer or getRadius() if there are not enough objects.

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

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

getAnswerClass

public java.lang.Class<? extends RankedAbstractObject> getAnswerClass()
Returns the class of objects this operation stores in its answer.

Overrides:
getAnswerClass in class RankingQueryOperation
Returns:
the class of objects this operation stores in its answer

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