net.obsearch.query
Class OBQueryShort<O extends OBShort>

java.lang.Object
  extended by net.obsearch.query.AbstractOBQuery<O>
      extended by net.obsearch.query.OBQueryShort<O>

public final class OBQueryShort<O extends OBShort>
extends net.obsearch.query.AbstractOBQuery<O>

Object used to store a query request.

Since:
0.7
Author:
Arnoldo Jose Muller Molina

Field Summary
protected  short[] max
          Maximum part of the rectangle of the query.
protected  short[] min
          Minimum part of the rectangle of the query.
protected  OBPriorityQueueShort<O> result
          Holds the results for the query.
protected  short[] smap
          SMAPed vector
 
Constructor Summary
OBQueryShort()
          Constructor.
OBQueryShort(O object, OBPriorityQueueShort<O> result)
           
OBQueryShort(O object, short range, OBPriorityQueueShort<O> result)
          Creates a new OBQueryShort object.
OBQueryShort(O object, short range, OBPriorityQueueShort<O> result, short[] smap)
          Creates a new OBQueryShort object.
 
Method Summary
 boolean add(long id, O object)
           
 boolean add(long id, O obj, short d)
          Add the given object, object id and distance of type float to the queue.
 double approx(short[] dbin)
          Calculate the 1 + E or (c for Adonis et al) for approx.
 boolean collides(short[][] rectangle)
          Returns true if the given rectangle collides with this query.
 double compound(short[] dbin)
          Calculates ep without multiplying by 1/k and
 double ep(List<net.obsearch.AbstractOBResult<O>> dbin)
           
 double ep(short[] dbin)
          Calculate the EP value for a sorted list of distances.
 short getDistance()
           
 short[] getHigh()
          Return low of the query rectangle.
 short[] getLow()
          Return low of the query rectangle.
 O getObject()
           
 OBPriorityQueueShort<O> getResult()
           
 List<net.obsearch.AbstractOBResult<O>> getSortedElements()
           
 boolean isCandidate(short smapDistance)
          Returns true if we should calculate the real distance.
 boolean isFull()
           
 short peek()
          peek to the largest value if the queue is full.
 double precision(short[] dbin)
          Calculates the precision
 double rde(short[] dbin)
           
 double recall(List<net.obsearch.AbstractOBResult<O>> perfectQuery)
           
 void setResult(OBPriorityQueueShort<O> result)
          Set the results of the matching to a new object.
 double tDR(short[] dbin)
          Total distance ratio
 boolean updatedRange(short originalRange)
          Returns true if the originalRange has been modified.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

result

protected OBPriorityQueueShort<O extends OBShort> result
Holds the results for the query.


min

protected short[] min
Minimum part of the rectangle of the query.


max

protected short[] max
Maximum part of the rectangle of the query.


smap

protected short[] smap
SMAPed vector

Constructor Detail

OBQueryShort

public OBQueryShort()
Constructor.


OBQueryShort

public OBQueryShort(O object,
                    short range,
                    OBPriorityQueueShort<O> result)
Creates a new OBQueryShort object.

Parameters:
object - The object that will be matched.
range - The range to be used for the match.
result - The priority queue were the results will be stored.

OBQueryShort

public OBQueryShort(O object,
                    OBPriorityQueueShort<O> result)

OBQueryShort

public OBQueryShort(O object,
                    short range,
                    OBPriorityQueueShort<O> result,
                    short[] smap)
Creates a new OBQueryShort object.

Parameters:
object - The object that will be matched.
range - The range to be used for the match.
result - The priority queue were the results will be stored.
smap - SMAP vector representation of the given object.
Method Detail

getObject

public O getObject()

collides

public boolean collides(short[][] rectangle)
Returns true if the given rectangle collides with this query.

Parameters:
rectangle - The rectangle to search.

getLow

public short[] getLow()
Return low of the query rectangle.


getHigh

public short[] getHigh()
Return low of the query rectangle.


getResult

public OBPriorityQueueShort<O> getResult()
Returns:
The current results of the matching.

setResult

public void setResult(OBPriorityQueueShort<O> result)
Set the results of the matching to a new object.

Parameters:
result - The new result.

isCandidate

public boolean isCandidate(short smapDistance)
Returns true if we should calculate the real distance.

Parameters:
smapDistance - The lower-resolution distance calculated with SMAP.

add

public boolean add(long id,
                   O object)
            throws InstantiationException,
                   IllegalAccessException,
                   net.obsearch.exception.OBException
Specified by:
add in class net.obsearch.query.AbstractOBQuery<O extends OBShort>
Throws:
InstantiationException
IllegalAccessException
net.obsearch.exception.OBException

getDistance

public short getDistance()

getSortedElements

public List<net.obsearch.AbstractOBResult<O>> getSortedElements()
Specified by:
getSortedElements in class net.obsearch.query.AbstractOBQuery<O extends OBShort>

add

public boolean add(long id,
                   O obj,
                   short d)
            throws InstantiationException,
                   IllegalAccessException
Add the given object, object id and distance of type float to the queue. Updates the range of the query as needed if the range shrinks after this insertion.

Parameters:
id - The id of the object to be used
obj - The object to be added
d - The distance to be added
Throws:
IllegalAccessException - If there is a problem when instantiating objects O
InstantiationException - If there is a problem when instantiating objects O

updatedRange

public boolean updatedRange(short originalRange)
Returns true if the originalRange has been modified.

Returns:
true If the current range (getDistance()) is different than originalRange.

isFull

public boolean isFull()
Specified by:
isFull in class net.obsearch.query.AbstractOBQuery<O extends OBShort>
Returns:
true if the underlying priority queue's size is equal to k

recall

public double recall(List<net.obsearch.AbstractOBResult<O>> perfectQuery)
Specified by:
recall in class net.obsearch.query.AbstractOBQuery<O extends OBShort>

ep

public double ep(List<net.obsearch.AbstractOBResult<O>> dbin)
Specified by:
ep in class net.obsearch.query.AbstractOBQuery<O extends OBShort>

ep

public double ep(short[] dbin)
Calculate the EP value for a sorted list of distances.


approx

public double approx(short[] dbin)
              throws net.obsearch.exception.OBException
Calculate the 1 + E or (c for Adonis et al) for approx. nearest neighbor This is the approximation and "real" is the real result.

Parameters:
q -
Returns:
Throws:
RAException
net.obsearch.exception.OBException

compound

public double compound(short[] dbin)
Calculates ep without multiplying by 1/k and


rde

public double rde(short[] dbin)

tDR

public double tDR(short[] dbin)
Total distance ratio


precision

public double precision(short[] dbin)
Calculates the precision


peek

public short peek()
           throws net.obsearch.exception.OBException
peek to the largest value if the queue is full.

Throws:
net.obsearch.exception.OBException


Copyright © 2007-2011 Arnoldo Jose Muller Molina. All Rights Reserved.