|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmessif.operations.AbstractOperation
messif.operations.QueryOperation<RankedAbstractObject>
messif.operations.RankingQueryOperation
public abstract class RankingQueryOperation
The base class for query operations that return objects
ranked by a distance. For example, all basic metric queries are ranking, since
range or k-nearest neighbor queries return objects ranked according to their
distance to the query object.
Each object in the answer must implement a DistanceRanked
interface
that provides access to the distance of the particular answer.
Note that the distance only makes sense in the context of a query.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class messif.operations.AbstractOperation |
---|
AbstractOperation.DataEqualOperation, AbstractOperation.OperationConstructor, AbstractOperation.OperationName |
Field Summary |
---|
Fields inherited from class messif.operations.QueryOperation |
---|
answerType |
Fields inherited from class messif.operations.AbstractOperation |
---|
errValue, operID, suppData |
Constructor Summary | |
---|---|
protected |
RankingQueryOperation()
Creates a new instance of RankingQueryOperation. |
protected |
RankingQueryOperation(AnswerType answerType,
int maxAnswerSize)
Creates a new instance of RankingQueryOperation. |
protected |
RankingQueryOperation(AnswerType answerType,
int maxAnswerSize,
boolean storeMetaDistances)
Creates a new instance of RankingQueryOperation. |
protected |
RankingQueryOperation(int maxAnswerSize)
Creates a new instance of RankingQueryOperation. |
Method Summary | |
---|---|
RankedAbstractObject |
addToAnswer(AbstractObject object,
float distance,
float[] objectDistances)
Add a distance-ranked object to the answer. |
RankedAbstractObject |
addToAnswer(LocalAbstractObject queryObject,
LocalAbstractObject object,
float distThreshold)
Add an object to the answer. |
void |
clearSurplusData()
Clear non-messif data stored in operation. |
RankingQueryOperation |
clone()
Create a duplicate of this operation. |
java.util.Iterator<RankedAbstractObject> |
getAnswer()
Returns an iterator over all objects in the answer to this query. |
java.util.Iterator<RankedAbstractObject> |
getAnswer(int skip,
int count)
Returns an iterator over all objects in the answer skipping the first skip items and returning only count elements. |
java.lang.Class<? extends RankedAbstractObject> |
getAnswerClass()
Returns the class of objects this operation stores in its answer. |
int |
getAnswerCount()
Returns the number of objects in this query answer. |
float |
getAnswerDistance()
Returns the distance of the last object in the answer. |
java.util.Iterator<AbstractObject> |
getAnswerObjects()
Returns an iterator over all AbstractObject s in the answer to this query. |
float |
getAnswerThreshold()
Returns the threshold distance for the current answer of this query. |
RankedAbstractObject |
getLastAnswer()
Returns the current last ranked object in the answer. |
boolean |
isAnswerFull()
Returns true if the current answer has reached the maximal number of objects, i.e., the maxAnswerSize
specified in constructor. |
boolean |
isStoringMetaDistances()
Returns true if sub-distances for metaobjects are stored in the answer. |
void |
resetAnswer()
Reset the current query answer. |
void |
setAnswerCollection(RankedSortedCollection collection)
Set a new collection that maintains the answer list of this ranking query. |
void |
updateFrom(AbstractOperation operation)
Update the error code and answer of this operation from another operation. |
protected void |
updateFrom(RankingQueryOperation operation)
Update the answer of this operation from a RankingQueryOperation . |
Methods inherited from class messif.operations.QueryOperation |
---|
appendErrorCode, endOperation, evaluate, getAnswerType, wasSuccessful |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
protected RankingQueryOperation()
changed to no-data objects
.
Unlimited number of objects can be added to the answer.
protected RankingQueryOperation(int maxAnswerSize) throws java.lang.IllegalArgumentException
changed to no-data objects
.
maxAnswerSize
- sets the maximal answer size
java.lang.IllegalArgumentException
- if the maximal answer size is negativeprotected RankingQueryOperation(AnswerType answerType, int maxAnswerSize) throws java.lang.IllegalArgumentException
answerType
- the type of objects this operation stores in its answermaxAnswerSize
- sets the maximal answer size
java.lang.IllegalArgumentException
- if the maximal answer size is negativeprotected RankingQueryOperation(AnswerType answerType, int maxAnswerSize, boolean storeMetaDistances) throws java.lang.IllegalArgumentException
answerType
- the type of objects this operation stores in its answermaxAnswerSize
- sets the maximal answer sizestoreMetaDistances
- if true, all processed meta objects
will
store their sub-distances
in the answer
java.lang.IllegalArgumentException
- if the maximal answer size is negativeMethod Detail |
---|
public RankingQueryOperation clone() throws java.lang.CloneNotSupportedException
clone
in class AbstractOperation
java.lang.CloneNotSupportedException
- if the operation instance cannot be clonedpublic void setAnswerCollection(RankedSortedCollection collection)
collection
- a new instance of answer collectionpublic java.lang.Class<? extends RankedAbstractObject> getAnswerClass()
QueryOperation
getAnswerClass
in class QueryOperation<RankedAbstractObject>
public int getAnswerCount()
QueryOperation
getAnswerCount
in class QueryOperation<RankedAbstractObject>
public java.util.Iterator<RankedAbstractObject> getAnswer()
QueryOperation
getAnswer
in class QueryOperation<RankedAbstractObject>
public java.util.Iterator<RankedAbstractObject> getAnswer(int skip, int count)
QueryOperation
skip
items and returning only count
elements. If count
is less than or equal to zero, all objects from the answer (except for
skip
) are returned.
getAnswer
in class QueryOperation<RankedAbstractObject>
skip
- number of answer objects to skipcount
- number of answer objects to iterate (maximally, actual number of results can be smaller)
public java.util.Iterator<AbstractObject> getAnswerObjects()
QueryOperation
AbstractObject
s in the answer to this query.
This method unwraps the objects from the results.
getAnswerObjects
in class QueryOperation<RankedAbstractObject>
AbstractObject
s in the answer to this querypublic RankedAbstractObject getLastAnswer() throws java.util.NoSuchElementException
java.util.NoSuchElementException
- if the answer is emptypublic float getAnswerDistance() throws java.util.NoSuchElementException
java.util.NoSuchElementException
- if the answer is emptypublic boolean isAnswerFull()
maxAnswerSize
specified in constructor.
public float getAnswerThreshold()
LocalAbstractObject.MAX_DISTANCE
is returned.
Otherwise, the distance of the last answer's object is returned.
LocalAbstractObject.MAX_DISTANCE
if there are not enough objects.public boolean isStoringMetaDistances()
public RankedAbstractObject addToAnswer(LocalAbstractObject queryObject, LocalAbstractObject object, float distThreshold)
queryObject
- the query object against which to compute the distance (rank)object
- the object to adddistThreshold
- the threshold on distance;
if the computed distance exceeds the threshold (sharply),
the object is not added to the answer
public final RankedAbstractObject addToAnswer(AbstractObject object, float distance, float[] objectDistances) throws java.lang.IllegalArgumentException
object
- the object to adddistance
- the distance of objectobjectDistances
- the array of distances to the respective sub-objects (can be null)
java.lang.IllegalArgumentException
- if the answer type of this operation requires clonning but the passed object cannot be clonedpublic void resetAnswer()
getAnswerCount()
will return zero.
resetAnswer
in class QueryOperation<RankedAbstractObject>
public final void updateFrom(AbstractOperation operation) throws java.lang.IllegalArgumentException
updateFrom
in class AbstractOperation
operation
- the source operation from which to get the update
java.lang.IllegalArgumentException
- if the answer of the specified operation is incompatible with this oneprotected void updateFrom(RankingQueryOperation operation)
RankingQueryOperation
.
operation
- the source operation from which to get the updatepublic void clearSurplusData()
clearSurplusData
in interface Clearable
clearSurplusData
in class AbstractOperation
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |