Class which represents a fixed-size database page containing records. More...
#include <page.h>
Public Member Functions | |
Page () | |
RecordId | insertRecord (const std::string &record_data) |
std::string | getRecord (const RecordId &record_id) const |
void | updateRecord (const RecordId &record_id, const std::string &record_data) |
void | deleteRecord (const RecordId &record_id) |
bool | hasSpaceForRecord (const std::string &record_data) const |
std::uint16_t | getFreeSpace () const |
PageId | page_number () const |
PageId | next_page_number () const |
PageIterator | begin () |
PageIterator | end () |
Static Public Attributes | |
static const std::size_t | SIZE = 8192 |
static const std::size_t | DATA_SIZE = SIZE - sizeof(PageHeader) |
static const PageId | INVALID_NUMBER = 0 |
static const SlotId | INVALID_SLOT = 0 |
Friends | |
class | File |
class | PageIterator |
class | PageTest |
class | BufferTest |
Class which represents a fixed-size database page containing records.
A page is a fixed-size unit of data storage. Each page holds zero or more records, which consist of arbitrary binary data. Records are placed into slots and identified by a RecordId. Although a record's actual contents may be moved on the page, accessing a record by its slot is consistent.
badgerdb::Page::Page | ( | ) |
PageIterator badgerdb::Page::begin | ( | ) |
void badgerdb::Page::deleteRecord | ( | const RecordId & | record_id | ) |
PageIterator badgerdb::Page::end | ( | ) |
|
inline |
std::string badgerdb::Page::getRecord | ( | const RecordId & | record_id | ) | const |
Returns the record with the given ID. Returned data is a copy of what is stored on the page; use updateRecord to change it.
record_id | ID of the record to return. |
bool badgerdb::Page::hasSpaceForRecord | ( | const std::string & | record_data | ) | const |
RecordId badgerdb::Page::insertRecord | ( | const std::string & | record_data | ) |
Inserts a new record into the page.
record_data | Bytes that compose the record. |
Definition at line 33 of file page.cpp.
|
inline |
|
inline |
void badgerdb::Page::updateRecord | ( | const RecordId & | record_id, |
const std::string & | record_data | ||
) |
Updates the record with the given ID, replacing its data with a new version. This is equivalent to deleting the old record and inserting a new one, with the exception that the record ID will not change.
record_id | ID of record to update. |
record_data | Updated bytes that compose the record. |
Definition at line 49 of file page.cpp.
|
static |
|
static |
|
static |
|
static |