net.obsearch.query
Class OBQueryInt<O extends OBInt>

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

public final class OBQueryInt<O extends OBInt>
extends net.obsearch.query.AbstractOBQuery<O>

Object used to store a query request.

Since:
0.7
Author:
Arnoldo Jose Muller Molina

Field Summary
protected  int[] max
          Maximum part of the rectangle of the query.
protected  int[] min
          Minimum part of the rectangle of the query.
protected  OBPriorityQueueInt<O> result
          Holds the results for the query.
protected  int[] smap
          SMAPed vector
 
Constructor Summary
OBQueryInt()
          Constructor.
OBQueryInt(O object, int range, OBPriorityQueueInt<O> result)
          Creates a new OBQueryInt object.
OBQueryInt(O object, int range, OBPriorityQueueInt<O> result, int[] smap)
          Creates a new OBQueryInt object.
OBQueryInt(O object, OBPriorityQueueInt<O> result)
           
 
Method Summary
 boolean add(long id, O object)
           
 boolean add(long id, O obj, int d)
          Add the given object, object id and distance of type float to the queue.
 double approx(int[] dbin)
          Calculate the 1 + E or (c for Adonis et al) for approx.
 boolean collides(int[][] rectangle)
          Returns true if the given rectangle collides with this query.
 double compound(int[] dbin)
          Calculates ep without multiplying by 1/k and
 double ep(int[] dbin)
          Calculate the EP value for a sorted list of distances.
 double ep(List<net.obsearch.AbstractOBResult<O>> dbin)
           
 int getDistance()
           
 int[] getHigh()
          Return low of the query rectangle.
 int[] getLow()
          Return low of the query rectangle.
 O getObject()
           
 OBPriorityQueueInt<O> getResult()
           
 List<net.obsearch.AbstractOBResult<O>> getSortedElements()
           
 boolean isCandidate(int smapDistance)
          Returns true if we should calculate the real distance.
 boolean isFull()
           
 int peek()
          peek to the largest value if the queue is full.
 double precision(int[] dbin)
          Calculates the precision
 double rde(int[] dbin)
           
 double recall(List<net.obsearch.AbstractOBResult<O>> perfectQuery)
           
 void setResult(OBPriorityQueueInt<O> result)
          Set the results of the matching to a new object.
 double tDR(int[] dbin)
          Total distance ratio
 boolean updatedRange(int 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 OBPriorityQueueInt<O extends OBInt> result
Holds the results for the query.


min

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


max

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


smap

protected int[] smap
SMAPed vector

Constructor Detail

OBQueryInt

public OBQueryInt()
Constructor.


OBQueryInt

public OBQueryInt(O object,
                  int range,
                  OBPriorityQueueInt<O> result)
Creates a new OBQueryInt 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.

OBQueryInt

public OBQueryInt(O object,
                  OBPriorityQueueInt<O> result)

OBQueryInt

public OBQueryInt(O object,
                  int range,
                  OBPriorityQueueInt<O> result,
                  int[] smap)
Creates a new OBQueryInt 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(int[][] rectangle)
Returns true if the given rectangle collides with this query.

Parameters:
rectangle - The rectangle to search.

getLow

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


getHigh

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


getResult

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

setResult

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

Parameters:
result - The new result.

isCandidate

public boolean isCandidate(int 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 OBInt>
Throws:
InstantiationException
IllegalAccessException
net.obsearch.exception.OBException

getDistance

public int getDistance()

getSortedElements

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

add

public boolean add(long id,
                   O obj,
                   int 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(int 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 OBInt>
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 OBInt>

ep

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

ep

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


approx

public double approx(int[] 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(int[] dbin)
Calculates ep without multiplying by 1/k and


rde

public double rde(int[] dbin)

tDR

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


precision

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


peek

public int 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.