Struct rustdb::page::Page

source ·
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

source

pub fn size(&self) -> usize

The size of the page in bytes.

source

pub fn new(rec_size: usize, level: u8, data: Data, pnum: u64) -> Page

Construct a new page.

source

pub fn write_header(&mut self)

Sets header and trailer (if parent) data. Called just before page is saved to file.

source

pub fn full(&self, page_limit: usize) -> bool

Is the page full?

source

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.

source

pub fn find_child(&self, db: &DB, r: &dyn Record) -> u64

Find child page number.

source

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.

source

pub fn remove(&mut self, db: &DB, r: &dyn Record)

Remove record from this page.

source

pub fn insert(&mut self, db: &DB, r: &dyn Record)

Insert a record into the page ( panics if the key is a duplicate ).

source

pub fn insert_page(&mut self, db: &DB, r: &dyn Record, cp: u64)

Insert a child page with specified key and number.

source

pub fn append_page(&mut self, r: &dyn Record, cp: u64)

Append a child page with specified key and number.

source

pub fn append_from(&mut self, from: &Page, x: usize)

Append record x from specified page to this page.

source

pub fn append_page_copy(&mut self, b: &[u8], cp: u64)

Append a copied parent key.

source

pub fn copy(&self, x: usize) -> Vec<u8>

Make a copy of a parent key record.

source

pub fn rec_offset(&self, x: usize) -> usize

Offset of the client data for node x.

source

pub fn rec_size(&self) -> usize

The client data size.

source

pub fn left(&self, x: usize) -> usize

Get the left child node for node x. Result is zero if there is no child.

source

pub fn right(&self, x: usize) -> usize

Get the right child node for node x. Result is zero if there is no child.

source

pub fn child_page(&self, x: usize) -> u64

Get the child page number for node x in a parent page.

source

pub fn set_child_page(&mut self, x: usize, pnum: u64)

Set the child page for node x.

source

pub fn compare(&self, db: &DB, r: &dyn Record, x: usize) -> Ordering

Compare record data for node x with record r.

source

pub fn get_key(&self, db: &DB, x: usize, r: &dyn Record) -> Box<dyn Record>

Get record key for node x.

source

pub fn clear(&mut self)

Clear the page ( no nodes ).

source

pub fn drop_key(&self, db: &DB, x: usize, r: &dyn Record)

Drop the key for the specified node.

source

pub fn compress(&mut self, db: &DB)

Reduce page size using free nodes.

Auto Trait Implementations§

§

impl Freeze for Page

§

impl RefUnwindSafe for Page

§

impl Send for Page

§

impl Sync for Page

§

impl Unpin for Page

§

impl UnwindSafe for Page

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>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.