Skip to main content

Module interior_page

Module interior_page 

Source
Expand description

Interior B-Tree page layout.

An interior page holds a slot directory of “divider” cells, each pointing at a child page, plus a separate rightmost-child pointer that serves as the catch-all for rowids larger than any divider. For N dividers, the page points at N+1 children.

  +---- page ---- (routes rowids to child pages by divider) ------+
  | divider[0] -> child[0]   (rowids <= divider[0])               |
  | divider[1] -> child[1]   (divider[0] < rowids <= divider[1])  |
  | ...                                                           |
  | divider[n-1] -> child[n-1]                                    |
  | rightmost_child          (rowids > divider[n-1])              |
  +---------------------------------------------------------------+

Interior cell format. Uses the shared [cell_length varint | kind_tag u8 | body] prefix with kind_tag = KIND_INTERIOR. Body:

  • divider_rowid zigzag varint
  • child_page u32 little-endian

Cell::peek_rowid works uniformly across all three kinds — interior cells happen to have their divider rowid at the same position as a local cell’s row rowid, so binary search over the slot directory just works.

Payload layout (inside the 4089-byte payload area):

  offset 0..2    slot_count         u16 LE
  offset 2..4    cells_top          u16 LE
  offset 4..8    rightmost_child    u32 LE
  offset 8..     slot[0]..slot[n-1] each u16 LE, divider-ordered
  [free space]
  offset cells_top..end              cell bodies

Parallel to TablePage except for the extra 4-byte rightmost_child slot between the cells_top pointer and the slot directory. Call sites that want a uniform “page with cells” abstraction should check the page type tag first and use the appropriate struct.

Structs§

InteriorCell
One divider in an interior page: “rowids up to divider_rowid live in the subtree under child_page”.
InteriorPage
An interior B-Tree page. Owns a heap-allocated 4089-byte payload buffer.