Expand description
Table-leaf page layout: a slot directory + cell content.
A TablePage operates on the payload portion of a page (the 4089
bytes that follow the 7-byte per-page header). The 7-byte header itself
(page type, next-page, legacy payload-length) is written by the caller
when the page is flushed to disk — this module doesn’t touch it.
Layout inside the payload area (PAYLOAD_PER_PAGE = 4089 bytes):
offset 0..2 slot_count u16 LE
offset 2..4 cells_top u16 LE (offset where cell
content begins)
offset 4.. slot[0]..slot[n-1] each u16 LE
points at the start of a
cell, ordered by rowid
[free space]
offset cells_top..PAYLOAD_PER_PAGE cell content (unordered
in physical position,
ordered by slot)cells_top = PAYLOAD_PER_PAGE on an empty page. Every insert shifts it
down (toward the slot directory) by the new cell’s byte size; every
insert also expands the slot directory up (away from the header) by
2 bytes.
Deletion leaves holes. Removing a cell only strips its slot; the cell
bytes stay in place. This keeps deletion O(n) in slots-to-shift, not
O(page_size) in bytes-to-compact. The hole is reclaimed by a future
vacuum pass (not yet implemented). free_space therefore underreports
available space in fragmented pages — caller should treat its answer as
“contiguous free bytes”, which is what a cell write actually needs.
Structs§
- Table
Page - A table-leaf page. Owns a heap-allocated 4089-byte payload buffer.
- Table
Page Iter
Enums§
- Find
- Result of searching for a rowid in the slot directory.