public abstract class BtreePage extends java.lang.Object implements Streamable
There are two types of normal pages: FixedKeyPage and VarKeyPage. A given btree will have either all FixedKeyPages or all VarKeyPages, depending on the key type. These are kept in a tree structure where leaf pages contain the actual data and intermediate pages contain pageIds of the pages on the level below.
The exception to this is BigKeyPages, which may coexist with VarKeyPages in the same btree. These are used when a key is encountered whose length is such that the key plus its data would take up more than one-third the available space on a page (for a btree with MOFID data items this would be a key longer than 670 bytes). All BigKeyPages are kept on a single chain attached to the root on the right.
| Modifier and Type | Field and Description |
|---|---|
byte[] |
pageBuffer |
byte[] |
pageId |
| Constructor and Description |
|---|
BtreePage()
Construct an empty BtreePage.
|
| Modifier and Type | Method and Description |
|---|---|
protected byte |
compare(byte[] key,
int entryNum)
Compares the key with that of the specified entry.
|
protected byte |
compareData(byte[] data,
int entryNum) |
int |
consistencyCheck(java.io.PrintWriter out) |
void |
dumpPage(java.io.PrintWriter out)
Print BtreePage contents for debugging.
|
void |
dumpPageBuffer(java.io.PrintWriter out)
Print raw page buffer contents for debugging.
|
void |
dumpPageEntries(java.io.PrintWriter out)
Print BtreePage entries for debugging.
|
void |
dumpPageHeader(java.io.PrintWriter out)
Print BtreePage header for debugging.
|
void |
dumpTree(java.io.PrintWriter out)
Print tree starting from this page for debugging.
|
byte[] |
get(byte[] key)
Retrieves the value associated with the given key.
|
org.netbeans.mdr.persistence.btreeimpl.btreeindex.SearchResult |
getLocation(byte[] key)
Finds the first entry associated with the given key, navigating down
the btree from this page.
|
void |
init(Btree btree,
byte[] pageId,
byte[] pageBuffer,
boolean isNew)
Initialize a newly-instantiated or recycled BtreePage.
|
void |
makeRoot() |
void |
put(byte[] key,
byte[] data,
byte operation,
int index)
Add an entry to the btree, navigating down from this page.
|
void |
put(byte[] key,
byte[] data,
byte operation,
int index,
org.netbeans.mdr.persistence.btreeimpl.btreeindex.SearchResult resultPosition)
Add an entry to the btree, navigating down from this page.
|
void |
read(java.io.InputStream in)
(Streamable Interface) Populate the pageBuffer from the InputStream.
|
boolean |
remove(byte[] key)
Remove all entries from the btree that match the given key.
|
boolean |
remove(byte[] key,
byte[] data)
Remove the first entry encountered that matches the key/value pair.
|
boolean |
remove(byte[] key,
int index)
Remove the item matching the key at the indexed position.
|
protected org.netbeans.mdr.persistence.btreeimpl.btreeindex.BtreePage.BtreeEntry |
split(org.netbeans.mdr.persistence.btreeimpl.btreeindex.BtreePage.BtreeEntry entry,
int entryNum,
org.netbeans.mdr.persistence.btreeimpl.btreeindex.SearchResult resultPosition) |
void |
store()
Write BtreePage header data to the page buffer.
|
void |
uninit() |
void |
write(java.io.OutputStream out)
(Streamable Interface) Write this page to the OutputStream.
|
public BtreePage()
public void init(Btree btree, byte[] pageId, byte[] pageBuffer, boolean isNew) throws StorageException
btree - Btree to which this page belongspageId - page ID in byte arraypageBuffer - page bufferisNew - is this page new to the btreeStorageExceptionpublic void store()
public void read(java.io.InputStream in)
throws StorageException
read in interface Streamablein - InputStream to read fromStorageExceptionpublic void write(java.io.OutputStream out)
throws StorageException
write in interface Streamableout - OutputStream to write page toStorageExceptionpublic void uninit()
public void put(byte[] key,
byte[] data,
byte operation,
int index)
throws StorageException
key - byte array containing keydata - byte array containing dataStorageExceptionpublic void put(byte[] key,
byte[] data,
byte operation,
int index,
org.netbeans.mdr.persistence.btreeimpl.btreeindex.SearchResult resultPosition)
throws StorageException
key - byte array containing keydata - byte array containing dataresultPosition - location of inserted element is recorded in case this parameter is not null
and the oparation to perform is insert (add).StorageExceptionpublic byte[] get(byte[] key)
throws StorageException
key - key to find the entry forStorageExceptionpublic org.netbeans.mdr.persistence.btreeimpl.btreeindex.SearchResult getLocation(byte[] key)
throws StorageException
key - key to find the entry forStorageExceptionpublic boolean remove(byte[] key)
throws StorageException
key - the key to be matchedStorageExceptionpublic boolean remove(byte[] key,
byte[] data)
throws StorageException
key - the key to be matcheddata - the data value to be matchedStorageExceptionpublic boolean remove(byte[] key,
int index)
throws StorageException
key - the key to be matchedindex - position within key's entries of the target entryStorageExceptionprotected org.netbeans.mdr.persistence.btreeimpl.btreeindex.BtreePage.BtreeEntry split(org.netbeans.mdr.persistence.btreeimpl.btreeindex.BtreePage.BtreeEntry entry,
int entryNum,
org.netbeans.mdr.persistence.btreeimpl.btreeindex.SearchResult resultPosition)
throws StorageException
StorageExceptionprotected byte compare(byte[] key,
int entryNum)
key - search keyentryNum - entry number of target entryprotected byte compareData(byte[] data,
int entryNum)
public void makeRoot()
public void dumpPage(java.io.PrintWriter out)
throws StorageException
out - PrintWriter to print toStorageExceptionpublic void dumpPageHeader(java.io.PrintWriter out)
out - PrintWriter to print topublic void dumpPageEntries(java.io.PrintWriter out)
throws StorageException
out - PrintWriter to print toStorageExceptionpublic void dumpPageBuffer(java.io.PrintWriter out)
out - PrintWriter to print topublic void dumpTree(java.io.PrintWriter out)
throws StorageException
out - PrintWriter to print toStorageExceptionpublic int consistencyCheck(java.io.PrintWriter out)
throws StorageException
StorageExceptionCopyright © 2005-2012 Apache Software Foundation. All Rights Reserved.