#include <heapfilescanner.h>
Scanner class for HeapFile. Scanner scans the given HeapFile object and returns the next RecordId and initiliazes the given Record Data whenever getNext is called. Returns INVALID_RECORD_ID if it reaches the end of the file.
◆ HeapFileScanner()
HeapFileScanner::HeapFileScanner |
( |
HeapFile * |
file | ) |
|
Constructor.
- Precondition
- Valid HeapFile* is provided as input.
- Postcondition
- HeapFile object is constructed with initialized data members. The cur_page is pinned if file is not empty.
- Parameters
-
◆ ~HeapFileScanner()
HeapFileScanner::~HeapFileScanner |
( |
| ) |
|
Destructor.
- Precondition
- If the end of the File has not been reached, cur_page is pinned.
- Postcondition
- If the end of the File has not been reached, cur_page is released.
◆ getNext()
Returns RecordId of the next Record in the HeapFile and initializes the given Record object to the data of the identified Record. Scans for records by iterating through the linked list of full pages, then the linked list of free pages.
- Precondition
- None
- Postcondition
- RecordId of the next Record is returned and data of the given Record object is initialized to that of the Record identified by the RecordId. If there are no more records in the HeapFile, INVALID_RECORD_ID is returned. cur_page is the Page that is being scanned and is pinned. Once the end of cur_page is reached, it is the next Page in the File is pinned (if there is next Page) and cur_page is unpinned. cur_pid and cur_page are updated accordingly. If the end of the File is reached, no Page is pinned by the HeapFileScanner.
- Returns
- Next valid RecordId. INVALID_RECORD_ID if the end of the file is reached.
◆ buf_mgr
◆ cur_page
◆ cur_pid
PageId HeapFileScanner::cur_pid |
|
private |
◆ end_of_free
bool HeapFileScanner::end_of_free |
|
private |
bool indicating whether the end of the free pages list has been reached in the scan.
◆ end_of_full
bool HeapFileScanner::end_of_full |
|
private |
bool indicating whether the end of the full pages list has been reached in the scan.
◆ file
◆ scanner
The documentation for this class was generated from the following file: