pub struct BTreeTable {
pub key_field: usize,
pub tuple_scheme: TupleScheme,
/* private fields */
}
Fields§
§key_field: usize
§tuple_scheme: TupleScheme
Implementations§
Source§impl BTreeTable
impl BTreeTable
pub fn new(file_path: &str, key_field: usize, row_scheme: &TupleScheme) -> Self
pub fn get_id(&self) -> i32
Sourcepub fn insert_tuple(&self, tuple: &Tuple)
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.
Sourcepub fn split_leaf_page(
&self,
page_rc: Rc<RefCell<BTreeLeafPage>>,
field: IntField,
) -> Rc<RefCell<BTreeLeafPage>>
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.
pub fn get_empty_page_index(&self) -> usize
pub fn set_root_pid(&self, root_pid: &BTreePageID)
Sourcepub fn find_leaf_page(
&self,
page_id: BTreePageID,
field: Option<IntField>,
) -> Rc<RefCell<BTreeLeafPage>>
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
pub fn get_file(&self) -> RefMut<'_, File>
pub fn write_page_to_disk(&self, page_id: &BTreePageID)
Sourcepub fn get_root_pid(&self) -> BTreePageID
pub fn get_root_pid(&self) -> BTreePageID
Get the root page pid.
Sourcepub fn pages_count(&self) -> usize
pub fn pages_count(&self) -> usize
The count of pages in this BTreeFile
(BTreeRootPointerPage is not included)