|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjdbm.btree.BPage
Page of a Btree.
The page contains a number of key-value pairs. Keys are ordered to allow dichotomic search.
If the page is a leaf page, the keys and values are user-defined and represent entries inserted by the user.
If the page is non-leaf, each key represents the greatest key in the underlying BPages and the values are recids pointing to the children BPages. The only exception is the rightmost BPage, which is considered to have an "infinite" key value, meaning that any insert will be to the left of this pseudo-key
Nested Class Summary | |
(package private) static class |
BPage.Browser
PRIVATE INNER CLASS Browser to traverse leaf BPages. |
(package private) static class |
BPage.InsertResult
STATIC INNER CLASS Result from insert() method call |
(package private) static class |
BPage.RemoveResult
STATIC INNER CLASS Result from remove() method call |
Field Summary | |
(package private) BTree |
_btree
Parent B+Tree. |
protected long[] |
_children
Children pages (recids) associated with keys. |
protected int |
_first
Index of first used item at the page |
protected boolean |
_isLeaf
Flag indicating if this is a leaf BPage. |
protected java.lang.Object[] |
_keys
Keys of children nodes |
protected long |
_next
Next leaf BPage (only if this BPage is a leaf) |
protected long |
_previous
Previous leaf BPage (only if this BPage is a leaf) |
protected long |
_recid
This BPage's record ID in the PageManager. |
protected java.lang.Object[] |
_values
Values associated with keys. |
(package private) static long |
serialVersionUID
Version id for serialization. |
Constructor Summary | |
|
BPage()
No-argument constructor used by serialization. |
(package private) |
BPage(BTree btree,
boolean isLeaf)
Overflow page constructor. |
(package private) |
BPage(BTree btree,
BPage root,
BPage overflow)
Root page overflow constructor |
(package private) |
BPage(BTree btree,
java.lang.Object key,
java.lang.Object value)
Root page (first insert) constructor. |
Method Summary | |
(package private) void |
assertConsistencyRecursive(int height)
Recursively assert the ordering of the BPage entries on this page and sub-pages. |
(package private) BPage |
childBPage(int index)
Return the child BPage at given index. |
java.lang.Object |
deserialize(byte[] serialized)
Deserialize the content of an object from a byte array. |
(package private) void |
dumpRecursive(int height,
int level)
Recursively dump the state of the BTree on screen. |
(package private) TupleBrowser |
find(int height,
java.lang.Object key)
Find the object associated with the given key. |
(package private) TupleBrowser |
findFirst()
Find first entry and return a browser positioned before it. |
(package private) java.lang.Object |
getLargestKey()
Get largest key under this BPage. |
(package private) BPage.InsertResult |
insert(int height,
java.lang.Object key,
java.lang.Object value,
boolean replace)
Insert the given key and value. |
(package private) boolean |
isEmpty()
Return true if BPage is empty. |
(package private) boolean |
isFull()
Return true if BPage is full. |
(package private) static byte[] |
readByteArray(java.io.ObjectInput in)
|
(package private) BPage.RemoveResult |
remove(int height,
java.lang.Object key)
Remove the entry associated with the given key. |
byte[] |
serialize(java.lang.Object obj)
Serialize the content of an object into a byte array. |
(package private) static void |
writeByteArray(java.io.ObjectOutput out,
byte[] buf)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
static final long serialVersionUID
transient BTree _btree
protected transient long _recid
protected boolean _isLeaf
protected java.lang.Object[] _keys
protected java.lang.Object[] _values
protected long[] _children
protected int _first
protected long _previous
protected long _next
Constructor Detail |
public BPage()
BPage(BTree btree, BPage root, BPage overflow) throws java.io.IOException
BPage(BTree btree, java.lang.Object key, java.lang.Object value) throws java.io.IOException
BPage(BTree btree, boolean isLeaf) throws java.io.IOException
Method Detail |
java.lang.Object getLargestKey()
boolean isEmpty()
boolean isFull()
TupleBrowser find(int height, java.lang.Object key) throws java.io.IOException
height
- Height of the current BPage (zero is leaf page)key
- The key
java.io.IOException
TupleBrowser findFirst() throws java.io.IOException
java.io.IOException
BPage.InsertResult insert(int height, java.lang.Object key, java.lang.Object value, boolean replace) throws java.io.IOException
Since the Btree does not support duplicate entries, the caller must specify whether to replace the existing value.
height
- Height of the current BPage (zero is leaf page)key
- Insert keyvalue
- Insert valuereplace
- Set to true to replace the existing value, if one exists.
java.io.IOException
BPage.RemoveResult remove(int height, java.lang.Object key) throws java.io.IOException
height
- Height of the current BPage (zero is leaf page)key
- Removal key
java.io.IOException
BPage childBPage(int index) throws java.io.IOException
java.io.IOException
static byte[] readByteArray(java.io.ObjectInput in) throws java.io.IOException
java.io.IOException
static void writeByteArray(java.io.ObjectOutput out, byte[] buf) throws java.io.IOException
java.io.IOException
void dumpRecursive(int height, int level) throws java.io.IOException
java.io.IOException
void assertConsistencyRecursive(int height) throws java.io.IOException
java.io.IOException
public java.lang.Object deserialize(byte[] serialized) throws java.io.IOException
deserialize
in interface Serializer
serialized
- Byte array representation of the object
java.io.IOException
public byte[] serialize(java.lang.Object obj) throws java.io.IOException
serialize
in interface Serializer
obj
- Object to serialize
java.io.IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |