pub struct Page {
pub data: MData,
pub pnum: u64,
pub count: usize,
pub level: u8,
pub is_dirty: bool,
pub node_size: usize,
pub root: usize,
pub first_page: u64,
/* private fields */
}
Expand description
A page in a SortedFile. Note that left subtree has nodes that compare greater.
Fields§
§data: MData
Data storage.
pnum: u64
Page number in file where page is saved.
count: usize
Number of records currently stored in the page.
level: u8
Page level. 0 means a child page, more than 0 a parent page.
is_dirty: bool
Has the page been modified?
node_size: usize
Number of bytes required for each node.
root: usize
Root node for the page.
first_page: u64
First child page ( for a parent page ).
Implementations§
source§impl Page
impl Page
sourcepub fn write_header(&mut self)
pub fn write_header(&mut self)
Sets header and trailer (if parent) data. Called just before page is saved to file.
sourcepub fn new_page(&self, capacity: usize) -> Page
pub fn new_page(&self, capacity: usize) -> Page
Construct a new empty page inheriting record size and level from self. Used when splitting a page that is full.
sourcepub fn find_child(&self, db: &DB, r: &dyn Record) -> u64
pub fn find_child(&self, db: &DB, r: &dyn Record) -> u64
Find child page number.
sourcepub fn find_equal(&self, db: &DB, r: &dyn Record) -> usize
pub fn find_equal(&self, db: &DB, r: &dyn Record) -> usize
Returns node id of Record equal to r, or zero if no such node exists.
sourcepub fn insert(&mut self, db: &DB, r: &dyn Record)
pub fn insert(&mut self, db: &DB, r: &dyn Record)
Insert a record into the page ( panics if the key is a duplicate ).
sourcepub fn insert_page(&mut self, db: &DB, r: &dyn Record, cp: u64)
pub fn insert_page(&mut self, db: &DB, r: &dyn Record, cp: u64)
Insert a child page with specified key and number.
sourcepub fn append_page(&mut self, r: &dyn Record, cp: u64)
pub fn append_page(&mut self, r: &dyn Record, cp: u64)
Append a child page with specified key and number.
sourcepub fn append_from(&mut self, from: &Page, x: usize)
pub fn append_from(&mut self, from: &Page, x: usize)
Append record x from specified page to this page.
sourcepub fn append_page_copy(&mut self, b: &[u8], cp: u64)
pub fn append_page_copy(&mut self, b: &[u8], cp: u64)
Append a copied parent key.
sourcepub fn rec_offset(&self, x: usize) -> usize
pub fn rec_offset(&self, x: usize) -> usize
Offset of the client data for node x.
sourcepub fn left(&self, x: usize) -> usize
pub fn left(&self, x: usize) -> usize
Get the left child node for node x. Result is zero if there is no child.
sourcepub fn right(&self, x: usize) -> usize
pub fn right(&self, x: usize) -> usize
Get the right child node for node x. Result is zero if there is no child.
sourcepub fn child_page(&self, x: usize) -> u64
pub fn child_page(&self, x: usize) -> u64
Get the child page number for node x in a parent page.
sourcepub fn set_child_page(&mut self, x: usize, pnum: u64)
pub fn set_child_page(&mut self, x: usize, pnum: u64)
Set the child page for node x.
sourcepub fn compare(&self, db: &DB, r: &dyn Record, x: usize) -> Ordering
pub fn compare(&self, db: &DB, r: &dyn Record, x: usize) -> Ordering
Compare record data for node x with record r.