Skip to main content

PageMut

Struct PageMut 

Source
pub struct PageMut<'a> { /* private fields */ }

Implementations§

Source§

impl<'a> PageMut<'a>

Source

pub fn init(b: &'a mut [u8], kind: PageKind, tree_id: u16, page_no: u32) -> Self

Source

pub fn reopen(b: &'a mut [u8]) -> Self

Reopen an already-initialised buffer for modification.

Source

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.

Source

pub fn free_space(&self) -> usize

Source

pub fn set_next_leaf(&mut self, p: u32)

Source

pub fn set_child0(&mut self, p: u32)

Same field, named for its meaning on an interior page.

Source

pub fn insert_slot(&mut self, at: usize, rec: &[u8]) -> Result<()>

Insert rec so that it becomes entry at, shifting later slots right.

Source

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.

Source

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).

Source

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.

Auto Trait Implementations§

§

impl<'a> !UnwindSafe for PageMut<'a>

§

impl<'a> Freeze for PageMut<'a>

§

impl<'a> RefUnwindSafe for PageMut<'a>

§

impl<'a> Send for PageMut<'a>

§

impl<'a> Sync for PageMut<'a>

§

impl<'a> Unpin for PageMut<'a>

§

impl<'a> UnsafeUnpin for PageMut<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.