|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.netbeans.mdr.persistence.btreeimpl.btreeindex.BtreePage
public abstract class BtreePage
Abstract class containing the main logic for searching and updating a Btree. It searches and updates the structure of the pages that make up the tree. Pages are obtained by calls on the associated BtreePageSource. Searching and updating of the entries on a given page is handled by the subclass for the specific page format.
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.
Field Summary | |
---|---|
byte[] |
pageBuffer
|
byte[] |
pageId
|
Constructor Summary | |
---|---|
BtreePage()
Construct an empty BtreePage. |
Method Summary | |
---|---|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public byte[] pageBuffer
public byte[] pageId
Constructor Detail |
---|
public BtreePage()
Method Detail |
---|
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 btree
StorageException
public void store()
public void read(java.io.InputStream in) throws StorageException
read
in interface Streamable
in
- InputStream to read from
StorageException
public void write(java.io.OutputStream out) throws StorageException
write
in interface Streamable
out
- OutputStream to write page to
StorageException
public void uninit()
public void put(byte[] key, byte[] data, byte operation, int index) throws StorageException
key
- byte array containing keydata
- byte array containing data
StorageException
public 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).
StorageException
public byte[] get(byte[] key) throws StorageException
key
- key to find the entry for
StorageException
public org.netbeans.mdr.persistence.btreeimpl.btreeindex.SearchResult getLocation(byte[] key) throws StorageException
key
- key to find the entry for
StorageException
public boolean remove(byte[] key) throws StorageException
key
- the key to be matched
StorageException
public boolean remove(byte[] key, byte[] data) throws StorageException
key
- the key to be matcheddata
- the data value to be matched
StorageException
public boolean remove(byte[] key, int index) throws StorageException
key
- the key to be matchedindex
- position within key's entries of the target entry
StorageException
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) throws StorageException
StorageException
protected byte compare(byte[] key, int entryNum)
key
- search keyentryNum
- entry number of target entry
protected byte compareData(byte[] data, int entryNum)
public void makeRoot()
public void dumpPage(java.io.PrintWriter out) throws StorageException
out
- PrintWriter to print to
StorageException
public void dumpPageHeader(java.io.PrintWriter out)
out
- PrintWriter to print topublic void dumpPageEntries(java.io.PrintWriter out) throws StorageException
out
- PrintWriter to print to
StorageException
public void dumpPageBuffer(java.io.PrintWriter out)
out
- PrintWriter to print topublic void dumpTree(java.io.PrintWriter out) throws StorageException
out
- PrintWriter to print to
StorageException
public int consistencyCheck(java.io.PrintWriter out) throws StorageException
StorageException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |