Go to the documentation of this file. 1 #ifndef STORAGE_VARLENDATAPAGE_H
2 #define STORAGE_VARLENDATAPAGE_H
325 #endif // STORAGE_VARLENDATAPAGE_H
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
int16_t FieldOffset
Definition: tdb_base.h:212
constexpr SlotId INVALID_SID
The invalid slot ID.
Definition: tdb_base.h:255
VarlenDataPage implements a buffered heap page that supports inserting, deleting, updating and random...
Definition: VarlenDataPage.h:40
constexpr const size_t PAGE_SIZE
Definition: tdb_base.h:159
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
VarlenDataPage(char *pagebuf)
Constructs a VarlenDataPage object on a buffered page in pagebuf that was previously initialized by V...
Definition: VarlenDataPage.cpp:99
constexpr SlotId MinSlotId
The minimum valid slot ID.
Definition: tdb_base.h:260
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
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:160
uint16_t SlotId
Definition: tdb_base.h:223
constexpr LogSeverity kError
Definition: logging.h:21
bool InsertRecordAt(SlotId sid, Record &rec)
Inserts the record at a given sid in the range of [GetMinSlotId(), GetMaxSlotId() + 1].
Definition: VarlenDataPage.cpp:386
void CheckSID(SlotId sid) const
Checks if sid is in the range of [GetMinSlotId(), GetMaxSlotId()].
Definition: VarlenDataPage.h:290
SlotId GetRecordCount() const
Returns the number of the occupied slots on this page.
Definition: VarlenDataPage.cpp:114
FieldOffset & GetLength()
Definition: Record.h:110
bool IsOccupied(SlotId sid) const
Returns whether the slot sid is currently occupied.
Definition: VarlenDataPage.cpp:135
#define SLOTID_FORMAT
Definition: tdb_base.h:274
SlotId sid
Definition: Record.h:23
const char *& GetData()
Definition: Record.h:100
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 GetMinOccupiedSlotId() const
Returns the slot ID of the first occupied slot on this page.
Definition: VarlenDataPage.h:104
RecordId & GetRecordId()
Definition: Record.h:131
SlotId GetMaxOccupiedSlotId() const
Returns the slot of the last occupied slot on this page.
Definition: VarlenDataPage.h:122
constexpr SlotId GetMinSlotId() const
Returns the smallest valid slot ID.
Definition: VarlenDataPage.h:80
Describes a slot.
Definition: VarlenDataPage.cpp:67
#define LOG(level,...)
LOG(LogSeverity level, const char *fmt, ...)
Definition: logging.h:116
char * m_pagebuf
Definition: VarlenDataPage.h:320
bool EraseRecord(SlotId sid)
Erases a record from the page specified by the slot ID.
Definition: VarlenDataPage.cpp:222
constexpr SlotData * GetSlotArray() const
Returns the beginning of the slot array, which grows backwards and its valid range is [-1....
Definition: VarlenDataPage.h:305
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 InsertRecord(Record &rec)
Inserts the record into the page.
Definition: VarlenDataPage.cpp:143
SlotId GetMaxSlotId() const
Returns the largest occupied slot ID sid currently on this page if there's any.
Definition: VarlenDataPage.cpp:109
void CompactSpace()
Definition: VarlenDataPage.cpp:345
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 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
char * GetUserData() const
Returns the pointer to the user data area.
Definition: VarlenDataPage.cpp:104