[][src]Struct banyan::tree::Tree

pub struct Tree<T: TreeTypes, V> { /* fields omitted */ }

A tree. This is mostly an user friendly handle.

Most of the logic except for handling the empty case is implemented in the forest

Implementations

impl<V: Serialize + DeserializeOwned + Clone + Send + Sync + Debug + 'static, T: TreeTypes + 'static> Tree<T, V>[src]

pub fn level(&self) -> i32[src]

pub async fn from_roots(
    forest: Arc<Forest<T, V>>,
    __arg1: Vec<Index<T>>
) -> Result<Self>
[src]

pub fn empty(forest: Arc<Forest<T, V>>) -> Self[src]

pub async fn dump<'_>(&'_ self) -> Result<()>[src]

dumps the tree structure

pub async fn roots<'_>(&'_ self) -> Result<Vec<Index<T>>>[src]

sealed roots of the tree

pub async fn check_invariants<'_>(&'_ self) -> Result<Vec<String>>[src]

pub async fn is_packed<'_>(&'_ self) -> Result<bool>[src]

pub async fn assert_invariants<'_>(&'_ self) -> Result<()>[src]

pub async fn collect<B: FromIterator<(T::Key, V)>, '_>(&'_ self) -> Result<B>[src]

Collects all elements from a stream. Might produce an OOM for large streams.

pub async fn collect_from<B: FromIterator<(T::Key, V)>, '_>(
    &'_ self,
    offset: u64
) -> Result<B>
[src]

Collects all elements from the given offset. Might produce an OOM for large streams.

pub async fn pack<'_>(&'_ mut self) -> Result<()>[src]

Packs the tree to the left.

For an already packed tree, this is a noop. Otherwise, all packed subtrees will be reused without touching them. Likewise, sealed subtrees or leafs will be reused if possible.

packing illustration

pub async fn push<'_>(&'_ mut self, key: T::Key, value: V) -> Result<()>[src]

append a single element. This is just a shortcut for extend.

pub async fn extend<I, '_>(&'_ mut self, from: I) -> Result<()> where
    I: IntoIterator<Item = (T::Key, V)>,
    I::IntoIter: Send
[src]

extend the node with the given iterator of key/value pairs

extend illustration

pub async fn extend_unpacked<I, '_>(&'_ mut self, from: I) -> Result<()> where
    I: IntoIterator<Item = (T::Key, V)>,
    I::IntoIter: Send
[src]

extend the node with the given iterator of key/value pairs

This variant will not pack the tree, but just create a new tree from the new values and join it with the previous tree via an unpacked branch node. Essentially this will produce a degenerate tree that resembles a linked list.

To pack a tree, use the pack method.

extend_unpacked illustration

pub async fn get<'_>(&'_ self, offset: u64) -> Result<Option<(T::Key, V)>>[src]

element at index

pub fn stream<'a>(&'a self) -> impl Stream<Item = Result<(T::Key, V)>> + 'a[src]

stream the entire content of the tree

pub fn stream_filtered<'a, Q: Query<T> + Debug>(
    &'a self,
    query: &'a Q
) -> impl Stream<Item = Result<(u64, T::Key, V)>> + 'a
[src]

stream the tree, filtered by a query

pub fn stream_filtered_static(
    self,
    query: impl Query<T> + Clone + 'static
) -> impl Stream<Item = Result<(u64, T::Key, V)>> + 'static
[src]

pub fn stream_filtered_static_chunked<E: 'static>(
    self,
    query: impl Query<T> + Clone + 'static,
    mk_extra: &'static impl Fn(IndexRef<'_, T>) -> E
) -> impl Stream<Item = Result<FilteredChunk<T, V, E>>> + 'static
[src]

pub fn stream_filtered_static_chunked_reverse<E: 'static>(
    self,
    query: impl Query<T> + Clone + 'static,
    mk_extra: &'static impl Fn(IndexRef<'_, T>) -> E
) -> impl Stream<Item = Result<FilteredChunk<T, V, E>>> + 'static
[src]

pub async fn retain<'a, Q: Query<T> + Send + Sync>(
    &'a mut self,
    query: &'a Q
) -> Result<()>
[src]

Retain just data matching the query

this is done as best effort and will not be precise. E.g. if a chunk of data contains just a tiny bit that needs to be retained, the entire chunk will be retained.

from this follows that this is not a suitable method if you want to ensure that the non-matching data is completely gone.

note that offsets will not be affected by this. Also, unsealed nodes will not be forgotten even if they do not match the query.

pub async fn repair<'a, '_>(&'_ mut self) -> Result<Vec<String>>[src]

repair a tree by purging parts of the tree that can not be resolved.

produces a report of links that could not be resolved.

Note that this is an emergency measure to recover data if the tree is not completely available. It might result in a degenerate tree that can no longer be safely added to, especially if there are repaired blocks in the non-packed part.

pub fn is_empty(&self) -> bool[src]

true for an empty tree

pub fn count(&self) -> u64[src]

number of elements in the tree

pub fn root(&self) -> Option<&T::Link>[src]

root of a non-empty tree

Trait Implementations

impl<V, T: TreeTypes> Clone for Tree<T, V>[src]

impl<T: TreeTypes, V> Debug for Tree<T, V>[src]

impl<T: TreeTypes, V> Display for Tree<T, V>[src]

Auto Trait Implementations

impl<T, V> !RefUnwindSafe for Tree<T, V>

impl<T, V> Send for Tree<T, V> where
    V: Send + Sync,
    <T as TreeTypes>::Link: Send + Sync,
    <T as TreeTypes>::Seq: Send + Sync

impl<T, V> Sync for Tree<T, V> where
    V: Send + Sync,
    <T as TreeTypes>::Link: Send + Sync,
    <T as TreeTypes>::Seq: Send + Sync

impl<T, V> Unpin for Tree<T, V> where
    V: Unpin,
    <T as TreeTypes>::Link: Unpin,
    <T as TreeTypes>::Seq: Unpin

impl<T, V> !UnwindSafe for Tree<T, V>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,