pub struct PageMut<'a> { /* private fields */ }Implementations§
Source§impl<'a> PageMut<'a>
impl<'a> PageMut<'a>
pub fn init(b: &'a mut [u8], kind: PageKind, tree_id: u16, page_no: u32) -> Self
Sourcepub fn nentries_pub(&self) -> usize
pub fn nentries_pub(&self) -> usize
Number of entries currently in a page under construction. Public
because btree.rs’s splits, and pack_tree in a later task, need to
know where the next insert_slot call will land while building a
fresh page from a collected Vec of records.
pub fn free_space(&self) -> usize
pub fn set_next_leaf(&mut self, p: u32)
Sourcepub fn set_child0(&mut self, p: u32)
pub fn set_child0(&mut self, p: u32)
Same field, named for its meaning on an interior page.
Sourcepub fn insert_slot(&mut self, at: usize, rec: &[u8]) -> Result<()>
pub fn insert_slot(&mut self, at: usize, rec: &[u8]) -> Result<()>
Insert rec so that it becomes entry at, shifting later slots right.
Sourcepub fn remove_slot(&mut self, at: usize)
pub fn remove_slot(&mut self, at: usize)
Remove entry at. The payload bytes are abandoned in place; they are
reclaimed only when the page is compacted.
SACRIFICE (Law 4): a page can hold dead payload bytes it cannot reuse until compaction. Bought: deletion touches only the slot directory.
Sourcepub fn compact(&mut self)
pub fn compact(&mut self)
Rewrite every live payload packed against the end of the page, in slot
order, and reset free_ptr to reclaim whatever remove_slot left
abandoned. This is the reclamation remove_slot’s doc comment
promises; without it that comment was a cheque the code could not
cash, and a caller that relied on it (a replace on an already-tight
leaf) would corrupt the page instead.
Bounded by one page: the snapshot below is at most PAGE_SIZE bytes,
so this is RAM proportional to the page, not the store (Law 1).
Sourcepub fn finalise(&mut self, lsn: u64)
pub fn finalise(&mut self, lsn: u64)
Close out a mutation: stamp the LSN. The checksum is stamped by
seal immediately before a page is WRITTEN – a page mutated fifty
times before eviction needs one checksum, not fifty (measured: 12.34
full-page CRCs per row, 10 of them re-verifying resident pages, 34% of
the write path). A dirty resident page’s checksum field is meaningless;
nothing reads it, and the only path to disk seals first.