btree
Class BTIndexPage

java.lang.Object
  extended bydiskmgr.Page
      extended byheap.HFPage
          extended bybtree.BTSortedPage
              extended bybtree.BTIndexPage
All Implemented Interfaces:
heap.ConstSlot, GlobalConst

public class BTIndexPage
extends BTSortedPage

A BTIndexPage is an index page on a B+ tree. It holds abstract {key, PageId} pairs; it doesn't know anything about the keys (their lengths or their types), instead relying on the abstract interface in BT.java See those files for our {key,data} pairing interface and implementation.


Field Summary
 
Fields inherited from class heap.HFPage
CUR_PAGE, DPFIXED, EMPTY_SLOT, FREE_SPACE, INVALID_SLOT, NEXT_PAGE, PREV_PAGE, SIZE_OF_SLOT, SLOT_CNT, TYPE, USED_PTR
 
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
BTIndexPage(int keyType)
           
BTIndexPage(PageId pageno, int keyType)
          pin the page with pageno, and get the corresponding BTIndexPage, also it sets the type of node to be NodeType.INDEX.
BTIndexPage(Page page, int keyType)
          associate the BTIndexPage instance with the Page instance, also it sets the type of node to be NodeType.INDEX.
 
Method Summary
 KeyDataEntry getFirst(RID rid)
          Iterators.
 KeyDataEntry getNext(RID rid)
          Iterators.
 RID insertKey(KeyClass key, PageId pageNo)
          It inserts a value into the index page,
 
Methods inherited from class btree.BTSortedPage
deleteSortedRecord
 
Methods inherited from class heap.HFPage
available_space, deleteRecord, dumpPage, empty, firstRecord, getCurPage, getHFpageArray, getNextPage, getPrevPage, getRecord, getSlotCnt, getSlotLength, getSlotOffset, getType, init, insertRecord, nextRecord, openHFpage, returnRecord, setCurPage, setNextPage, setPrevPage, setSlot, setType
 
Methods inherited from class diskmgr.Page
getpage, setpage
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BTIndexPage

public BTIndexPage(PageId pageno,
                   int keyType)
            throws java.io.IOException,
                   ConstructPageException
pin the page with pageno, and get the corresponding BTIndexPage, also it sets the type of node to be NodeType.INDEX.

Parameters:
pageno - Input parameter. To specify which page number the BTIndexPage will correspond to.
keyType - either AttrType.attrInteger or AttrType.attrString. Input parameter.
Throws:
java.io.IOException - error from the lower layer
ConstructPageException - error when BTIndexpage constructor

BTIndexPage

public BTIndexPage(Page page,
                   int keyType)
            throws java.io.IOException,
                   ConstructPageException
associate the BTIndexPage instance with the Page instance, also it sets the type of node to be NodeType.INDEX.

Parameters:
page - input parameter. To specify which page the BTIndexPage will correspond to.
keyType - either AttrType.attrInteger or AttrType.attrString. Input parameter.
Throws:
java.io.IOException - error from the lower layer
ConstructPageException - error when BTIndexpage constructor

BTIndexPage

public BTIndexPage(int keyType)
            throws java.io.IOException,
                   ConstructPageException
Method Detail

insertKey

public RID insertKey(KeyClass key,
                     PageId pageNo)
              throws IndexInsertRecException
It inserts a value into the index page,

Returns:
It returns the rid where the record is inserted; null if no space left.
Throws:
IndexInsertRecException - error when insert

getFirst

public KeyDataEntry getFirst(RID rid)
                      throws IteratorException
Iterators. One of the two functions: getFirst and getNext which provide an iterator interface to the records on a BTIndexPage.

Parameters:
rid - It will be modified and the first rid in the index page will be passed out by itself. Input and Output parameter.
Returns:
return the first KeyDataEntry in the index page. null if NO MORE RECORD
Throws:
IteratorException - iterator error

getNext

public KeyDataEntry getNext(RID rid)
                     throws IteratorException
Iterators. One of the two functions: get_first and get_next which provide an iterator interface to the records on a BTIndexPage.

Parameters:
rid - It will be modified and next rid will be passed out by itself. Input and Output parameter.
Returns:
return the next KeyDataEntry in the index page. null if no more record
Throws:
IteratorException - iterator error