net.obsearch.pivots
Class AbstractIncrementalPivotSelector<O extends OB>

java.lang.Object
  extended by net.obsearch.pivots.AbstractIncrementalPivotSelector<O>
Direct Known Subclasses:
AbstractIncrementalBustosNavarroChavez, AbstractIncrementalPerm, AbstractIncrementalRF02, AbstractIncrementalRF03, AbstractIncrementalRF04, AbstractMySSS, IncrementalDummyPivotSelector, IncrementalKMeansPPPivotSelectorByte, IncrementalKMeansPPPivotSelectorDouble, IncrementalKMeansPPPivotSelectorFloat, IncrementalKMeansPPPivotSelectorInt, IncrementalKMeansPPPivotSelectorLong, IncrementalKMeansPPPivotSelectorShort, RandomPivotSelector

public abstract class AbstractIncrementalPivotSelector<O extends OB>
extends Object

AbstractIncrementalPivotSelector holds common functionality to all the incremental pivot selectors.

Author:
Arnoldo Jose Muller Molina

Field Summary
protected  Pivotable<O> pivotable
          Pivotable objects determine if a given object is suitable.
protected  Random r
           
 
Constructor Summary
protected AbstractIncrementalPivotSelector()
           
protected AbstractIncrementalPivotSelector(Pivotable<O> pivotable)
           
 
Method Summary
 void enableAcceptRepeated()
           
 PivotResult generatePivots(int pivotsCount, Index<O> index)
           
abstract  PivotResult generatePivots(int pivotCount, cern.colt.list.LongArrayList elements, Index<O> index)
           
protected  O getObject(long i, cern.colt.list.LongArrayList elements, Index<O> index)
          Returns the given object.
protected  long mapId(long i, cern.colt.list.LongArrayList elements)
           
protected  int max(cern.colt.list.LongArrayList source, Index<O> index)
          Returns the max # of elements.
protected  long[] select(int k, Random r, cern.colt.list.LongArrayList source, Index<O> index, cern.colt.list.LongArrayList excludes)
          Selects k random elements from the given source.
protected  O[] selectO(int k, Random r, cern.colt.list.LongArrayList source, Index<O> index, cern.colt.list.LongArrayList excludes)
           
protected  long[] selectUnique(int k, Random r, cern.colt.list.LongArrayList source, Index<O> index, cern.colt.list.LongArrayList excludes)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

r

protected Random r

pivotable

protected Pivotable<O extends OB> pivotable
Pivotable objects determine if a given object is suitable. For example, in the case of trees, very big trees will become a burden and we should avoid using them as pivots.

Constructor Detail

AbstractIncrementalPivotSelector

protected AbstractIncrementalPivotSelector(Pivotable<O> pivotable)

AbstractIncrementalPivotSelector

protected AbstractIncrementalPivotSelector()
Method Detail

getObject

protected final O getObject(long i,
                            cern.colt.list.LongArrayList elements,
                            Index<O> index)
                                throws IllegalAccessException,
                                       InstantiationException,
                                       IllegalIdException,
                                       OBException
Returns the given object. If elements != null, then the returned item id is elements[i].

Parameters:
i - The id in the database or in elements of the object that will be accessed.
elements - Elements that will be searched.
Returns:
O object of the corresponding id.
Throws:
IllegalAccessException
InstantiationException
com.sleepycat.je.DatabaseException
IllegalIdException
OBException

mapId

protected long mapId(long i,
                     cern.colt.list.LongArrayList elements)

enableAcceptRepeated

public void enableAcceptRepeated()

generatePivots

public PivotResult generatePivots(int pivotsCount,
                                  Index<O> index)
                           throws OBException,
                                  IllegalAccessException,
                                  InstantiationException,
                                  OBStorageException,
                                  PivotsUnavailableException
Throws:
OBException
IllegalAccessException
InstantiationException
OBStorageException
PivotsUnavailableException

generatePivots

public abstract PivotResult generatePivots(int pivotCount,
                                           cern.colt.list.LongArrayList elements,
                                           Index<O> index)
                                    throws OBException,
                                           IllegalAccessException,
                                           InstantiationException,
                                           OBStorageException,
                                           PivotsUnavailableException
Throws:
OBException
IllegalAccessException
InstantiationException
OBStorageException
PivotsUnavailableException

max

protected int max(cern.colt.list.LongArrayList source,
                  Index<O> index)
           throws OBStorageException
Returns the max # of elements. if source != null then source.size() otherwise index.databaseSize();

Parameters:
source - The source of data (can be null)
index - The underlying index.
Returns:
The max # of elements of source if source != null or of index if source == null.
Throws:
OBStorageException

select

protected long[] select(int k,
                        Random r,
                        cern.colt.list.LongArrayList source,
                        Index<O> index,
                        cern.colt.list.LongArrayList excludes)
                 throws OBStorageException,
                        IllegalIdException,
                        OBException,
                        IllegalAccessException,
                        InstantiationException
Selects k random elements from the given source.

Parameters:
k - number of elements to select
r - Random object used to randomly select objects.
source - The source of item ids.
index - underlying index.
will - not add pivots included in excludes.
Returns:
The ids of selected objects.
Throws:
InstantiationException
IllegalAccessException
OBException
IllegalIdException
OBStorageException

selectUnique

protected long[] selectUnique(int k,
                              Random r,
                              cern.colt.list.LongArrayList source,
                              Index<O> index,
                              cern.colt.list.LongArrayList excludes)
                       throws OBStorageException,
                              IllegalIdException,
                              OBException,
                              IllegalAccessException,
                              InstantiationException
Throws:
OBStorageException
IllegalIdException
OBException
IllegalAccessException
InstantiationException

selectO

protected O[] selectO(int k,
                      Random r,
                      cern.colt.list.LongArrayList source,
                      Index<O> index,
                      cern.colt.list.LongArrayList excludes)
                          throws IllegalIdException,
                                 IllegalAccessException,
                                 InstantiationException,
                                 OBException
Throws:
IllegalIdException
IllegalAccessException
InstantiationException
OBException


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