SwatDB
Public Member Functions | Private Attributes | List of all members
HeapFileScanner Class Reference

#include <heapfilescanner.h>

Collaboration diagram for HeapFileScanner:
Collaboration graph
[legend]

Public Member Functions

 HeapFileScanner (HeapFile *file)
 Constructor. More...
 
 ~HeapFileScanner ()
 Destructor. More...
 
RecordId getNext (Record *record)
 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. More...
 

Private Attributes

BufferManagerbuf_mgr
 
PageId cur_pid
 
HeapPagecur_page
 
HeapPageScannerscanner
 
HeapFilefile
 
bool end_of_full
 
bool end_of_free
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ 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
fileHeapFile object to be scanned.

◆ ~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.

Member Function Documentation

◆ getNext()

RecordId HeapFileScanner::getNext ( Record record)

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.

Member Data Documentation

◆ buf_mgr

BufferManager* HeapFileScanner::buf_mgr
private

Pointer to the BufferManager of SwatDB (for retrieving/pinning pages).

◆ cur_page

HeapPage* HeapFileScanner::cur_page
private

HeapPage object that contains the latest Record scanned.

◆ cur_pid

PageId HeapFileScanner::cur_pid
private

PageId of the Page that contains the latest Record scanned.

◆ 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

HeapFile* HeapFileScanner::file
private

Pointer to the HeapFile to be scanned.

◆ scanner

HeapPageScanner* HeapFileScanner::scanner
private

HeapPageScanner object pointer for scanning through individual HeapPages.


The documentation for this class was generated from the following file: