public class JoinQueryOperation extends QueryOperation<RankedJoinObject>
mu
to each other
(according to object's distance function).
The top-k closest pairs can be retrieved by specifying the parameter k
.
It also supports approximate parameters for early termination.QueryOperation.DataEqualOperation
AbstractOperation.OperationConstructor, AbstractOperation.OperationName
Modifier and Type | Field and Description |
---|---|
protected int |
k
Number of nearest pairs to retrieve
|
protected float |
mu
Distance threshold
|
protected boolean |
skipSymmetricPairs
Flag whether symmetric pairs should be avoided in the answer
|
suppData, uuidOperationComparator
Constructor and Description |
---|
JoinQueryOperation(float mu)
Creates a new instance of JoinQueryOperation for a given distance threshold.
|
JoinQueryOperation(float mu,
boolean skipSymmetricPairs,
AnswerType answerType)
Creates a new instance of JoinQueryOperation for a given distance threshold and the flag whether symmetric pairs can be added or not.
|
JoinQueryOperation(float mu,
int k,
boolean skipSymmetricPairs)
Creates a new instance of JoinQueryOperation for a given distance threshold and maximal number of pairs to return.
|
JoinQueryOperation(float mu,
int k,
boolean skipSymmetricPairs,
AnswerType answerType)
Creates a new instance of JoinQueryOperation for a given distance threshold and maximal number of objects to return.
|
Modifier and Type | Method and Description |
---|---|
RankedJoinObject |
addToAnswer(LocalAbstractObject leftObject,
LocalAbstractObject rightObject)
Add a new pair of objects to the answer.
|
RankedJoinObject |
addToAnswer(LocalAbstractObject leftObject,
LocalAbstractObject rightObject,
float distThreshold)
Add a new pair of objects to the answer.
|
RankedJoinObject |
addToAnswer(LocalAbstractObject leftObject,
LocalAbstractObject rightObject,
float distance,
float distThreshold)
Add a new pair of objects to the answer.
|
void |
clearSurplusData()
Clear non-messif data stored in operation.
|
JoinQueryOperation |
clone(boolean preserveAnswer)
Create a duplicate of this operation.
|
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.
|
void |
endOperation(ErrorCode errValue)
End operation with a specific error code.
|
int |
evaluate(AbstractObjectIterator<? extends LocalAbstractObject> objects)
Evaluate this query on a given set of objects.
|
java.util.Iterator<RankedJoinObject> |
getAnswer()
Returns an iterator over all objects in the answer to this query.
|
java.util.Iterator<RankedJoinObject> |
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 RankedJoinObject> |
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<RankedJoinObject> |
getAnswerDistanceRestricted(float maxDistance)
Returns an iterator over all objects in the answer that are ranked lower
than the
maxDistance . |
java.util.Iterator<RankedJoinObject> |
getAnswerDistanceRestricted(float minDistance,
float maxDistance)
Returns an iterator over all objects in the answer that are ranked higher
than the
minDistance but lower than the maxDistance . |
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.
|
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.
|
float |
getDistanceThreshold()
Returns the threshold on distance between objects of a pair to qualify.
|
int |
getK()
Returns the maximum number of nearest pairs to retrieve.
|
RankedJoinObject |
getLastAnswer()
Returns the current last ranked object in the answer.
|
float |
getMu()
Returns the threshold on distance between objects of a pair to qualify.
|
java.util.Iterator<? extends RankedJoinObject> |
getSubAnswer(int index)
Returns an iterator over all objects in the answer sub-collection with the given index.
|
java.util.Iterator<? extends RankedJoinObject> |
getSubAnswer(java.lang.Object key)
Returns an iterator over all objects in the answer sub-collection with the given key.
|
int |
getSubAnswerCount()
Returns the number of answer sub-collections.
|
boolean |
isAnswerFull()
Returns true if the current answer has reached
the maximal number of objects, i.e., the
maxAnswerSize
specified in constructor. |
void |
resetAnswer()
Reset the current query answer.
|
void |
updateFrom(AbstractOperation operation)
Update the error code and answer of this operation from another operation.
|
protected void |
updateFrom(JoinQueryOperation operation)
Update the answer of this operation from a
JoinQueryOperation . |
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
protected final float mu
protected final int k
protected boolean skipSymmetricPairs
public JoinQueryOperation(float mu)
no-data objects
.mu
- the distance thresholdpublic JoinQueryOperation(float mu, boolean skipSymmetricPairs, AnswerType answerType)
no-data objects
.mu
- the distance thresholdskipSymmetricPairs
- flag whether symmetric pairs should be avoided in the answeranswerType
- the type of objects this operation stores in pairs in its answerpublic JoinQueryOperation(float mu, int k, boolean skipSymmetricPairs)
no-data objects
.mu
- the distance thresholdk
- the number of nearest pairs to retrieveskipSymmetricPairs
- flag whether symmetric pairs should be avoided in the answerpublic JoinQueryOperation(float mu, int k, boolean skipSymmetricPairs, AnswerType answerType)
mu
- the distance thresholdk
- the number of nearest pairs to retrieveskipSymmetricPairs
- flag whether symmetric pairs should be avoided in the answeranswerType
- the type of objects this operation stores in pairs in its answerpublic float getMu()
public final float getDistanceThreshold()
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)
addToAnswer(messif.objects.LocalAbstractObject, messif.objects.LocalAbstractObject)
.evaluate
in class QueryOperation<RankedJoinObject>
objects
- the collection of objects on which to evaluate this querypublic JoinQueryOperation clone(boolean preserveAnswer) throws java.lang.CloneNotSupportedException
QueryOperation
preserveAnswer
is true the answer is
not cloned but both this and the cloned operation share the same answer collection.clone
in class QueryOperation<RankedJoinObject>
preserveAnswer
- flag whether to clone the answer (false) or preserve
the same answer collection (true) in the cloned operationjava.lang.CloneNotSupportedException
- if the operation instance cannot be clonedpublic RankedJoinObject addToAnswer(LocalAbstractObject leftObject, LocalAbstractObject rightObject)
mu
.leftObject
- left object of the pairrightObject
- right object of the pairpublic RankedJoinObject addToAnswer(LocalAbstractObject leftObject, LocalAbstractObject rightObject, float distThreshold)
leftObject
- left object of the pairrightObject
- right object of the pairdistThreshold
- the threshold on distance;
if the computed distance exceeds the threshold (sharply) or the join constraint (threshold),
the pair is not addedpublic RankedJoinObject addToAnswer(LocalAbstractObject leftObject, LocalAbstractObject rightObject, float distance, float distThreshold)
leftObject
- left object of the pairrightObject
- right object of the pairdistance
- distance between the left and right objects (this distance is compared against the passed threshold as well as any internal join query threshold)distThreshold
- the threshold on distance;
if the computed distance exceeds the threshold (sharply) or the join constraint (threshold),
the pair is not addedpublic java.lang.Class<? extends RankedJoinObject> getAnswerClass()
QueryOperation
getAnswerClass
in class QueryOperation<RankedJoinObject>
public int getAnswerCount()
QueryOperation
getAnswerCount
in class QueryOperation<RankedJoinObject>
public java.util.Iterator<RankedJoinObject> getAnswer()
QueryOperation
getAnswer
in class QueryOperation<RankedJoinObject>
public java.util.Iterator<RankedJoinObject> 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<RankedJoinObject>
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<RankedJoinObject>
AbstractObject
s in the answer to this querypublic int getSubAnswerCount()
QueryOperation
getSubAnswerCount
in class QueryOperation<RankedJoinObject>
public java.util.Iterator<? extends RankedJoinObject> getSubAnswer(int index) throws java.lang.IndexOutOfBoundsException
QueryOperation
getSubAnswer
in class QueryOperation<RankedJoinObject>
index
- the index of the answer sub-collection to returnjava.lang.IndexOutOfBoundsException
- if the given index is negative or
greater or equal to QueryOperation.getSubAnswerCount()
public java.util.Iterator<? extends RankedJoinObject> getSubAnswer(java.lang.Object key)
QueryOperation
getSubAnswer
in class QueryOperation<RankedJoinObject>
key
- the key of the answer sub-collection to returnpublic java.util.Iterator<RankedJoinObject> getAnswerDistanceRestricted(float minDistance, float maxDistance)
minDistance
but lower than the maxDistance
.minDistance
- the minimal distance of the answer objects to returnmaxDistance
- the maximal distance of the answer objects to returnpublic java.util.Iterator<RankedJoinObject> getAnswerDistanceRestricted(float maxDistance)
maxDistance
.maxDistance
- the maximal distance of the answer objects to returnpublic RankedJoinObject 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 void resetAnswer()
QueryOperation
QueryOperation.getAnswerCount()
will return zero.resetAnswer
in class QueryOperation<RankedJoinObject>
public final void updateFrom(AbstractOperation operation) throws java.lang.IllegalArgumentException
updateFrom
in class AbstractOperation
operation
- the source operation from which to get the updatejava.lang.IllegalArgumentException
- if the answer of the specified operation is incompatible with this oneprotected void updateFrom(JoinQueryOperation operation)
JoinQueryOperation
.operation
- the source operation from which to get the updatepublic void endOperation(ErrorCode errValue) throws java.lang.IllegalArgumentException
AbstractOperation
endOperation
in class AbstractOperation
errValue
- the error code to setjava.lang.IllegalArgumentException
- if the specified error value is null or ErrorCode.NOT_SET
public void clearSurplusData()
clearSurplusData
in interface Clearable
clearSurplusData
in class AbstractOperation
protected boolean dataEqualsImpl(QueryOperation obj)
dataEqualsImpl
in class QueryOperation<RankedJoinObject>
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<RankedJoinObject>