|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectglobal.Page
heap.HFPage
public class HFPage
Heap file data pages are implemented as slotted pages, with the slots at the front and the records in the back, both growing into the free space in the middle of the page. This design assumes that records are kept compacted when deletions are performed. Each slot contains the length and offset of its corresponding record.
Field Summary | |
---|---|
static int |
HEADER_SIZE
Total size of the header fields. |
static int |
SLOT_SIZE
Size of a record slot. |
Fields inherited from interface global.GlobalConst |
---|
EMPTY_SLOT, FIRST_PAGEID, INVALID_PAGEID, MAX_COLSIZE, MAX_TUPSIZE, NAME_MAXLEN, PAGE_SIZE, PIN_DISKIO, PIN_MEMCPY, UNPIN_CLEAN, UNPIN_DIRTY |
Constructor Summary | |
---|---|
HFPage()
Default constructor; creates a heap file page with default values. |
|
HFPage(Page page)
Constructor that wraps an existing heap file page. |
Method Summary | |
---|---|
void |
deleteRecord(RID rid)
Deletes a record from the page, compacting the records space. |
RID |
firstRecord()
Gets the RID of the first record on the page, or null if none. |
PageId |
getCurPage()
Gets the current page's id. |
short |
getFreeSpace()
Gets the amount of free space (in bytes). |
PageId |
getNextPage()
Gets the next page's id. |
PageId |
getPrevPage()
Gets the previous page's id. |
short |
getSlotCount()
Gets the number of slots on the page. |
short |
getSlotLength(int slotno)
Gets the length of the record referenced by the given slot. |
short |
getSlotOffset(int slotno)
Gets the offset of the record referenced by the given slot. |
short |
getType()
Gets the arbitrary type of the page. |
boolean |
hasNext(RID curRid)
Returns true if the iteration has more elements. |
RID |
insertRecord(byte[] record)
Inserts a new record into the page. |
RID |
nextRecord(RID curRid)
Gets the next RID after the given one, or null if no more. |
void |
print()
Prints the contents of a heap file page. |
byte[] |
selectRecord(RID rid)
Selects a record from the page. |
void |
setCurPage(PageId pageno)
Sets the current page's id. |
void |
setNextPage(PageId pageno)
Sets the next page's id. |
void |
setPrevPage(PageId pageno)
Sets the previous page's id. |
void |
setType(short type)
Sets the arbitrary type of the page. |
void |
updateRecord(RID rid,
byte[] record)
Updates a record on the page. |
Methods inherited from class global.Page |
---|
copyPage, getCharValue, getData, getFloatValue, getIntValue, getShortValue, getStringValue, setCharValue, setData, setFloatValue, setIntValue, setPage, setShortValue, setStringValue |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int HEADER_SIZE
public static final int SLOT_SIZE
Constructor Detail |
---|
public HFPage()
public HFPage(Page page)
Method Detail |
---|
public short getSlotCount()
public short getFreeSpace()
public short getType()
public void setType(short type)
public PageId getPrevPage()
public void setPrevPage(PageId pageno)
public PageId getNextPage()
public void setNextPage(PageId pageno)
public PageId getCurPage()
public void setCurPage(PageId pageno)
public short getSlotLength(int slotno)
public short getSlotOffset(int slotno)
public RID insertRecord(byte[] record)
public byte[] selectRecord(RID rid)
java.lang.IllegalArgumentException
- if the rid is invalidpublic void updateRecord(RID rid, byte[] record)
java.lang.IllegalArgumentException
- if the rid or record size is invalidpublic void deleteRecord(RID rid)
java.lang.IllegalArgumentException
- if the rid is invalidpublic RID firstRecord()
public boolean hasNext(RID curRid)
java.lang.IllegalArgumentException
- if the rid is invalidpublic RID nextRecord(RID curRid)
java.lang.IllegalArgumentException
- if the rid is invalidpublic void print()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |