Struct BTreeTable

Source
pub struct BTreeTable {
    pub key_field: usize,
    pub tuple_scheme: TupleScheme,
    /* private fields */
}

Fields§

§key_field: usize§tuple_scheme: TupleScheme

Implementations§

Source§

impl BTreeTable

Source

pub fn new(file_path: &str, key_field: usize, row_scheme: &TupleScheme) -> Self

Source

pub fn get_id(&self) -> i32

Source

pub fn insert_tuple(&self, tuple: &Tuple)

Insert a tuple into this BTreeFile, keeping the tuples in sorted order. May cause pages to split if the page where tuple belongs is full.

Source

pub fn split_leaf_page( &self, page_rc: Rc<RefCell<BTreeLeafPage>>, field: IntField, ) -> Rc<RefCell<BTreeLeafPage>>

Split a leaf page to make room for new tuples and recursively split the parent node as needed to accommodate a new entry. The new entry should have a key matching the key field of the first tuple in the right-hand page (the key is “copied up”), and child pointers pointing to the two leaf pages resulting from the split. Update sibling pointers and parent pointers as needed.

Return the leaf page into which a new tuple with key field “field” should be inserted.

§Arguments
  • field: the key field of the tuple to be inserted after the split is complete. Necessary to know which of the two pages to return.
Source

pub fn get_empty_page_index(&self) -> usize

Source

pub fn set_root_pid(&self, root_pid: &BTreePageID)

Source

pub fn find_leaf_page( &self, page_id: BTreePageID, field: Option<IntField>, ) -> Rc<RefCell<BTreeLeafPage>>

Recursive function which finds and locks the leaf page in the B+ tree corresponding to the left-most page possibly containing the key field f. It locks all internal nodes along the path to the leaf node with READ_ONLY permission, and locks the leaf node with permission perm.

If f is null, it finds the left-most leaf page – used for the iterator

§Arguments
  • tid - the transaction id
  • pid - the current page being searched
  • perm - the permissions with which to lock the leaf page
  • f - the field to search for
§Return
  • the left-most leaf page possibly containing the key field f
Source

pub fn get_file(&self) -> RefMut<'_, File>

Source

pub fn write_page_to_disk(&self, page_id: &BTreePageID)

Source

pub fn get_root_pid(&self) -> BTreePageID

Get the root page pid.

Source

pub fn pages_count(&self) -> usize

The count of pages in this BTreeFile

(BTreeRootPointerPage is not included)

Source

pub fn get_first_tuple(&self, pid: &BTreePageID) -> Option<Tuple>

Source

pub fn set_page_index(&self, i: usize)

Source

pub fn get_last_tuple(&self, pid: &BTreePageID) -> Option<Tuple>

Source

pub fn draw_tree(&self, max_level: i32)

used for debug

§Arguments
  • max_level - the max level of the print, -1 for print all

Trait Implementations§

Source§

impl Display for BTreeTable

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

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

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.