net.obsearch.query
Class OBQueryByte<O extends OBByte>

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

public final class OBQueryByte<O extends OBByte>
extends AbstractOBQuery<O>

Object used to store a query request.

Since:
0.7
Author:
Arnoldo Jose Muller Molina

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


min

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


max

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


smap

protected byte[] smap
SMAPed vector

Constructor Detail

OBQueryByte

public OBQueryByte()
Constructor.


OBQueryByte

public OBQueryByte(O object,
                   byte range,
                   OBPriorityQueueByte<O> result)
Creates a new OBQueryByte 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.

OBQueryByte

public OBQueryByte(O object,
                   OBPriorityQueueByte<O> result)

OBQueryByte

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

Parameters:
rectangle - The rectangle to search.

getLow

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


getHigh

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


getResult

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

setResult

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

Parameters:
result - The new result.

isCandidate

public boolean isCandidate(byte 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,
                   OBException
Description copied from class: AbstractOBQuery
Adds an object into the queue. The underlying classes calculate the distance of the object and the query.

Specified by:
add in class AbstractOBQuery<O extends OBByte>
Parameters:
id - id number of the object to add.
object - object added.
Returns:
true if the range has changed after the add.
Throws:
InstantiationException
IllegalAccessException
OBException

getDistance

public byte getDistance()

getSortedElements

public List<AbstractOBResult<O>> getSortedElements()
Specified by:
getSortedElements in class AbstractOBQuery<O extends OBByte>
Returns:
a list of objects ordered from smallest distance to largest distance

add

public boolean add(long id,
                   O obj,
                   byte 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(byte 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 AbstractOBQuery<O extends OBByte>
Returns:
true if the underlying priority queue's size is equal to k

recall

public double recall(List<AbstractOBResult<O>> perfectQuery)
Description copied from class: AbstractOBQuery
calculates the recall value of this query against the "DB" (all the objects of the DB sorted by distance to this query).

Specified by:
recall in class AbstractOBQuery<O extends OBByte>
Parameters:
perfectQuery - all the objects of the DB sorted by distance to this query
Returns:
ep value

ep

public double ep(List<AbstractOBResult<O>> dbin)
Description copied from class: AbstractOBQuery
calculates the ep value of this query against the "DB" (all the objects of the DB sorted by distance to this query).

Specified by:
ep in class AbstractOBQuery<O extends OBByte>
Parameters:
dbin - all the objects of the DB sorted by distance to this query
Returns:
ep value

ep

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


approx

public double approx(byte[] dbin)
              throws 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
OBException

compound

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


rde

public double rde(byte[] dbin)

tDR

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


precision

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


peek

public byte peek()
          throws OBException
peek to the largest value if the queue is full.

Throws:
OBException


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