public final class BPage extends java.lang.Object implements Serializer
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
| Modifier and Type | Class and Description |
|---|---|
(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
|
| Modifier and Type | Field and Description |
|---|---|
(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 and Description |
|---|
BPage()
No-argument constructor used by serialization.
|
BPage(BTree btree,
boolean isLeaf)
Overflow page constructor.
|
BPage(BTree btree,
BPage root,
BPage overflow)
Root page overflow constructor
|
BPage(BTree btree,
java.lang.Object key,
java.lang.Object value)
Root page (first insert) constructor.
|
| Modifier and Type | Method and Description |
|---|---|
(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) |
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
public BPage()
BPage(BTree btree, BPage root, BPage overflow) throws java.io.IOException
java.io.IOExceptionBPage(BTree btree, java.lang.Object key, java.lang.Object value) throws java.io.IOException
java.io.IOExceptionBPage(BTree btree, boolean isLeaf) throws java.io.IOException
java.io.IOExceptionjava.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 keyjava.io.IOExceptionTupleBrowser findFirst() throws java.io.IOException
java.io.IOExceptionBPage.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.IOExceptionBPage.RemoveResult remove(int height, java.lang.Object key) throws java.io.IOException
height - Height of the current BPage (zero is leaf page)key - Removal keyjava.io.IOExceptionBPage childBPage(int index) throws java.io.IOException
java.io.IOExceptionstatic byte[] readByteArray(java.io.ObjectInput in)
throws java.io.IOException
java.io.IOExceptionstatic void writeByteArray(java.io.ObjectOutput out,
byte[] buf)
throws java.io.IOException
java.io.IOExceptionvoid dumpRecursive(int height,
int level)
throws java.io.IOException
java.io.IOExceptionvoid assertConsistencyRecursive(int height)
throws java.io.IOException
java.io.IOExceptionpublic java.lang.Object deserialize(byte[] serialized)
throws java.io.IOException
deserialize in interface Serializerserialized - Byte array representation of the objectjava.io.IOExceptionpublic byte[] serialize(java.lang.Object obj)
throws java.io.IOException
serialize in interface Serializerobj - Object to serializejava.io.IOExceptionCees de Groot (C) 2000-2001. All rights reserved http://jdbm.sourceforge.net