net.obsearch.index.aesa.impl
Class AesaFloat<O extends OBFloat>

java.lang.Object
  extended by net.obsearch.index.aesa.AbstractAESA<O>
      extended by net.obsearch.index.aesa.impl.AesaFloat<O>
All Implemented Interfaces:
Index<O>, IndexFloat<O>

public class AesaFloat<O extends OBFloat>
extends AbstractAESA<O>
implements IndexFloat<O>


Nested Class Summary
protected  class AesaFloat.Computation
           
 
Field Summary
protected static Logger logger
           
 
Fields inherited from class net.obsearch.index.aesa.AbstractAESA
objects, stats
 
Fields inherited from interface net.obsearch.Index
ID_SIZE
 
Constructor Summary
AesaFloat(Class<O> type, int expectedSize)
           
 
Method Summary
 void close()
          Closes the database.
 String debug(O object)
          Routine that helps to debug objects.
 OperationStatus delete(O object)
          Deletes the given object from the database.
 OperationStatus exists(O object)
          Returns true if the given object exists in the database.
 float[] fullMatchLite(O query, boolean filterSame)
          This method returns a list of all the distances of the query against the DB.
 long getBox(O object)
          Returns the box where the given object is stored.
 O getObject(long i)
          This method returns the object with internal id "i".
 Statistics getStats()
           
 void init(OBStoreFactory fact)
          This method *must* be called after de-serializing the database object and after instantiating the index.
 OperationStatus insert(O object, long id)
          Inserts the given object into the index.
 OperationStatus insertBulk(O object)
          Inserts the given object into the index.
 OperationStatus insertBulk(O object, long id)
          Inserts the given object into the index.
 boolean isFrozen()
          Returns true if the index is frozen.
 void prepare()
          compute all the distances
 void searchOB(OBQueryFloat<O> query)
           
 void searchOB(O object, float r, Filter<O> filter, OBPriorityQueueFloat<O> result)
          Searches the Index and returns OBResult (ID, OB and distance) elements that are closer to "object".
 void searchOB(O object, float r, OBPriorityQueueFloat<O> result)
          Searches the Index and returns OBResult (ID, OB and distance) elements that are closer to "object".
 void setPreFreezeCheck(boolean preFreezeCheck)
          If the index should check for existent objects before freeze.
 long totalBoxes()
          Returns the total number of boxes this index can hold.
 
Methods inherited from class net.obsearch.index.aesa.AbstractAESA
databaseSize, freeze, get, getStatistics, getType, insert, loadObject, resetStats, size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.obsearch.Index
databaseSize, freeze, getType, insert, loadObject, resetStats
 

Field Detail

logger

protected static Logger logger
Constructor Detail

AesaFloat

public AesaFloat(Class<O> type,
                 int expectedSize)
Method Detail

prepare

public void prepare()
             throws OBException
Description copied from class: AbstractAESA
compute all the distances

Specified by:
prepare in class AbstractAESA<O extends OBFloat>
Throws:
OBException

fullMatchLite

public float[] fullMatchLite(O query,
                             boolean filterSame)
                      throws OBException,
                             IllegalAccessException,
                             InstantiationException
This method returns a list of all the distances of the query against the DB. This helps to calculate EP values in a cheaper way. results that are equal to the original object are added as Float.MAX_VALUE

Specified by:
fullMatchLite in interface IndexFloat<O extends OBFloat>
Parameters:
query -
filterSame - if True we do not return objects o such that query.equals(o)
Returns:
Throws:
OBException
InstantiationException
IllegalAccessException

searchOB

public void searchOB(OBQueryFloat<O> query)
              throws OBException,
                     InstantiationException,
                     IllegalAccessException
Throws:
OBException
InstantiationException
IllegalAccessException

searchOB

public void searchOB(O object,
                     float r,
                     OBPriorityQueueFloat<O> result)
              throws NotFrozenException,
                     InstantiationException,
                     IllegalIdException,
                     IllegalAccessException,
                     OutOfRangeException,
                     OBException
Description copied from interface: IndexFloat
Searches the Index and returns OBResult (ID, OB and distance) elements that are closer to "object". The closest element is at the beginning of the list and the farthest elements is at the end of the list. You can control the size of the resulting set when you create the object "result". This becomes the k parameter of the search.

