|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.axiondb.util.ObjectBTree
public class ObjectBTree
A B-Tree for Object
s, based on the implementation described in
"Introduction to Algorithms" by Cormen, Leiserson and Rivest (CLR).
Constructor Summary | |
---|---|
protected |
ObjectBTree(org.axiondb.util.BTreeMetaData meta,
Comparator comp)
Create a new, non-root node. |
protected |
ObjectBTree(org.axiondb.util.BTreeMetaData meta,
Comparator comp,
int fileId)
Create a non-root node by reading it from disk. |
|
ObjectBTree(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 void |
addKeyValuePair(Object key,
int value,
boolean setDirty)
|
void |
clearData()
Clear my keys, values, and file ids. |
protected ObjectBTree |
createNode(org.axiondb.util.BTreeMetaData meta,
Comparator comp)
Create a new node. |
void |
delete(Object key)
Delete an arbitrary instance of the specified key, which when you think about it, isn't terribly useful. |
Integer |
get(Object key)
Find some occurance of the given key. |
org.apache.commons.collections.primitives.IntListIterator |
getAll(Object key)
Obtain an iterator over all values associated with the given key. |
org.apache.commons.collections.primitives.IntListIterator |
getAllExcludingNull()
Obtain an iterator over all values excluding null key values |
protected void |
getAllExcludingNull(IntListIteratorChain chain)
|
org.apache.commons.collections.primitives.IntListIterator |
getAllFrom(Object key)
Obtain an iterator over all values greater than or equal to the given key. |
org.apache.commons.collections.primitives.IntListIterator |
getAllTo(Object key)
Obtain an iterator over all values strictly less than the given key. |
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 Object |
getKey(int index)
Obtain the key stored at 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()
|
IntListIteratorChain |
inorderIterator()
|
void |
insert(Object key,
int value)
Insert the given key/value pair. |
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 |
replaceId(Object key,
int oldRowId,
int newRowId)
Replace any occurance of oldRowId associated with the given key with newRowId. |
void |
save()
Deprecated. See save(File) |
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)
|
int |
size()
Returns the number of keys I currently contain. |
protected String |
space(int n)
Return a String comprised of 2*n spaces. |
String |
toString()
Obtain a String representation of this node, suitable for debugging. |
void |
truncate()
|
protected void |
write()
Writes the node file out. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ObjectBTree(File idxDir, String idxName, int minimizationFactor, Comparator comp) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
protected ObjectBTree(org.axiondb.util.BTreeMetaData meta, Comparator comp) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
protected ObjectBTree(org.axiondb.util.BTreeMetaData meta, Comparator comp, int fileId) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
Method Detail |
---|
public final int size()
minimizationFactor
-1 and at most
2*minimizationFactor
-1 for all nodes except the
root (which may have fewer than minimizationFactor
-1 keys).
public final String toString()
toString
in class Object
public final Integer get(Object key) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
public final org.apache.commons.collections.primitives.IntListIterator getAll(Object key) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
public final org.apache.commons.collections.primitives.IntListIterator getAllFrom(Object key) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
public final org.apache.commons.collections.primitives.IntListIterator getAllExcludingNull() throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
public final org.apache.commons.collections.primitives.IntListIterator getAllTo(Object key) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
public final void insert(Object key, int value) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
public final void replaceId(Object key, int oldRowId, int newRowId) throws ClassNotFoundException, IOException
ClassNotFoundException
IOException
public final void delete(Object key) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
public final void save() throws IOException, ClassNotFoundException
save(File)
IOException
ClassNotFoundException
protected ObjectBTree loadNode(org.axiondb.util.BTreeMetaData meta, Comparator comp, int fileId) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
protected ObjectBTree createNode(org.axiondb.util.BTreeMetaData meta, Comparator comp) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
protected void write() throws IOException
IOException
protected void read() throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
protected void getAllExcludingNull(IntListIteratorChain chain) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
protected final Object getKey(int index)
public final void clearData()
public void truncate()
protected final void addKeyValuePair(Object key, int value, boolean setDirty)
public IntListIteratorChain inorderIterator() throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
protected Object getReplacementForNullKey()
public void save(File dataDirectory) throws IOException, ClassNotFoundException
write()
s any dirty nodes.
IOException
ClassNotFoundException
public void saveAfterTruncate() throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
protected final org.apache.commons.collections.primitives.IntList getValues()
protected final void setValues(org.apache.commons.collections.primitives.IntList vals)
protected final int getValue(int index)
protected final void setValue(int index, int val)
protected final int getMinimizationFactor()
protected final int getKeyCapacity()
minimizationFactor
-1).
protected final boolean isFull()
protected final int getFileId()
protected final void setFileId(int fileId)
protected final org.apache.commons.collections.primitives.IntList getChildIds()
protected final void setChildIds(org.apache.commons.collections.primitives.IntList childIds)
protected final boolean isRoot()
true
iff I am the root node.
protected final boolean isLeaf()
true
iff I don't contain any child nodes.
protected final org.axiondb.util.BTreeMetaData getBTreeMetaData()
protected final void saveCounterIfRoot() throws IOException
IOException
protected final String space(int n)
protected final void addFileId(int index, int fileid)
protected final int getFileIdForIndex(int index)
protected final void addFileId(int fileId)
protected final void addFileIds(org.apache.commons.collections.primitives.IntList fileIds)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |