Trait sanakirja_core::btree::BTreeMutPage
source · pub trait BTreeMutPage<K: ?Sized, V: ?Sized>: BTreePage<K, V> + Debug {
type Saved;
// Required methods
fn init(page: &mut MutPage);
unsafe fn put<'a, T: AllocPage>(
txn: &mut T,
page: CowPage,
mutable: bool,
replace: bool,
c: &Self::Cursor,
k0: &'a K,
v0: &'a V,
k1v1: Option<(&'a K, &'a V)>,
l: u64,
r: u64
) -> Result<Put<'a, K, V>, T::Error>;
unsafe fn put_mut<T: AllocPage>(
txn: &mut T,
page: &mut MutPage,
c: &mut Self::Cursor,
k0: &K,
v0: &V,
r: u64
);
unsafe fn set_left_child(page: &mut MutPage, c: &Self::Cursor, l: u64);
unsafe fn update_left_child<T: AllocPage>(
txn: &mut T,
page: CowPage,
mutable: bool,
c: &Self::Cursor,
r: u64
) -> Result<Ok, T::Error>;
fn save_deleted_leaf_entry(k: &K, v: &V) -> Self::Saved;
unsafe fn from_saved<'a>(s: &Self::Saved) -> (&'a K, &'a V);
unsafe fn del<T: AllocPage>(
txn: &mut T,
page: CowPage,
mutable: bool,
c: &Self::Cursor,
l: u64
) -> Result<(MutPage, u64), T::Error>;
unsafe fn merge_or_rebalance<'a, 'b, T: AllocPage>(
txn: &mut T,
m: Concat<'a, K, V, Self>
) -> Result<Op<'a, T, K, V>, T::Error>;
}
Required Associated Types§
Required Methods§
sourceunsafe fn put<'a, T: AllocPage>(
txn: &mut T,
page: CowPage,
mutable: bool,
replace: bool,
c: &Self::Cursor,
k0: &'a K,
v0: &'a V,
k1v1: Option<(&'a K, &'a V)>,
l: u64,
r: u64
) -> Result<Put<'a, K, V>, T::Error>
unsafe fn put<'a, T: AllocPage>( txn: &mut T, page: CowPage, mutable: bool, replace: bool, c: &Self::Cursor, k0: &'a K, v0: &'a V, k1v1: Option<(&'a K, &'a V)>, l: u64, r: u64 ) -> Result<Put<'a, K, V>, T::Error>
Add an entry to the page, possibly splitting the page in the process.
Makes the assumption that k1v1.is_some()
implies
replace
. When k1v1.is_some()
, we insert both (k0, v0)
(as a replacement), followed by (k1, v1)
. This is only ever
used when deleting, and when the right child of a deleted
entry (in an internal node) has split while we were looking
for a replacement for the deleted entry.
Since we only look for replacements in the right child, the
left child of the insertion isn’t modified, in which case l
and r
are interpreted as the left and right child of the new
entry, k1v1
.
sourceunsafe fn put_mut<T: AllocPage>(
txn: &mut T,
page: &mut MutPage,
c: &mut Self::Cursor,
k0: &K,
v0: &V,
r: u64
)
unsafe fn put_mut<T: AllocPage>( txn: &mut T, page: &mut MutPage, c: &mut Self::Cursor, k0: &K, v0: &V, r: u64 )
Add an entry to page
, at position c
. Does not check
whether there is enough space to do so. This method is mostly
useful for cloning pages.
unsafe fn set_left_child(page: &mut MutPage, c: &Self::Cursor, l: u64)
sourceunsafe fn update_left_child<T: AllocPage>(
txn: &mut T,
page: CowPage,
mutable: bool,
c: &Self::Cursor,
r: u64
) -> Result<Ok, T::Error>
unsafe fn update_left_child<T: AllocPage>( txn: &mut T, page: CowPage, mutable: bool, c: &Self::Cursor, r: u64 ) -> Result<Ok, T::Error>
Update the left child of the position pointed to by the cursor.
sourcefn save_deleted_leaf_entry(k: &K, v: &V) -> Self::Saved
fn save_deleted_leaf_entry(k: &K, v: &V) -> Self::Saved
Save a leaf entry as a replacement, when we delete at an internal node. This can be a pointer to the leaf if the leaf isn’t mutated, or the actual value, or something else.
sourceunsafe fn from_saved<'a>(s: &Self::Saved) -> (&'a K, &'a V)
unsafe fn from_saved<'a>(s: &Self::Saved) -> (&'a K, &'a V)
Recover the saved value.