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());
bool IsValid() const
Definition: Record.h:126
RecordId & GetRecordId()
Definition: Record.h:131
const std::string & GetMessage() const
Definition: logging.h:42
Definition: TableDesc.h:11
The Iterator interface for scanning the heap file.
Definition: Table.h:185
Iterator & operator=(Iterator &&it)=default
We can use the default move assignment only if EndScan does not do anything other than unpin the page...
bool Next()
Moves the iterator to the next record in the file.
Definition: Table.cpp:220
RecordId GetCurrentRecordId() const
Returns the record ID of the current record.
Definition: Table.h:269
void EndScan()
Ends the scan, which may perform operations that may throw errors such as releasing page pins.
Definition: Table.cpp:297
~Iterator()
Destructs an iterator.
Definition: Table.h:205
Record m_cur_record
The current record the iterator is on if the most recent Next() call returns true.
Definition: Table.h:318
Table * GetTable() const
Returns the table.
Definition: Table.h:252
Iterator(const Iterator &it)=delete
Deleted copy constructor.
bool IsAtValidRecord() const
Returns GetCurrentRecord().IsValid().
Definition: Table.h:277
Iterator(Iterator &&it)=default
Default move constructor.
const Record & GetCurrentRecord() const
Returns the current record, which is only valid when a previous Next() call returns true.
Definition: Table.h:261
Iterator & operator=(const Iterator &it)=delete
Deleted copy assignment.
Iterator()
Constructs an invalid iterator.
Definition: Table.h:190
ScopedBufferId m_pinned_bufid
A pin on the page where the current record is located.
Definition: Table.h:323
PageNumber m_lastpg_pid
Definition: Table.h:325
Table * m_table
The table that the iterator is iterating on.
Definition: Table.h:312
Table implements a heap file over the virtual file provided by the FileManager.
Definition: Table.h:33
PageNumber m_insertion_pid
The last known page possibly with empty space.
Definition: Table.h:171
~Table()
Destructor.
Definition: Table.cpp:38
void UpdateRecord(RecordId rid, Record &rec)
Updates the record specified by the record ID.
Definition: Table.cpp:155
void InsertRecord(Record &rec)
Inserts the record into table.
Definition: Table.cpp:43
Table(std::shared_ptr< const TableDesc > tabdesc, std::unique_ptr< File > file)
Definition: Table.h:77
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:32
static void Initialize(const TableDesc *tabdesc)
Inititalizes a table on a newly created virtual file.
Definition: Table.cpp:10
std::unique_ptr< File > m_file
An open file that stores the heap file for this table.
Definition: Table.h:165
std::shared_ptr< const TableDesc > m_tabdesc
The descriptor of the table.
Definition: Table.h:160
friend class Iterator
Definition: Table.h:330
Iterator StartScan()
Starts a scan of the table from the beginning.
Definition: Table.cpp:199
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:205
void EraseRecord(RecordId rid)
Erases the record specified by the record ID.
Definition: Table.cpp:121
const TableDesc * GetTableDesc() const
Returns the table descriptor of this table.
Definition: Table.h:95
#define LOG(level,...)
LOG(LogSeverity level, const char *fmt, ...)
Definition: logging.h:116
uint32_t PageNumber
Definition: tdb_base.h:213
constexpr LogSeverity kWarning
Definition: logging.h:20
constexpr PageNumber INVALID_PID
The invalid page number.
Definition: tdb_base.h:235
The record ID of a record on a page is a pair of ‘(PageNumber, SlotId)’.
Definition: Record.h:17