#include <sortedpage.h>
SortedPage is a special kind of HeapPage that arrange the records in page in sorted order according to a specified key. Records and slots directory on the page are compact. Therefore it is unsafe to retrieve a record on a SortedPage based on RecordID after a deletion.
Page --- HeapPage --- SortedPage
Insert a record, pointed to by pointer recPtr, of length recLen, into this page. Output the record id of the inserted record as rid.
Delete a record with record id rid from the page,
Set the type of the page to t.
Return the type of the page.
Return the number of records on this page.
Initialize the data members in this page. Set the page id of this page to pageNo.
Return the page id of this page.
Return the size of empty space on this page (in bytes).
can be set to INDEX_NODE or LEAF_NODE to indicate the type of this object. INDEX_NODE indicates that this object is a BTIndexPage object, LEAF_NODE indicates a BTLeafPage object.
Each Slots is contains two attributes : offset and length. Even though this array is defined as size 1, we can access slots[i] as long as it is within the boundry of the page.
This array represents the area where data (including slots directories) can be stored on this page. HEAPPAGE_DATA_SIZE is the size of this area.
To check if a page is half filled :
AvailableSpace() > HEAPPAGE_DATA_SIZE/2
To create a new page of type BTLeafNode:
Status s; PageID pid; SortedPage *page; s = MINIBASE_BM->NewPage(pid, (Page *&)page); if (s != OK) { // error; } page->Init(pid); page->SetType(LEAF_NODE);
To get an entry at slot number i:
data + slots[i].offset