Go to the documentation of this file.
6 #include <unordered_set>
73 static std::unique_ptr<Table>
Create(
74 std::shared_ptr<const TableDesc> tabdesc);
77 Table(std::shared_ptr<const TableDesc> tabdesc,
78 std::unique_ptr<File> file)
219 LOG(
kWarning,
"unable to destruct the iterator due to an error "
220 "in Table::Iterator::EndScan(): \n%s", e.
GetMessage());
friend class Iterator
Definition: Table.h:330
Table implements a heap file over the virtual file provided by the FileManager.
Definition: Table.h:33
Iterator StartScan()
Starts a scan of the table from the beginning.
Definition: Table.cpp:205
void InsertRecord(Record &rec)
Inserts the record into table.
Definition: Table.cpp:45
Definition: TableDesc.h:11
PageNumber m_insertion_pid
The last known page possibly with empty space.
Definition: Table.h:171
constexpr PageNumber INVALID_PID
The invalid page number.
Definition: tdb_base.h:236
Table * m_table
The table that the iterator is iterating on.
Definition: Table.h:312
Record m_cur_record
The current record the iterator is on if the most recent Next() call returns true.
Definition: Table.h:318
Iterator StartScanFrom(RecordId rid)
Starts a scan of the table so that the first call to Iterator::Next() will return the first record wi...
Definition: Table.cpp:211
Table(std::shared_ptr< const TableDesc > tabdesc, std::unique_ptr< File > file)
Definition: Table.h:77
const TableDesc * GetTableDesc() const
Returns the table descriptor of this table.
Definition: Table.h:95
std::unique_ptr< File > m_file
An open file that stores the heap file for this table.
Definition: Table.h:165
constexpr LogSeverity kWarning
Definition: logging.h:20
constexpr Table * GetTable() const
Returns the table.
Definition: Table.h:252
The record ID of a record on a page is a pair of ‘(PageNumber, SlotId)’.
Definition: Record.h:17
The Iterator interface for scanning the heap file.
Definition: Table.h:185
ScopedBufferId m_pinned_bufid
A pin on the page where the current record is located.
Definition: Table.h:323
Iterator()
Constructs an invalid iterator.
Definition: Table.h:190
constexpr const Record & GetCurrentRecord() const
Returns the current record, which is only valid when a previous Next() call returns true.
Definition: Table.h:261
~Table()
Destructor.
Definition: Table.cpp:40
void EndScan()
Ends the scan, which may perform operations that may throw errors such as releasing page pins.
Definition: Table.cpp:307
void UpdateRecord(RecordId rid, Record &rec)
Updates the record specified by the record ID.
Definition: Table.cpp:167
bool Next()
Moves the iterator to the next record in the file.
Definition: Table.cpp:226
RecordId & GetRecordId()
Definition: Record.h:131
bool IsValid() const
Definition: Record.h:126
#define LOG(level,...)
LOG(LogSeverity level, const char *fmt, ...)
Definition: logging.h:116
bool IsAtValidRecord() const
Returns GetCurrentRecord().IsValid().
Definition: Table.h:277
std::shared_ptr< const TableDesc > m_tabdesc
The descriptor of the table.
Definition: Table.h:160
PageNumber m_lastpg_pid
Definition: Table.h:325
void EraseRecord(RecordId rid)
Erases the record specified by the record ID.
Definition: Table.cpp:132
static std::unique_ptr< Table > Create(std::shared_ptr< const TableDesc > tabdesc)
Constructs a table object on a heap file that was previously initialized by Table::Initialize().
Definition: Table.cpp:34
Iterator & operator=(Iterator &&it)=default
We can use the default move assignment only if EndScan does not do anything other than unpin the page...
const std::string & GetMessage() const
Definition: logging.h:42
~Iterator()
Destructs an iterator.
Definition: Table.h:205
RecordId GetCurrentRecordId() const
Returns the record ID of the current record.
Definition: Table.h:269
static void Initialize(const TableDesc *tabdesc)
Inititalizes a table on a newly created virtual file.
Definition: Table.cpp:10
uint32_t PageNumber
Definition: tdb_base.h:214