btree
Class BT

java.lang.Object
  extended bybtree.BT
All Implemented Interfaces:
GlobalConst

public class BT
extends java.lang.Object
implements GlobalConst

This file contains, among some debug utilities, the interface to our key and data abstraction. The BTLeafPage and BTIndexPage code know very little about the various key types. Essentially we provide a way for those classes to package and unpackage pairs in a space-efficient manner. That is, the packaged result contains the key followed immediately by the data value; No padding bytes are used (not even for alignment). Furthermore, the BT<*>Page classes need not know anything about the possible AttrType values, since all their processing of pairs is done by the functions declared here. In addition to packaging/unpacking of pairs, we provide a keyCompare function for the (obvious) purpose of comparing keys of arbitrary type (as long as they are defined here). For debug utilities, we provide some methods to print any page or the whole B+ tree structure or all leaf pages.


Field Summary
 
Fields inherited from interface global.GlobalConst
INVALID_PAGE, MAX_NAME, MAX_SPACE, MAXATTRNAME, MAXFILENAME, MAXINDEXNAME, MINIBASE_BUFFER_POOL_SIZE, MINIBASE_DB_SIZE, MINIBASE_DEFAULT_SHAREDMEM_SIZE, MINIBASE_MAX_TRANSACTIONS, MINIBASE_MAXARRSIZE, MINIBASE_PAGESIZE, NUMBUF
 
Constructor Summary
BT()
           
 
Method Summary
static int keyCompare(KeyClass key1, KeyClass key2)
          It compares two keys.
static void printAllLeafPages(btree.BTreeHeaderPage header)
          For debug.
static void printBTree(btree.BTreeHeaderPage header)
          For debug.
static void printPage(PageId pageno, int keyType)
          used for debug: to print a page out.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BT

public BT()
Method Detail

keyCompare

public static final int keyCompare(KeyClass key1,
                                   KeyClass key2)
                            throws KeyNotMatchException
It compares two keys.

Parameters:
key1 - the first key to compare. Input parameter.
key2 - the second key to compare. Input parameter.
Returns:
return negative if key1 less than key2; positive if key1 bigger than key2; 0 if key1=key2.
Throws:
KeyNotMatchException - key is not IntegerKey or StringKey class

printPage

public static void printPage(PageId pageno,
                             int keyType)
                      throws java.io.IOException,
                             IteratorException,
                             ConstructPageException,
                             HashEntryNotFoundException,
                             ReplacerException,
                             PageUnpinnedException,
                             InvalidFrameNumberException
used for debug: to print a page out. The page is either BTIndexPage, or BTLeafPage.

Parameters:
pageno - the number of page. Input parameter.
keyType - It specifies the type of key. It can be AttrType.attrString or AttrType.attrInteger. Input parameter.
Throws:
java.io.IOException - error from the lower layer
IteratorException - error for iterator
ConstructPageException - error for BT page constructor
HashEntryNotFoundException - error from the lower layer
ReplacerException - error from the lower layer
PageUnpinnedException - error from the lower layer
InvalidFrameNumberException - error from the lower layer

printBTree

public static void printBTree(btree.BTreeHeaderPage header)
                       throws java.io.IOException,
                              ConstructPageException,
                              IteratorException,
                              HashEntryNotFoundException,
                              InvalidFrameNumberException,
                              PageUnpinnedException,
                              ReplacerException
For debug. Print the B+ tree structure out

Parameters:
header - the head page of the B+ tree file
Throws:
java.io.IOException - error from the lower layer
ConstructPageException - error from BT page constructor
IteratorException - error from iterator
HashEntryNotFoundException - error from lower layer
InvalidFrameNumberException - error from lower layer
PageUnpinnedException - error from lower layer
ReplacerException - error from lower layer

printAllLeafPages

public static void printAllLeafPages(btree.BTreeHeaderPage header)
                              throws java.io.IOException,
                                     ConstructPageException,
                                     IteratorException,
                                     HashEntryNotFoundException,
                                     InvalidFrameNumberException,
                                     PageUnpinnedException,
                                     ReplacerException
For debug. Print all leaf pages of the B+ tree out

Parameters:
header - the head page of the B+ tree file
Throws:
java.io.IOException - error from the lower layer
ConstructPageException - error for BT page constructor
IteratorException - error from iterator
HashEntryNotFoundException - error from lower layer
InvalidFrameNumberException - error from lower layer
PageUnpinnedException - error from lower layer
ReplacerException - error from lower layer