Skip to main content

LsmTreeMap

Struct LsmTreeMap 

Source
pub struct LsmTreeMap<S, K, V>
where S: AnyBlockStorage, K: Hash + Ord + Clone + Serialize + DeserializeOwned + Send + Sync + 'static, V: Clone + Serialize + DeserializeOwned + Send + Sync + 'static,
{ /* private fields */ }
Expand description

LSM Tree Instance.

Implementations§

Source§

impl<S, K, V> LsmTreeMap<S, K, V>
where S: AnyBlockStorage, K: Hash + Ord + Clone + Serialize + DeserializeOwned + Send + Sync + 'static, V: Clone + Serialize + DeserializeOwned + Send + Sync + 'static,

Source

pub fn new(storage: S, settings: LsmTreeMapSettings) -> Self

Create new empty tree.

Source

pub async fn load( storage: S, root: Link<Root<K, V>>, ) -> Result<Self, StorageError>

Load Tree from root CID.

Source

pub async fn insert(&mut self, key: K, value: V) -> Result<(), StorageError>

Insert/Replace key.

Source

pub async fn remove(&mut self, key: K) -> Result<(), StorageError>

Remove key.

Source

pub async fn get(&self, key: &K) -> Result<Option<V>, StorageError>

Get value for key.

Source

pub async fn contains_key(&self, key: &K) -> Result<bool, StorageError>

Source

pub fn stream( &self, ) -> impl Stream<Item = Result<(K, V), StorageError>> + use<S, K, V>

Stream all tree entries.

Source

pub fn stream_query( &self, start_at: Option<K>, ) -> impl Stream<Item = Result<(K, V), StorageError>> + use<S, K, V>

Stream tree entries.

Source

pub fn reverse_stream( &self, ) -> impl Stream<Item = Result<(K, V), StorageError>> + use<S, K, V>

Stream all tree entries in reverse order.

Source

pub fn reverse_stream_query( &self, start_at: Option<K>, ) -> impl Stream<Item = Result<(K, V), StorageError>> + use<S, K, V>

Stream tree entries in reverse order.

Source

pub async fn store(&mut self) -> Result<OptionLink<Root<K, V>>, StorageError>

Store active items and return the root link.

§Guarantees
  • The method detects if the collection is empty after this and accordingly returns OptionLink::none.
Source

pub async fn stats(&self) -> Result<LsmTreeStats, StorageError>

Tree stats.

Source

pub async fn is_empty(&self) -> Result<bool, StorageError>

Whether the collection is empty.

Source

pub async fn min_key(&self) -> Result<Option<K>, StorageError>

Find the first (active - not tombstoned) key.

Source

pub async fn max_key(&self) -> Result<Option<K>, StorageError>

Find the last (active - not tombstoned) key.

Source

pub async fn compact(&mut self, flush_active: bool) -> Result<(), StorageError>

Compact tree.

§Arguments
  • flush_active - Flush active “in memory” entries to L0.

Trait Implementations§

Source§

impl<S, K, V> Clone for LsmTreeMap<S, K, V>
where S: AnyBlockStorage + Clone, K: Hash + Ord + Clone + Serialize + DeserializeOwned + Send + Sync + 'static + Clone, V: Clone + Serialize + DeserializeOwned + Send + Sync + 'static + Clone,

Source§

fn clone(&self) -> LsmTreeMap<S, K, V>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<S, K, V> Freeze for LsmTreeMap<S, K, V>
where S: Freeze,

§

impl<S, K, V> RefUnwindSafe for LsmTreeMap<S, K, V>

§

impl<S, K, V> Send for LsmTreeMap<S, K, V>

§

impl<S, K, V> Sync for LsmTreeMap<S, K, V>

§

impl<S, K, V> Unpin for LsmTreeMap<S, K, V>
where S: Unpin, K: Unpin, V: Unpin,

§

impl<S, K, V> UnsafeUnpin for LsmTreeMap<S, K, V>
where S: UnsafeUnpin,

§

impl<S, K, V> UnwindSafe for LsmTreeMap<S, K, V>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.