pub struct BTree {
pub root: PageId,
pub depth: u16,
pub entry_count: u64,
/* private fields */
}Expand description
B+ tree metadata. Pages stored externally.
Fields§
§root: PageId§depth: u16§entry_count: u64Implementations§
Source§impl BTree
impl BTree
Sourcepub fn new(
pages: &mut FxHashMap<PageId, Page>,
alloc: &mut PageAllocator,
txn_id: TxnId,
) -> Self
pub fn new( pages: &mut FxHashMap<PageId, Page>, alloc: &mut PageAllocator, txn_id: TxnId, ) -> Self
Create a new empty B+ tree with a single leaf root.
Sourcepub fn from_existing(root: PageId, depth: u16, entry_count: u64) -> Self
pub fn from_existing(root: PageId, depth: u16, entry_count: u64) -> Self
Create a BTree from existing metadata (e.g., loaded from commit slot).
pub fn search_at_leaf( pages: &FxHashMap<PageId, Page>, leaf_id: PageId, key: &[u8], ) -> Result<Option<(ValueType, Vec<u8>)>>
pub fn search( &self, pages: &FxHashMap<PageId, Page>, key: &[u8], ) -> Result<Option<(ValueType, Vec<u8>)>>
pub fn lil_would_hit(&self, pages: &FxHashMap<PageId, Page>, key: &[u8]) -> bool
Sourcepub fn try_lil_insert(
&mut self,
pages: &mut FxHashMap<PageId, Page>,
alloc: &mut PageAllocator,
txn_id: TxnId,
key: &[u8],
val_type: ValueType,
value: &[u8],
) -> Result<Option<bool>>
pub fn try_lil_insert( &mut self, pages: &mut FxHashMap<PageId, Page>, alloc: &mut PageAllocator, txn_id: TxnId, key: &[u8], val_type: ValueType, value: &[u8], ) -> Result<Option<bool>>
Combined LIL check + insert. Returns Some(was_new) on hit, None on miss.
Sourcepub fn insert(
&mut self,
pages: &mut FxHashMap<PageId, Page>,
alloc: &mut PageAllocator,
txn_id: TxnId,
key: &[u8],
val_type: ValueType,
value: &[u8],
) -> Result<bool>
pub fn insert( &mut self, pages: &mut FxHashMap<PageId, Page>, alloc: &mut PageAllocator, txn_id: TxnId, key: &[u8], val_type: ValueType, value: &[u8], ) -> Result<bool>
Insert key-value. Returns true if new, false if updated existing.
pub fn insert_at_leaf( &mut self, pages: &mut FxHashMap<PageId, Page>, alloc: &mut PageAllocator, txn_id: TxnId, key: &[u8], val_type: ValueType, value: &[u8], path: Vec<(PageId, usize)>, leaf_id: PageId, ) -> Result<bool>
pub fn insert_or_fetch( &mut self, pages: &mut FxHashMap<PageId, Page>, alloc: &mut PageAllocator, txn_id: TxnId, key: &[u8], val_type: ValueType, value: &[u8], ) -> Result<Option<Vec<u8>>>
pub fn insert_if_absent( &mut self, pages: &mut FxHashMap<PageId, Page>, alloc: &mut PageAllocator, txn_id: TxnId, key: &[u8], val_type: ValueType, value: &[u8], ) -> Result<bool>
pub fn insert_if_absent_at_leaf( &mut self, pages: &mut FxHashMap<PageId, Page>, alloc: &mut PageAllocator, txn_id: TxnId, key: &[u8], val_type: ValueType, value: &[u8], path: Vec<(PageId, usize)>, leaf_id: PageId, ) -> Result<bool>
pub fn upsert_with<F, E>( &mut self, pages: &mut FxHashMap<PageId, Page>, alloc: &mut PageAllocator, txn_id: TxnId, key: &[u8], val_type: ValueType, default_value: &[u8], f: F, ) -> Result<UpsertOutcome, E>
pub fn upsert_with_at_leaf<F, E>( &mut self, pages: &mut FxHashMap<PageId, Page>, alloc: &mut PageAllocator, txn_id: TxnId, key: &[u8], val_type: ValueType, default_value: &[u8], path: Vec<(PageId, usize)>, leaf_id: PageId, f: F, ) -> Result<UpsertOutcome, E>
Sourcepub fn update_sorted(
&mut self,
pages: &mut FxHashMap<PageId, Page>,
alloc: &mut PageAllocator,
txn_id: TxnId,
pairs: &[(&[u8], &[u8])],
) -> Result<u64>
pub fn update_sorted( &mut self, pages: &mut FxHashMap<PageId, Page>, alloc: &mut PageAllocator, txn_id: TxnId, pairs: &[(&[u8], &[u8])], ) -> Result<u64>
Bulk-update existing keys. Keys must be sorted.
Sourcepub fn delete(
&mut self,
pages: &mut FxHashMap<PageId, Page>,
alloc: &mut PageAllocator,
txn_id: TxnId,
key: &[u8],
) -> Result<bool>
pub fn delete( &mut self, pages: &mut FxHashMap<PageId, Page>, alloc: &mut PageAllocator, txn_id: TxnId, key: &[u8], ) -> Result<bool>
Delete a key. Returns true if the key was found and deleted.
pub fn delete_at_leaf( &mut self, pages: &mut FxHashMap<PageId, Page>, alloc: &mut PageAllocator, txn_id: TxnId, key: &[u8], path: &mut Vec<(PageId, usize)>, leaf_id: PageId, ) -> Result<bool>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BTree
impl RefUnwindSafe for BTree
impl Send for BTree
impl Sync for BTree
impl Unpin for BTree
impl UnsafeUnpin for BTree
impl UnwindSafe for BTree
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more