The Iterator interface for scanning the heap file.
More...
#include <storage/Table.h>
The Iterator interface for scanning the heap file.
Note: a call to Table::InsertRecord(), Table::UpdateRecord(), or Table::EraseRecord() may insert a new record and/or remove a record somewhere in the file. You do not have to worry about them in the heap file project as long as the implementation is able to return exactly all the records in the file, provided that there are no concurrent update operations, or there's only in-place update of the current record.
◆ Iterator() [1/4]
taco::Table::Iterator::Iterator |
( |
| ) |
|
|
inline |
Constructs an invalid iterator.
◆ Iterator() [2/4]
Constructs an iterator right before the specified record ID.
A Next()
call will return the first valid record after that if any.
◆ ~Iterator()
taco::Table::Iterator::~Iterator |
( |
| ) |
|
|
inline |
Destructs an iterator.
It should attemp to call EndScan() but may not throw any error.
◆ Iterator() [3/4]
taco::Table::Iterator::Iterator |
( |
Iterator && |
it | ) |
|
|
default |
Default move constructor.
◆ Iterator() [4/4]
taco::Table::Iterator::Iterator |
( |
const Iterator & |
it | ) |
|
|
delete |
Deleted copy constructor.
◆ EndScan()
void taco::Table::Iterator::EndScan |
( |
| ) |
|
Ends the scan, which may perform operations that may throw errors such as releasing page pins.
You should always explicitly calling EndScan() to avoid any error being thrown and caught in the destructor.
After the EndScan() call, the iterator becomes invalid and the only functions may be called on this iterator are EndScan() and the destructor (which should do nothing). Note that EndScan() may be called from the destructor after the table object is destructed in exception handling, so make sure not to dereference m_table
in EndScan().
◆ GetCurrentRecord()
const Record& taco::Table::Iterator::GetCurrentRecord |
( |
| ) |
const |
|
inline |
Returns the current record, which is only valid when a previous Next() call returns true.
◆ GetCurrentRecordId()
RecordId taco::Table::Iterator::GetCurrentRecordId |
( |
| ) |
const |
|
inline |
Returns the record ID of the current record.
◆ GetTable()
Table* taco::Table::Iterator::GetTable |
( |
| ) |
const |
|
inline |
Returns the table.
It is only non-null when the iterator is a valid iterator and has not been ended.
◆ IsAtValidRecord()
bool taco::Table::Iterator::IsAtValidRecord |
( |
| ) |
const |
|
inline |
◆ Next()
bool taco::Table::Iterator::Next |
( |
| ) |
|
Moves the iterator to the next record in the file.
Returns true
if there is such a record, and the current record of this iterator stores a pointer to its buffer on a buffered page. The page pin should be held as long as the current record still points the buffer on the buffered page. Otherwise, it returns false
.
Note: the tuples that appear on an earlier page of the file must be iterated before those that appear on a later page, and the tuples on the same page must be iterated in the order from the smallest occupied slot id to the largest occupied slot id.
◆ operator=() [1/2]
◆ operator=() [2/2]
We can use the default move assignment only if EndScan does not do anything other than unpin the page and we use ScopedBufferId to store the buffer ID.
Otherwise, you'll have to implement your own move assignment operator.
◆ Table
◆ m_cur_record
Record taco::Table::Iterator::m_cur_record |
|
private |
The current record the iterator is on if the most recent Next() call returns true
.
Otherwise, it should be invalid.
◆ m_lastpg_pid
◆ m_pinned_bufid
A pin on the page where the current record is located.
◆ m_table
Table* taco::Table::Iterator::m_table |
|
private |
The table that the iterator is iterating on.
The documentation for this class was generated from the following files: