HeapFile Class Reference

#include <HeapFile.h>

List of all members.


Detailed Description

Heap file.

This manages a linked list of heap file pages.

Author:
Dave Musicant, with considerable material reused from the UW-Madison Minibase project


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.
PageIteratorpageIterator ()
 Returns a page iterator on this heap file starting with the first page.
RecordIteratorrecordIterator ()
 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.


Constructor & Destructor Documentation

HeapFile::HeapFile ( BufferManager bufMgr,
string  name,
int  numPages 
)

Constructs a heap file with the specified number of pages.

Parameters:
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.

Parameters:
bufMgr Pointer to a buffer manager to be used for the life of this HeapFile object.
name Name to be used for heap file


Member Function Documentation

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.

Parameters:
filename name of the database.
Returns:
true if operation succeeded.

void HeapFile::getRecord ( RID  rid,
char  record[],
int &  recLen 
)

Returns the record associated with an RID.

Parameters:
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
Exceptions:
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.

Parameters:
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.
Returns:
the RID of the new record.
Exceptions:
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.

Returns:
a pointer to a page iterator starting with the first page

RecordIterator* HeapFile::recordIterator (  ) 

Returns a record iterator on this heap file starting with the first page.

Returns:
a record iterator starting with the first page


Generated on Thu Aug 30 08:39:22 2007 for Minibase by  doxygen 1.4.7