BTree

Struct BTree 

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

Source

pub fn create(path: &Path) -> IsamResult<Self>

Source

pub fn open(path: &Path) -> IsamResult<Self>

Source

pub fn search(&mut self, key: &K) -> IsamResult<Option<RecordRef>>

Look up key and return its RecordRef if found.

Source

pub fn insert(&mut self, key: &K, rec: RecordRef) -> IsamResult<()>

Insert key → rec into the tree. Returns DuplicateKey if the key already exists.

Source

pub fn delete(&mut self, key: &K) -> IsamResult<()>

Delete key from the tree. Returns KeyNotFound if absent.

Source

pub fn update(&mut self, key: &K, rec: RecordRef) -> IsamResult<()>

Update the RecordRef stored for key.

Source

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.

Source

pub fn first_leaf_id(&mut self) -> IsamResult<u32>

Return the id of the first (leftmost) leaf page for sequential scan.

Source

pub fn min_key(&mut self) -> IsamResult<Option<K>>

Return the smallest key in the tree, or None if the tree is empty.

Source

pub fn max_key(&mut self) -> IsamResult<Option<K>>

Return the largest key in the tree, or None if the tree is empty.

Source

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.

Source

pub fn key_schema_version(&self) -> u32

Source

pub fn val_schema_version(&self) -> u32

Source

pub fn set_schema_versions(&mut self, key_v: u32, val_v: u32) -> IsamResult<()>

Source

pub fn flush(&mut self) -> IsamResult<()>

Source

pub fn fsync(&mut self) -> IsamResult<()>

Auto Trait Implementations§

§

impl<K> Freeze for BTree<K>

§

impl<K> RefUnwindSafe for BTree<K>
where K: RefUnwindSafe,

§

impl<K> Send for BTree<K>
where K: Send,

§

impl<K> Sync for BTree<K>
where K: Sync,

§

impl<K> Unpin for BTree<K>
where K: Unpin,

§

impl<K> UnwindSafe for BTree<K>
where K: UnwindSafe,

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