#include <hashindexscanner.h>
HashIndexScanner: Scanner for Hash indicies. Different constructors are used to initiate different types of scans over indicies. getNext gets the the next matching tuple based on the type of scan
◆ HashIndexScanner() [1/2]
Constructor for scanning all entries of the Index.
- Precondition
- Valid HashIndexFile* is provided as input.
- Postcondition
- IndexFileScanner object is constructed and initialized to do a scan of the entire index. cur_page, the first page of index K* entries is pinned if file is not empty.
- Parameters
-
◆ HashIndexScanner() [2/2]
Constructor for equality scan, this scan is over all K* entries with a matching key value to the passed key_val.
- Precondition
- Valid IndexFile and Key are provided as input.
- Postcondition
- HashIndexScanner object is constructed and initialized to do a scan of K* index entries with a matching key value. cur_page, the first page of index K* entries is pinned if file is not empty. Its key field is initialized to the passed key_val (a caller cannot reuse this Key object safely until the HashIndex Scanner is destroyed)
- Parameters
-
index | IndexFile object to be scanned. |
key_val | Key value on which to do the equality scan |
◆ ~HashIndexScanner()
HashIndexScanner::~HashIndexScanner |
( |
| ) |
|
Destructor.
- Precondition
- If the end of the Index scan has not been reached, cur_page is pinned.
- Postcondition
- cur_page is released.
◆ getNext() [1/2]
Returns RecordId of the next matching K* in the scan.
This is the getNext method to use if you only need the RID of the next matching entry and do not also want the key value of the next matching K* entry in the scan.
- Returns
- Next RecordId, or INVALID_RECORD_ID if the end of the scan is reached.
◆ getNext() [2/2]
Returns RecordId of the next matching K* and sets the data part of the passed Key to the Key value of the next matching K* entry in the scan.
This version of getNext should be used when the values of the key part of the K* entry are needed by the caller (for some non-equality searches this may be the case).
- Precondition
- the caller passes in a Key object that has been initialized to match the Key type of the index and with appropriate data field capacity to store the largest (in num bytes) key value (this function doesn't check capacity) TODO: should this function test if passed Key object is formatted correctly to store copy of Key value??
- Postcondition
- RecordId of the next Record is returned and data of the passed Key object is initialized to that of the next Key part of the next K* entry in the scan. If there are no more records in the Index scan, INVALID_RECORD_ID is returned.
- Returns
- Next RecordId, or INVALID_RECORD_ID if the end of the scan is reached.
◆ bucket_scanner
Scanner over a hash bucket page
◆ buf_mgr
◆ cur_dir_pid
PageId HashIndexScanner::cur_dir_pid |
|
private |
PageId of the Current Directory Page (useful for the full index scan)
◆ cur_page
Hash Bucket object that contains the latest Record scanned. if this is equal to nullptr then the scan is complete
◆ cur_pid
PageId HashIndexScanner::cur_pid |
|
private |
PageId of the Page that contains the latest Record scanned. if this is equal to INVALID_PAGE_ID then the scan is complete.
◆ full_scan
bool HashIndexScanner::full_scan |
|
private |
set to true if this is a full scan of the index
◆ index
◆ scan_complete
bool HashIndexScanner::scan_complete |
|
private |
set to true if the scan is done
◆ search_key
Key* HashIndexScanner::search_key |
|
private |
The search Key value on which to scan for matches. Because hash indexes don't support range scans, and only support EQUAL Comp operators, we only need to store the search Key.
This stores a copy of the value passed to the constructor.
The documentation for this class was generated from the following file: