1 #ifndef STORAGE_VARLENDATAPAGE_H
2 #define STORAGE_VARLENDATAPAGE_H
FieldOffset & GetLength()
Definition: Record.h:110
const char *& GetData()
Definition: Record.h:100
RecordId & GetRecordId()
Definition: Record.h:131
VarlenDataPage implements a buffered heap page that supports inserting, deleting, updating and random...
Definition: VarlenDataPage.h:50
SlotId GetMinOccupiedSlotId() const
Returns the slot ID of the first occupied slot on this page.
Definition: VarlenDataPage.h:114
bool InsertRecord(Record &rec)
Inserts the record into the page.
Definition: VarlenDataPage.cpp:143
static FieldOffset ComputeFreeSpace(FieldOffset usr_data_sz, SlotId num_recs, FieldOffset total_reclen)
Computes the size of the free space on the page if there are num_recs records inserted to an empty Va...
Definition: VarlenDataPage.cpp:526
void CheckSID(SlotId sid) const
Checks if sid is in the range of [GetMinSlotId(), GetMaxSlotId()].
Definition: VarlenDataPage.h:306
bool UpdateRecord(SlotId sid, Record &rec)
Updates the record at the specified slot in place to a new one rec on this page if there's enough spa...
Definition: VarlenDataPage.cpp:249
char * GetUserData() const
Returns the pointer to the user data area.
Definition: VarlenDataPage.cpp:104
bool IsOccupied(SlotId sid) const
Returns whether the slot sid is currently occupied.
Definition: VarlenDataPage.cpp:135
char * m_pagebuf
Definition: VarlenDataPage.h:336
bool InsertRecordAt(SlotId sid, Record &rec)
Inserts the record at a given sid in the range of [GetMinSlotId(), GetMaxSlotId() + 1].
Definition: VarlenDataPage.cpp:386
VarlenDataPage(char *pagebuf)
Constructs a VarlenDataPage object on a buffered page in pagebuf that was previously initialized by V...
Definition: VarlenDataPage.cpp:99
SlotId GetMaxSlotId() const
Returns the largest occupied slot ID sid currently on this page if there's any.
Definition: VarlenDataPage.cpp:109
void RemoveSlot(SlotId sid)
Erases a record at the given sid in the range of [GetMinSlotId(), GetMaxSlotId()] if it exists and mo...
Definition: VarlenDataPage.cpp:439
void CompactSpace()
Definition: VarlenDataPage.cpp:345
SlotId GetMinSlotId() const
Returns the smallest valid slot ID.
Definition: VarlenDataPage.h:90
Record GetRecord(SlotId sid) const
Returns the record in the slot sid as a Record object, with its GetRecordId().sid set to sid and GetR...
Definition: VarlenDataPage.h:170
char * GetRecordBuffer(SlotId sid, FieldOffset *p_len) const
Returns the record buffer of the slot sid and sets *p_len to the length of the record if p_len is not...
Definition: VarlenDataPage.cpp:119
SlotId GetRecordCount() const
Returns the number of the occupied slots on this page.
Definition: VarlenDataPage.cpp:114
SlotData * GetSlotArray() const
Returns the beginning of the slot array, which grows backwards and its valid range is [-1....
Definition: VarlenDataPage.h:321
void ShiftSlots(SlotId n, bool truncate)
Shifts all the (occupied or unoccupied) slots to the right by n slots to truncate existing slots or t...
Definition: VarlenDataPage.cpp:467
SlotId GetMaxOccupiedSlotId() const
Returns the slot of the last occupied slot on this page.
Definition: VarlenDataPage.h:132
static void InitializePage(char *pagebuf, FieldOffset usr_data_sz=0)
Initializes a new (virtual) File page buffered in pagebuf as an empty variable-length data page.
Definition: VarlenDataPage.cpp:81
void PutRecordIntoSlot(SlotId sid, Record &rec)
Copies a record into an unoccupied space at the beginning of the free space and stores the offset and...
Definition: VarlenDataPage.cpp:207
bool EraseRecord(SlotId sid)
Erases a record from the page specified by the slot ID.
Definition: VarlenDataPage.cpp:222
#define LOG(level,...)
LOG(LogSeverity level, const char *fmt, ...)
Definition: logging.h:116
constexpr LogSeverity kError
Definition: logging.h:21
uint16_t SlotId
Definition: tdb_base.h:222
constexpr SlotId INVALID_SID
The invalid slot ID.
Definition: tdb_base.h:254
int16_t FieldOffset
Definition: tdb_base.h:211
constexpr SlotId MinSlotId
The minimum valid slot ID.
Definition: tdb_base.h:259
SlotId sid
Definition: Record.h:23
Describes a slot.
Definition: VarlenDataPage.cpp:67
constexpr const size_t PAGE_SIZE
Definition: tdb_base.h:159
#define SLOTID_FORMAT
Definition: tdb_base.h:273