Specified by:
searchOB in interface IndexFloat<O extends OBFloat>
Parameters:
object - The object that has to be searched
r - The range to be used
result - A priority queue that will hold the result
Throws:
NotFrozenException - if the index has not been frozen.
InstantiationException - If there is a problem when instantiating objects O
IllegalIdException - This exception is left as a Debug flag. If you receive this exception please report the problem to: http://code.google.com/p/obsearch/issues/list
IllegalAccessException - If there is a problem when instantiating objects O
OutOfRangeException - If the distance of any object to any other object exceeds the range defined by the user.
OBException - User generated exception

searchOB

public void searchOB(O object,
                     float r,
                     Filter<O> filter,
                     OBPriorityQueueFloat<O> result)
              throws NotFrozenException,
                     InstantiationException,
                     IllegalIdException,
                     IllegalAccessException,
                     OutOfRangeException,
                     OBException
Description copied from interface: IndexFloat
Searches the Index and returns OBResult (ID, OB and distance) elements that are closer to "object". The closest element is at the beginning of the list and the farthest elements is at the end of the list. You can control the size of the resulting set when you create the object "result". This becomes the k parameter of the search. The parameter "filter" is used to remove unwanted objects from the result (a select where clause). Users are responsible to implement at least one filter that can be used with their O.

Specified by:
searchOB in interface IndexFloat<O extends OBFloat>
Parameters:
object - The object that has to be searched
r - The range to be used
result - A priority queue that will hold the result
Throws:
NotFrozenException - if the index has not been frozen.
InstantiationException - If there is a problem when instantiating objects O
IllegalIdException - This exception is left as a Debug flag. If you receive this exception please report the problem to: http://code.google.com/p/obsearch/issues/list
IllegalAccessException - If there is a problem when instantiating objects O
OutOfRangeException - If the distance of any object to any other object exceeds the range defined by the user.
OBException - User generated exception

close

public void close()
           throws OBException
Description copied from interface: Index
Closes the database.

Specified by:
close in interface Index<O extends OBFloat>
Throws:
OBStorageException - If something goes wrong with the DB.
OBException

debug

public String debug(O object)
             throws OBException,
                    InstantiationException,
                    IllegalAccessException
Description copied from interface: Index
Routine that helps to debug objects. Returns some human-readable information regarding the given object. This method is optional.

Specified by:
debug in interface Index<O extends OBFloat>
Throws:
OBException
InstantiationException
IllegalAccessException

delete

public OperationStatus delete(O object)
                       throws OBStorageException,
                              OBException,
                              IllegalAccessException,
                              InstantiationException,
                              NotFrozenException
Description copied from interface: Index
Deletes the given object from the database.

Specified by:
delete in interface Index<O extends OBFloat>
Parameters:
object - The object to be deleted
Returns:
Status.OK and the deleted object's id if the object was found and successfully deleted. Status.NOT_EXISTS if the object is not in the database.
Throws:
OBStorageException - If something goes wrong with the DB
NotFrozenException - if the index has not been frozen.
OBException - User generated exception
IllegalAccessException - If there is a problem when instantiating objects O
InstantiationException - If there is a problem when instantiating objects O

exists

public OperationStatus exists(O object)
                       throws OBStorageException,
                              OBException,
                              IllegalAccessException,
                              InstantiationException
Description copied from interface: Index
Returns true if the given object exists in the database. This method was created for OBSearch internal use. If you are relying on this method a lot, isn't it better to use a hash table or a B-tree instead of OBSearch? O.equals(...) is used to calculate the equality of two objects.

Specified by:
exists in interface Index<O extends OBFloat>
Parameters:
object - The object that will be searched.
Returns:
Status.EXISTS and the object's id if the object exists in the database, otherwise Status.NOT_EXISTS is returned.
Throws:
OBStorageException - If something goes wrong with the DB
OBException - User generated exception
IllegalAccessException - If there is a problem when instantiating objects O
InstantiationException - If there is a problem when instantiating objects O

getBox

public long getBox(O object)
            throws OBException
Description copied from interface: Index
Returns the box where the given object is stored. This is an optional operation, not all indexes need to support this.

Specified by:
getBox in interface Index<O extends OBFloat>
Parameters:
object - The object to be analyzed
Returns:
The box that corresponds to object
Throws:
OBException - User generated exception

getObject

public O getObject(long i)
                            throws IllegalIdException,
                                   IllegalAccessException,
                                   InstantiationException,
                                   OBException
Description copied from interface: Index
This method returns the object with internal id "i". Mainly used for internal validation purposes, users should not have to use this method directly

Specified by:
getObject in interface Index<O extends OBFloat>
Parameters:
i - The id to be retrieved
Returns:
The object associated to the given id. if the index has not been frozen. was deleted successfully
Throws:
IllegalAccessException - If there is a problem when instantiating objects O
InstantiationException - If there is a problem when instantiating objects O
OBStorageException - If something goes wrong with the DB
OBException - User generated exception
IllegalIdException

getStats

public Statistics getStats()
                    throws OBStorageException
Specified by:
getStats in interface Index<O extends OBFloat>
Returns:
A human-readable list of stats relevant for this index.
Throws:
OBStorageException

init

public void init(OBStoreFactory fact)
          throws OBStorageException,
                 NotFrozenException,
                 IllegalAccessException,
                 InstantiationException,
                 OBException,
                 IOException
Description copied from interface: Index
This method *must* be called after de-serializing the database object and after instantiating the index. This method is called by the #org.obsearch.ambient.Ambient, users do not need to worry about this method.

Specified by:
init in interface Index<O extends OBFloat>
Parameters:
fact - The storage factory that will be used to store the data.
Throws:
OBStorageException - If something goes wrong with the DB
NotFrozenException - if the index has not been frozen.
IllegalAccessException - If there is a problem when instantiating objects O
InstantiationException - If there is a problem when instantiating objects O
OBException - User generated exception
IOException - if the index serialization process fails

insert

public OperationStatus insert(O object,
                              long id)
                       throws OBStorageException,
                              OBException,
                              IllegalAccessException,
                              InstantiationException
Description copied from interface: Index
Inserts the given object into the index.

Specified by:
insert in interface Index<O extends OBFloat>
Parameters:
object - The object to be added.
id - The id that will be used for the object.
Returns:
If Status.OK or Status.EXISTS then the result will hold the id of the inserted object and the operation is successful. Otherwise an exception will be thrown.
Throws:
OBStorageException - If something goes wrong with the DB
OBException - User generated exception
IllegalAccessException - If there is a problem when instantiating objects O
InstantiationException - If there is a problem when instantiating objects O

insertBulk

public OperationStatus insertBulk(O object)
                           throws OBStorageException,
                                  OBException,
                                  IllegalAccessException,
                                  InstantiationException
Description copied from interface: Index
Inserts the given object into the index. It does not check if the object to be inserted exists in the database.

Specified by:
insertBulk in interface Index<O extends OBFloat>
Parameters:
object - The object to be added.
Returns:
Status.OK
Throws:
OBStorageException - If something goes wrong with the DB
OBException - User generated exception
IllegalAccessException - If there is a problem when instantiating objects O
InstantiationException - If there is a problem when instantiating objects O

insertBulk

public OperationStatus insertBulk(O object,
                                  long id)
                           throws OBStorageException,
                                  OBException,
                                  IllegalAccessException,
                                  InstantiationException
Description copied from interface: Index
Inserts the given object into the index. It does not check if the object to be inserted exists in the database.

Specified by:
insertBulk in interface Index<O extends OBFloat>
Parameters:
object - The object to be added.
id - The id that will be used for the object.
Returns:
Status.OK
Throws:
OBStorageException - If something goes wrong with the DB
OBException - User generated exception
IllegalAccessException - If there is a problem when instantiating objects O
InstantiationException - If there is a problem when instantiating objects O

isFrozen

public boolean isFrozen()
Description copied from interface: Index
Returns true if the index is frozen.

Specified by:
isFrozen in interface Index<O extends OBFloat>
Returns:
true if the index is frozen, false otherwise

setPreFreezeCheck

public void setPreFreezeCheck(boolean preFreezeCheck)
Description copied from interface: Index
If the index should check for existent objects before freeze.

Specified by:
setPreFreezeCheck in interface Index<O extends OBFloat>
Parameters:
preFreezeCheck - Set the flag.

totalBoxes

public long totalBoxes()
Description copied from interface: Index
Returns the total number of boxes this index can hold. This is an optional operation, not all indexes need to support this.

Specified by:
totalBoxes in interface Index<O extends OBFloat>
Returns:
The total number of boxes the index can eventually support.


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