org.axiondb.engine.indexes
Class BaseArrayIndex

java.lang.Object
  extended byorg.axiondb.event.BaseTableModificationListener
      extended byorg.axiondb.engine.indexes.BaseIndex
          extended byorg.axiondb.engine.indexes.BaseArrayIndex
All Implemented Interfaces:
Index, TableModificationListener
Direct Known Subclasses:
IntArrayIndex, ObjectArrayIndex

public abstract class BaseArrayIndex
extends BaseIndex
implements Index

Abstract base implemenation for indicesthat maintain an in-memory, sorted array of key values (and their associated row identifiers). This type of index is fast to read, relatively slow to write and somewhat memory expensive when very large.

Version:
$Revision: 1.5 $ $Date: 2004/09/09 23:47:46 $

Field Summary
 
Fields inherited from interface org.axiondb.Index
ARRAY, BTREE, DEFAULT
 
Constructor Summary
BaseArrayIndex(String name, Column column, boolean unique)
           
BaseArrayIndex(String name, Column column, boolean unique, org.apache.commons.collections.primitives.IntList values)
           
 
Method Summary
 void changeRowId(Table table, Row row, int oldId, int newId)
           
protected abstract  int find(Object value, boolean required)
           
abstract  IndexLoader getIndexLoader()
           
 RowIterator getInorderRowIterator(RowSource source)
          Returns a RowIteratorwhich is inorder traversal of keys,
abstract  List getKeyList()
           
protected abstract  List getKeyList(int minIndex, int maxIndex)
           
 RowIterator getRowIterator(RowSource source, Function fn, Object value)
          Returns a RowIteratorover the indexed rows, limited by the given ComparisonOperator/value pair, using the default sort order.
 String getType()
          Returns my type.
protected  org.apache.commons.collections.primitives.IntList getValueList()
           
protected abstract  int insertKey(Object value)
           
protected abstract  int removeKey(Object value)
           
protected abstract  void removeKeyAt(int index)
           
 void rowDeleted(RowEvent event)
           
 void rowInserted(RowEvent event)
           
 void rowUpdated(RowEvent event)
           
 void save(File dataDirectory)
           
 void saveAfterTruncate(File dataDirectory)
           
 boolean supportsFunction(Function fn)
          Returns true iff #getRowIterator(org.axiondb.RowSource,org.axiondb.ComparisonOperator,java.lang.Object) can support the given operator, false otherwise.
 void truncate()
           
 
Methods inherited from class org.axiondb.engine.indexes.BaseIndex
getComparator, getDataType, getIndexedColumn, getName, isUnique
 
Methods inherited from class org.axiondb.event.BaseTableModificationListener
columnAdded, constraintAdded, constraintRemoved
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.axiondb.Index
getIndexedColumn, getName, isUnique
 
Methods inherited from interface org.axiondb.event.TableModificationListener
columnAdded, constraintAdded, constraintRemoved
 

Constructor Detail

BaseArrayIndex

public BaseArrayIndex(String name,
                      Column column,
                      boolean unique)

BaseArrayIndex

public BaseArrayIndex(String name,
                      Column column,
                      boolean unique,
                      org.apache.commons.collections.primitives.IntList values)
Method Detail

getIndexLoader

public abstract IndexLoader getIndexLoader()
Specified by:
getIndexLoader in interface Index
Specified by:
getIndexLoader in class BaseIndex

find

protected abstract int find(Object value,
                            boolean required)

insertKey

protected abstract int insertKey(Object value)
                          throws AxionException
Throws:
AxionException

removeKey

protected abstract int removeKey(Object value)
                          throws AxionException
Throws:
AxionException

removeKeyAt

protected abstract void removeKeyAt(int index)
                             throws AxionException
Throws:
AxionException

getKeyList

public abstract List getKeyList()

getKeyList

protected abstract List getKeyList(int minIndex,
                                   int maxIndex)

supportsFunction

public boolean supportsFunction(Function fn)
Description copied from interface: Index
Returns true iff #getRowIterator(org.axiondb.RowSource,org.axiondb.ComparisonOperator,java.lang.Object) can support the given operator, false otherwise.

Specified by:
supportsFunction in interface Index
Specified by:
supportsFunction in class BaseIndex

getRowIterator

public RowIterator getRowIterator(RowSource source,
                                  Function fn,
                                  Object value)
                           throws AxionException
Description copied from interface: Index
Returns a RowIteratorover the indexed rows, limited by the given ComparisonOperator/value pair, using the default sort order.

Specified by:
getRowIterator in interface Index
Specified by:
getRowIterator in class BaseIndex
Throws:
AxionException

getInorderRowIterator

public RowIterator getInorderRowIterator(RowSource source)
                                  throws AxionException
Description copied from interface: Index
Returns a RowIteratorwhich is inorder traversal of keys,

Specified by:
getInorderRowIterator in interface Index
Specified by:
getInorderRowIterator in class BaseIndex
Throws:
AxionException

rowInserted

public void rowInserted(RowEvent event)
                 throws AxionException
Specified by:
rowInserted in interface TableModificationListener
Overrides:
rowInserted in class BaseTableModificationListener
Throws:
AxionException

rowDeleted

public void rowDeleted(RowEvent event)
                throws AxionException
Specified by:
rowDeleted in interface TableModificationListener
Overrides:
rowDeleted in class BaseTableModificationListener
Throws:
AxionException

rowUpdated

public void rowUpdated(RowEvent event)
                throws AxionException
Specified by:
rowUpdated in interface TableModificationListener
Overrides:
rowUpdated in class BaseTableModificationListener
Throws:
AxionException

save

public void save(File dataDirectory)
          throws AxionException
Specified by:
save in interface Index
Specified by:
save in class BaseIndex
Throws:
AxionException

saveAfterTruncate

public void saveAfterTruncate(File dataDirectory)
                       throws AxionException
Specified by:
saveAfterTruncate in interface Index
Specified by:
saveAfterTruncate in class BaseIndex
Throws:
AxionException

getValueList

protected org.apache.commons.collections.primitives.IntList getValueList()

changeRowId

public void changeRowId(Table table,
                        Row row,
                        int oldId,
                        int newId)
                 throws AxionException
Specified by:
changeRowId in interface Index
Throws:
AxionException

truncate

public void truncate()
              throws AxionException
Specified by:
truncate in interface Index
Specified by:
truncate in class BaseIndex
Throws:
AxionException

getType

public String getType()
Description copied from interface: Index
Returns my type.

Specified by:
getType in interface Index