pub struct BTree<K> { /* private fields */ }Expand description
On-disk B-tree index.
K is the key type; it must be serializable, deserializable, ordered,
and cheap to clone. These bounds appear once on the impl block so we
don’t have to repeat them on every method.
Implementations§
Source§impl<K> BTree<K>
impl<K> BTree<K>
pub fn create(path: &Path) -> IsamResult<Self>
pub fn open(path: &Path) -> IsamResult<Self>
Sourcepub fn search(&mut self, key: &K) -> IsamResult<Option<RecordRef>>
pub fn search(&mut self, key: &K) -> IsamResult<Option<RecordRef>>
Look up key and return its RecordRef if found.
Sourcepub fn insert(&mut self, key: &K, rec: RecordRef) -> IsamResult<()>
pub fn insert(&mut self, key: &K, rec: RecordRef) -> IsamResult<()>
Insert key → rec into the tree. Returns DuplicateKey if the
key already exists.
Sourcepub fn delete(&mut self, key: &K) -> IsamResult<()>
pub fn delete(&mut self, key: &K) -> IsamResult<()>
Delete key from the tree. Returns KeyNotFound if absent.
Sourcepub fn update(&mut self, key: &K, rec: RecordRef) -> IsamResult<()>
pub fn update(&mut self, key: &K, rec: RecordRef) -> IsamResult<()>
Update the RecordRef stored for key.
Sourcepub fn find_leaf_for_key(&mut self, key: &K) -> IsamResult<u32>
pub fn find_leaf_for_key(&mut self, key: &K) -> IsamResult<u32>
Return the leaf page id where key would be found (or inserted).
Unlike search, this never returns None — it always finds the
appropriate leaf even if the key is not present. Used by range scans
to position the iterator at the correct starting leaf.
Sourcepub fn first_leaf_id(&mut self) -> IsamResult<u32>
pub fn first_leaf_id(&mut self) -> IsamResult<u32>
Return the id of the first (leftmost) leaf page for sequential scan.
Sourcepub fn min_key(&mut self) -> IsamResult<Option<K>>
pub fn min_key(&mut self) -> IsamResult<Option<K>>
Return the smallest key in the tree, or None if the tree is empty.
Sourcepub fn max_key(&mut self) -> IsamResult<Option<K>>
pub fn max_key(&mut self) -> IsamResult<Option<K>>
Return the largest key in the tree, or None if the tree is empty.
Sourcepub fn read_leaf(&mut self, id: u32) -> IsamResult<(Vec<(K, RecordRef)>, u32)>
pub fn read_leaf(&mut self, id: u32) -> IsamResult<(Vec<(K, RecordRef)>, u32)>
Read leaf page id and return its entries and next_leaf_id.