SwatDB
|
#include <heapfile.h>
Public Member Functions | |
HeapFile (Catalog *catalog, BufferManager *buf_mgr, Schema *schema) | |
Constructor for HeapFile class. More... | |
~HeapFile () | |
HeapFile destructor. More... | |
void | createHeader () |
Allocates and initializes the header Page of the file. More... | |
void | flushHeader () |
Flushes header Page to disk. More... | |
RecordId | insertRecord (Record record) |
Inserts a Record into the HeapFile. More... | |
void | getRecord (RecordId record_id, Record *record) |
Sets the record_data of the given Record pointer to the data corresponding to the given RecordId. More... | |
void | updateRecord (RecordId record_id, Record record) |
Updates the record data in the HeapFile identified by the given RecordId to the data in the provided Record. More... | |
void | deleteRecord (RecordId record_id) |
Deletes the Record identified by the given RecordId. More... | |
HeapFileHeader | getHeader () |
THIS METHOD IS FOR DEBUGGING ONLY. Returns the current HeapFileHeader. | |
Public Member Functions inherited from File | |
File (Catalog *catalog, BufferManager *buf_mgr, Schema *schema) | |
Constructor. Initializes common state associated with every file, including catalog, buf_mgr, and schema. More... | |
virtual | ~File () |
Destructor. Data members are cleaned up, but none of the dynamically allocated data members are not deleted. The underlying Unix file is not deleted. | |
FileId | getMyFid () |
Returns the FileId of the File. More... | |
Schema * | getSchema () |
Returns the schema of the File. More... | |
PageId | getHeaderId () |
Returns Header PageId. More... | |
Friends | |
class | HeapFileScanner |
Additional Inherited Members | |
Protected Member Functions inherited from File | |
void | _setMyFid (FileId file_id) |
Sets the file_id and the schema fields of this File. More... | |
Protected Attributes inherited from File | |
FileId | file_id |
Catalog * | catalog |
BufferManager * | buf_mgr |
Schema * | schema |
PageId | header_id |
SwatDB HeapFile Class. Represents heap file in the system. It consists of doubly linked list of HeapPage and is an unsorted collection of records. Provides various methods, including inserting, modifying and retrieving records.
HeapFile::HeapFile | ( | Catalog * | catalog, |
BufferManager * | buf_mgr, | ||
Schema * | schema | ||
) |
Constructor for HeapFile class.
catalog | Pointer to the SwatDB Catalog object. |
buf_mgr | Pointer to the SwatDB BufferManager object. |
schema | Pointer to this file's Schema. |
|
inline |
|
virtual |
Allocates and initializes the header Page of the file.
InsufficientSpaceBufMgr | If there is not enough space in the bufferpool. |
Implements File.
void HeapFile::deleteRecord | ( | RecordId | record_id | ) |
Deletes the Record identified by the given RecordId.
record_id | RecordId identifying the record data to be deleted. |
InvalidSchemaHeapFile | If the given Record's Schema does not match that of the HeapFile(compare pointers). |
InvalidPageIdBufMgr | If the PageNum of the given RecordId is not valid. |
InvalidSlotIdHeapPage | If the SlotId of the given RecordId is not valid. |
|
virtual |
Flushes header Page to disk.
InsufficientSpaceBufMgr | If there is not enough space in the bufferpool for the header Page. |
InvalidPageIdBufMgr | If the header_id of the File is not valid. |
Implements File.
Sets the record_data of the given Record pointer to the data corresponding to the given RecordId.
record_id | RecordId of the record_data to be retrieved. |
record | Record pointer to store the retrieved data. |
InvalidSchemaHeapFile | If the given Record pointer's Schema does not match that of the HeapFile (compares pointers). |
InvalidPageIdBufMgr | If the PageNum of the given RecordId is not valid. |
InvalidSlotIdHeapPage | If the SlotId of the given RecordId is not valid. |
Inserts a Record into the HeapFile.
InvalidSchemaHeapFile | If the given Record's Schema does not match that of the HeapFile (compares pointers). |
InsufficientSpaceHeapPage | If the given Record's data exceeds the MAXIMUM_RECORD_SIZE. |
InsufficientSpaceHeapFile | If the number of pages (including the header) in the HeapFile exceeds MAX_PAGE_NUM. |
Updates the record data in the HeapFile identified by the given RecordId to the data in the provided Record.
record_id | RecordId identifying the record data to be updated. |
record | Record object containing data to overwrite the record data identified by the given RecordId. |
InvalidSchemaHeapFile | If the given Record's Schema does not match that of the HeapFile (compares pointers). |
InvalidPageIdBufMgr | if the PageNum of the given RecordId is not valid. |
InvalidSlotIdHeapPage | if the SlotId of the given RecordId is not valid. |
InsufficientSpaceHeapPage | if there is not enough space for the updated record in the corresponding HeapPage. |