org.axiondb.util
Class StringBTree

java.lang.Object
  extended by org.axiondb.util.ObjectBTree
      extended by org.axiondb.util.StringBTree

public class StringBTree
extends ObjectBTree

An ObjectBTreeoptimized for reading and writing Strings.

Version:
$Revision: 1.6 $ $Date: 2004/08/27 03:21:22 $

Constructor Summary
StringBTree(File idxDir, String idxName, int minimizationFactor, Comparator comp)
          Create or load a new root node.
 
Method Summary
protected  void addFileId(int fileId)
          Add a reference to the given file id.
protected  void addFileId(int index, int fileid)
          Store a reference to the given file id at the specifed index.
protected  void addFileIds(org.apache.commons.collections.primitives.IntList fileIds)
          Add the given specified file ids.
protected  ObjectBTree createNode(org.axiondb.util.BTreeMetaData meta, Comparator comp)
          Create a new node.
protected  org.axiondb.util.BTreeMetaData getBTreeMetaData()
           
protected  org.apache.commons.collections.primitives.IntList getChildIds()
           
protected  int getFileId()
           
protected  int getFileIdForIndex(int index)
          Get the file id for the specified index.
protected  int getKeyCapacity()
          Return the maximum number of keys I can contain (2* minimizationFactor-1).
protected  int getMinimizationFactor()
           
protected  Object getReplacementForNullKey()
           
protected  int getValue(int index)
           
protected  org.apache.commons.collections.primitives.IntList getValues()
           
protected  boolean isFull()
           
protected  boolean isLeaf()
          Returns true iff I don't contain any child nodes.
protected  boolean isRoot()
          Returns true iff I am the root node.
protected  ObjectBTree loadNode(org.axiondb.util.BTreeMetaData meta, Comparator comp, int fileId)
          Read the node with the specified fileId from disk.
protected  void read()
          Reads in the node.
 void save(File dataDirectory)
          Saves the tree.
 void saveAfterTruncate()
           
protected  void saveCounterIfRoot()
           
protected  void setChildIds(org.apache.commons.collections.primitives.IntList childIds)
           
protected  void setFileId(int fileId)
           
protected  void setValue(int index, int val)
           
protected  void setValues(org.apache.commons.collections.primitives.IntList vals)
           
protected  String space(int n)
          Return a String comprised of 2*n spaces.
protected  void write()
          Writes the node file out.
 
Methods inherited from class org.axiondb.util.ObjectBTree
addKeyValuePair, clearData, delete, get, getAll, getAllExcludingNull, getAllExcludingNull, getAllFrom, getAllTo, getKey, inorderIterator, insert, replaceId, save, size, toString, truncate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StringBTree

public StringBTree(File idxDir,
                   String idxName,
                   int minimizationFactor,
                   Comparator comp)
            throws IOException,
                   ClassNotFoundException
Create or load a new root node.

Throws:
IOException
ClassNotFoundException
Method Detail

createNode

protected ObjectBTree createNode(org.axiondb.util.BTreeMetaData meta,
                                 Comparator comp)
                          throws IOException,
                                 ClassNotFoundException
Description copied from class: ObjectBTree
Create a new node.

Overrides:
createNode in class ObjectBTree
Throws:
IOException
ClassNotFoundException

loadNode

protected ObjectBTree loadNode(org.axiondb.util.BTreeMetaData meta,
                               Comparator comp,
                               int fileId)
                        throws IOException,
                               ClassNotFoundException
Description copied from class: ObjectBTree
Read the node with the specified fileId from disk.

Overrides:
loadNode in class ObjectBTree
Throws:
IOException
ClassNotFoundException

read

protected void read()
             throws IOException,
                    ClassNotFoundException
Description copied from class: ObjectBTree
Reads in the node. This doesn't read in the entire subtree, which happens incrementally as files are needed.

Overrides:
read in class ObjectBTree
Throws:
IOException
ClassNotFoundException

write

protected void write()
              throws IOException
Description copied from class: ObjectBTree
Writes the node file out. This is differentiated from save in that it doesn't save the entire tree or the counter file.

Overrides:
write in class ObjectBTree
Throws:
IOException

getReplacementForNullKey

protected Object getReplacementForNullKey()
Overrides:
getReplacementForNullKey in class ObjectBTree

save

public void save(File dataDirectory)
          throws IOException,
                 ClassNotFoundException
Saves the tree. It saves the counter file and write()s any dirty nodes.

Throws:
IOException
ClassNotFoundException

saveAfterTruncate

public void saveAfterTruncate()
                       throws IOException,
                              ClassNotFoundException
Throws:
IOException
ClassNotFoundException

getValues

protected final org.apache.commons.collections.primitives.IntList getValues()

setValues

protected final void setValues(org.apache.commons.collections.primitives.IntList vals)

getValue

protected final int getValue(int index)

setValue

protected final void setValue(int index,
                              int val)

getMinimizationFactor

protected final int getMinimizationFactor()

getKeyCapacity

protected final int getKeyCapacity()
Return the maximum number of keys I can contain (2* minimizationFactor-1).


isFull

protected final boolean isFull()

getFileId

protected final int getFileId()

setFileId

protected final void setFileId(int fileId)

getChildIds

protected final org.apache.commons.collections.primitives.IntList getChildIds()

setChildIds

protected final void setChildIds(org.apache.commons.collections.primitives.IntList childIds)

isRoot

protected final boolean isRoot()
Returns true iff I am the root node.


isLeaf

protected final boolean isLeaf()
Returns true iff I don't contain any child nodes.


getBTreeMetaData

protected final org.axiondb.util.BTreeMetaData getBTreeMetaData()

saveCounterIfRoot

protected final void saveCounterIfRoot()
                                throws IOException
Throws:
IOException

space

protected final String space(int n)
Return a String comprised of 2*n spaces.


addFileId

protected final void addFileId(int index,
                               int fileid)
Store a reference to the given file id at the specifed index. Flags me as dirty.


getFileIdForIndex

protected final int getFileIdForIndex(int index)
Get the file id for the specified index.


addFileId

protected final void addFileId(int fileId)
Add a reference to the given file id. Flags me as dirty.


addFileIds

protected final void addFileIds(org.apache.commons.collections.primitives.IntList fileIds)
Add the given specified file ids. Flags me as dirty.