Skip to main content

SharedBPlusTree

Struct SharedBPlusTree 

Source
pub struct SharedBPlusTree<P, KC, IC>
where P: Pager + Clone, P::Page: Send + Sync + 'static, P::Id: Send + Sync + 'static, KC: KeyCodec, IC: IdCodec<Id = P::Id>,
{ /* private fields */ }
Expand description

A façade that provides a serialized writer and snapshot readers, while implementing the same BTree trait.

Implementations§

Source§

impl<P, KC, IC> SharedBPlusTree<P, KC, IC>
where P: Pager + Clone, P::Page: Send + Sync + 'static, P::Id: Send + Sync + 'static, KC: KeyCodec, IC: IdCodec<Id = P::Id>,

Source

pub fn create_empty( pager: P, opt_shared_node_cache: Option<Arc<RwLock<NodeCache<P>>>>, ) -> Result<Self, Error>

Create an empty tree + shared writer.

Source

pub fn open( pager: P, root: P::Id, opt_shared_node_cache: Option<Arc<RwLock<NodeCache<P>>>>, ) -> Self

Open a shared B+Tree backed by an existing root.

Source

pub fn snapshot(&self) -> BPlusTree<P, KC, IC>

Produce a snapshot tree at the current published root. This is a normal BPlusTree you can iterate with ScanOpts.

Source

pub fn start_stream_with_opts( &self, opts: ScanOpts<'static, KC>, ) -> Receiver<(KC::Key, Vec<u8>)>
where P: Send + 'static, P::Id: Send + 'static, KC: KeyCodec + 'static, KC::Key: Send + Sync + 'static, IC: IdCodec<Id = P::Id> + 'static,

Start a streaming scan at the current root, using any ScanOpts. Returns a crossbeam MPMC receiver; read it from as many threads as you like. Keys/values are owned (no borrows across threads).

Trait Implementations§

Source§

impl<'a, P, KC, IC> BTree<'a, <KC as KeyCodec>::Key> for SharedBPlusTree<P, KC, IC>
where P: Pager + Clone + 'a, P::Page: Send + Sync + 'static, P::Id: Send + Sync + 'static, KC: KeyCodec + 'a, IC: IdCodec<Id = P::Id> + 'a,

Source§

type Value = <BPlusTree<P, KC, IC> as BTree<'a, <KC as KeyCodec>::Key>>::Value

Tree returns zero-copy views; must deref to &[u8].
Source§

fn get_many( &'a self, keys: &[KC::Key], ) -> Result<Vec<Option<Self::Value>>, Error>

Batched point lookups. The output vector lines up with keys by index.
Source§

fn contains_key(&'a self, key: &KC::Key) -> Result<bool, Error>

Source§

fn insert_many(&self, items: &[(KC::Key, &[u8])]) -> Result<(), Error>
where KC::Key: Clone,

Source§

fn delete_many(&self, keys: &[KC::Key]) -> Result<(), Error>
where KC::Key: Clone,

Auto Trait Implementations§

§

impl<P, KC, IC> !Freeze for SharedBPlusTree<P, KC, IC>

§

impl<P, KC, IC> RefUnwindSafe for SharedBPlusTree<P, KC, IC>
where P: RefUnwindSafe,

§

impl<P, KC, IC> Send for SharedBPlusTree<P, KC, IC>
where P: Send, KC: Send, IC: Send,

§

impl<P, KC, IC> Sync for SharedBPlusTree<P, KC, IC>
where P: Sync + Send, KC: Send, IC: Send,

§

impl<P, KC, IC> Unpin for SharedBPlusTree<P, KC, IC>
where P: Unpin, <P as Pager>::Id: Unpin, KC: Unpin, IC: Unpin,

§

impl<P, KC, IC> UnsafeUnpin for SharedBPlusTree<P, KC, IC>
where P: UnsafeUnpin, <P as Pager>::Id: UnsafeUnpin,

§

impl<P, KC, IC> UnwindSafe for SharedBPlusTree<P, KC, IC>
where P: 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.