#include <HeapFile.h>
This manages a linked list of heap file pages.
Public Member Functions | |
HeapFile (BufferManager *bufMgr, string name, int numPages) | |
Constructs a heap file with the specified number of pages. | |
HeapFile (BufferManager *bufMgr, string name) | |
Opens the heap file with the given name. | |
~HeapFile () | |
Destructor. | |
RID | insertRecord (char record[], int recLen) |
Inserts a new record onto the heap file. | |
void | getRecord (RID rid, char record[], int &recLen) |
Returns the record associated with an RID. | |
PageIterator * | pageIterator () |
Returns a page iterator on this heap file starting with the first page. | |
RecordIterator * | recordIterator () |
Returns a record iterator on this heap file starting with the first page. | |
Static Public Member Functions | |
static bool | erase (string filename) |
Erases the heap file entirely from the filesystem. |
HeapFile::HeapFile | ( | BufferManager * | bufMgr, | |
string | name, | |||
int | numPages | |||
) |
Constructs a heap file with the specified number of pages.
bufMgr | Pointer to a buffer manager to be used for the life of this HeapFile object. | |
name | Name to be used for heap file | |
numPages | maximum number of pages in heap file. |
HeapFile::HeapFile | ( | BufferManager * | bufMgr, | |
string | name | |||
) |
Opens the heap file with the given name.
bufMgr | Pointer to a buffer manager to be used for the life of this HeapFile object. | |
name | Name to be used for heap file |
static bool HeapFile::erase | ( | string | filename | ) | [static] |
Erases the heap file entirely from the filesystem.
Dangerous to do if still have a heap file object that refers to this file. Make sure to flush the buffer pool before calling this method to ensure that no dirty pages remain in memory that might get flushed later.
filename | name of the database. |
void HeapFile::getRecord | ( | RID | rid, | |
char | record[], | |||
int & | recLen | |||
) |
Returns the record associated with an RID.
rid | the rid of interest | |
record | an already allocated character array which the record will be copied into | |
recLen | the length of the record is copied into here |
DBFile.BadPageNumberException | if the page id is invalid | |
HFPage.BadSlotIdException | if the slot id within curRid is invalid |
RID HeapFile::insertRecord | ( | char | record[], | |
int | recLen | |||
) |
Inserts a new record onto the heap file.
record | the record to be inserted. A copy of the data is inserted into the heap file. | |
recLen | length of the record to be inserted. |
DBFile.FileFullException | if there are not enough free pages. |
PageIterator* HeapFile::pageIterator | ( | ) |
Returns a page iterator on this heap file starting with the first page.
RecordIterator* HeapFile::recordIterator | ( | ) |
Returns a record iterator on this heap file starting with the first page.