net.obsearch.index.pivot
Class AbstractPivotOBIndex<O extends OB>

java.lang.Object
  extended by net.obsearch.index.AbstractOBIndex<O>
      extended by net.obsearch.index.pivot.AbstractPivotOBIndex<O>
All Implemented Interfaces:
Index<O>
Direct Known Subclasses:
AbstractBucketIndex

public abstract class AbstractPivotOBIndex<O extends OB>
extends AbstractOBIndex<O>

AbstractPivotOBIndex defines abstract functionality for an index that uses n pivots to partition the data into more tractable subsets. To create a new index, do the following: 1) Implement objectToProjectionBytes(O object) (smap an object and codify it) 2) Implement deleteAux 3) Implement insertAux 4) Implement searchOB. That's all!

Author:
Arnoldo Jose Muller Molina

Field Summary
protected  int intrinsicDimensionalityPairs
          Use the following amount of pairs when the intrinsic dimensionality is calculated.
protected  O[] pivots
          The pivots for this Tree.
protected  IncrementalPivotSelector<O> pivotSelector
          The pivot selector used by the index.
 
Fields inherited from class net.obsearch.index.AbstractOBIndex
A, fact, isFrozen, stats, type
 
Fields inherited from interface net.obsearch.Index
ID_SIZE
 
Constructor Summary
protected AbstractPivotOBIndex()
           
protected AbstractPivotOBIndex(Class<O> type, IncrementalPivotSelector<O> pivotSelector, int pivotCount)
          Creates an index that uses pivots as its major data partitioning strategy.
 
Method Summary
protected  double calculateIntrinsicDimensionality()
          Calculates the intrinsic dimensionality of the inserted dataset.
protected  void createPivotsArray(int size)
          Creates an array with the pivots.
 void freeze()
          Freezes the index.
protected  O[] getObjects(long[] ids)
          Stores the given pivots in a local array.
 int getPivotCount()
           
 void init(OBStoreFactory fact)
          Initialize the index.
protected  PivotResult selectPivots(int pivotCount, IncrementalPivotSelector<O> pivotSelector)
          Override this method if selection must be changed
 
Methods inherited from class net.obsearch.index.AbstractOBIndex
assertFrozen, bytesToObject, bytesToObject, clearACache, close, databaseSize, debug, delete, deleteAux, distance, emptyPivotsArray, findAux, getBox, getObject, getStats, getType, initCache, initStorageDevices, insert, insert, insertAux, insertAuxBulk, insertBulk, insertBulk, intrinsicDimensionality, isFrozen, isPreFreeze, isPreFreezeCheck, loadObject, loadPivots, objectToByteBuffer, objectToBytes, resetStats, serializePivots, setFixedRecord, setFixedRecord, setIdAutoGeneration, setPreFreeze, setPreFreezeCheck, totalBoxes
 
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
exists
 

Field Detail

pivotSelector

protected IncrementalPivotSelector<O extends OB> pivotSelector
The pivot selector used by the index.


pivots

protected O extends OB[] pivots
The pivots for this Tree. When we instantiate or de-serialize this object we load them from #pivotsBytes.


intrinsicDimensionalityPairs

protected int intrinsicDimensionalityPairs
Use the following amount of pairs when the intrinsic dimensionality is calculated.

Constructor Detail

AbstractPivotOBIndex

protected AbstractPivotOBIndex(Class<O> type,
                               IncrementalPivotSelector<O> pivotSelector,
                               int pivotCount)
                        throws OBStorageException,
                               OBException
Creates an index that uses pivots as its major data partitioning strategy.

Parameters:
type - The type of object that will be stored.
pivotSelector - The pivot selection strategy to be employed.
pivotCount - The number of pivots that will be selected.
Throws:
OBStorageException
OBException

AbstractPivotOBIndex

protected AbstractPivotOBIndex()
Method Detail

freeze

public void freeze()
            throws AlreadyFrozenException,
                   IllegalIdException,
                   IllegalAccessException,
                   InstantiationException,
                   OBStorageException,
                   OutOfRangeException,
                   OBException,
                   PivotsUnavailableException,
                   IOException
Description copied from interface: Index
Freezes the index. From this point data can be inserted, searched and deleted. The index might deteriorate at some point so every once in a while it is a good idea to rebuild the index. A PivotSelector must be executed before calling this method.

Specified by:
freeze in interface Index<O extends OB>
Overrides:
freeze in class AbstractOBIndex<O extends OB>
Throws:
AlreadyFrozenException - If the index was already frozen and the user attempted to freeze it again
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
InstantiationException - If there is a problem when instantiating objects O
OBStorageException - If something goes wrong with the DB
OutOfRangeException - If the distance of any object to any other object exceeds the range defined by the user.
OBException - User generated exception
PivotsUnavailableException
IOException - if the index serialization process fails
See Also:
Index.freeze()

calculateIntrinsicDimensionality

protected double calculateIntrinsicDimensionality()
                                           throws IllegalIdException,
                                                  IllegalAccessException,
                                                  InstantiationException,
                                                  OBException
Calculates the intrinsic dimensionality of the inserted dataset.

Returns:
Throws:
IllegalIdException
IllegalAccessException
InstantiationException
OBException

selectPivots

protected PivotResult selectPivots(int pivotCount,
                                   IncrementalPivotSelector<O> pivotSelector)
                            throws AlreadyFrozenException,
                                   IllegalIdException,
                                   IllegalAccessException,
                                   InstantiationException,
                                   OBStorageException,
                                   OutOfRangeException,
                                   OBException,
                                   IOException
Override this method if selection must be changed

Throws:
IOException
AlreadyFrozenException
IllegalIdException
IllegalAccessException
InstantiationException
OBStorageException
OutOfRangeException
OBException

getObjects

protected O[] getObjects(long[] ids)
                             throws IllegalIdException,
                                    IllegalAccessException,
                                    InstantiationException,
                                    OBException
Stores the given pivots in a local array. Takes the pivots from the database using the given ids.

Parameters:
ids - Ids of the pivots that will be stored.
Throws:
IllegalIdException - If the pivot selector generates invalid ids
com.sleepycat.je.DatabaseException - 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

createPivotsArray

protected void createPivotsArray(int size)
Creates an array with the pivots. It has to be created like this because we are using generics. Subclasses must override this if different sets of pivots are to be used. We can override this later to have a multiple set of pivots for indexes like D...


getPivotCount

public int getPivotCount()
Returns:
The number of pivots used in this index.

init

public void init(OBStoreFactory fact)
          throws OBStorageException,
                 OBException,
                 NotFrozenException,
                 IllegalAccessException,
                 InstantiationException,
                 OBException
Description copied from class: AbstractOBIndex
Initialize the index.

Specified by:
init in interface Index<O extends OB>
Overrides:
init in class AbstractOBIndex<O extends OB>
Parameters:
fact - The storage factory that will be used to store the data.
Throws:
OBStorageException - If something goes wrong with the DB
OBException - User generated exception
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


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