TransactionTree

Struct TransactionTree 

Source
pub struct TransactionTree<Root: Root, File: ManagedFile> { /* private fields */ }
Expand description

A tree that is modifiable during a transaction.

Implementations§

Source§

impl<File: ManagedFile, Index> TransactionTree<VersionedTreeRoot<Index>, File>
where Index: Clone + Reducer<Index> + EmbeddedIndex + Debug + 'static,

Source

pub fn current_sequence_id(&self) -> u64

Returns the latest sequence id.

Source§

impl<Root: Root, File: ManagedFile> TransactionTree<Root, File>

Source

pub fn set( &mut self, key: impl Into<ArcBytes<'static>>, value: impl Into<ArcBytes<'static>>, ) -> Result<(), Error>

Sets key to value.

Source

pub fn modify<'a>( &mut self, keys: Vec<ArcBytes<'a>>, operation: Operation<'a, ArcBytes<'static>>, ) -> Result<(), Error>

Executes a modification.

Source

pub fn replace( &mut self, key: impl Into<ArcBytes<'static>>, value: impl Into<ArcBytes<'static>>, ) -> Result<Option<ArcBytes<'static>>, Error>

Sets key to value. If a value already exists, it will be returned.

Source

pub fn get(&mut self, key: &[u8]) -> Result<Option<ArcBytes<'static>>, Error>

Returns the current value of key. This will return updated information if it has been previously updated within this transaction.

Source

pub fn remove(&mut self, key: &[u8]) -> Result<Option<ArcBytes<'static>>, Error>

Removes key and returns the existing value, if present.

Source

pub fn compare_and_swap( &mut self, key: &[u8], old: Option<&[u8]>, new: Option<ArcBytes<'_>>, ) -> Result<(), CompareAndSwapError>

Compares the value of key against old. If the values match, key will be set to the new value if new is Some or removed if new is None.

Source

pub fn get_multiple<'keys, KeysIntoIter, KeysIter>( &mut self, keys: KeysIntoIter, ) -> Result<Vec<(ArcBytes<'static>, ArcBytes<'static>)>, Error>
where KeysIntoIter: IntoIterator<Item = &'keys [u8], IntoIter = KeysIter>, KeysIter: Iterator<Item = &'keys [u8]> + ExactSizeIterator,

Retrieves the values of keys. If any keys are not found, they will be omitted from the results. Keys are required to be pre-sorted.

Source

pub fn get_range<'keys, KeyRangeBounds>( &mut self, range: &'keys KeyRangeBounds, ) -> Result<Vec<(ArcBytes<'static>, ArcBytes<'static>)>, Error>
where KeyRangeBounds: RangeBounds<&'keys [u8]> + Debug + ?Sized,

Retrieves all of the values of keys within range.

Source

pub fn scan<'b, 'keys, CallerError, KeyRangeBounds, NodeEvaluator, KeyEvaluator, DataCallback>( &mut self, range: &'keys KeyRangeBounds, forwards: bool, node_evaluator: NodeEvaluator, key_evaluator: KeyEvaluator, callback: DataCallback, ) -> Result<(), AbortError<CallerError>>
where KeyRangeBounds: RangeBounds<&'keys [u8]> + Debug + ?Sized, NodeEvaluator: FnMut(&ArcBytes<'static>, &Root::ReducedIndex, usize) -> ScanEvaluation, KeyEvaluator: FnMut(&ArcBytes<'static>, &Root::Index) -> ScanEvaluation, DataCallback: FnMut(ArcBytes<'static>, &Root::Index, ArcBytes<'static>) -> Result<(), AbortError<CallerError>>, CallerError: Display + Debug,

Scans the tree across all nodes that might contain nodes within range.

If forwards is true, the tree is scanned in ascending order. Otherwise, the tree is scanned in descending order.

node_evaluator is invoked for each Interior node to determine if the node should be traversed. The parameters to the callback are:

  • &ArcBytes<'static>: The maximum key stored within the all children nodes.
  • &Root::ReducedIndex: The reduced index value stored within the node.
  • usize: The depth of the node. The root nodes are depth 0.

The result of the callback is a ScanEvaluation. To read children nodes, return ScanEvaluation::ReadData.

key_evaluator is invoked for each key encountered that is contained within range. For all ScanEvaluation::ReadData results returned, callback will be invoked with the key and values. callback may not be invoked in the same order as the keys are scanned.

Source

pub fn reduce<'keys, KeyRangeBounds>( &mut self, range: &'keys KeyRangeBounds, ) -> Result<Root::ReducedIndex, Error>
where KeyRangeBounds: RangeBounds<&'keys [u8]> + Debug + Clone + ?Sized,

Returns the reduced index over the provided range. This is an aggregation function that builds atop the scan() operation which calls Reducer::reduce() and Reducer::rereduce() on all matching indexes stored within the nodes of this tree, producing a single aggregated Root::ReducedIndex value.

If no keys match, the returned result is what Reducer::rereduce() returns when an empty slice is provided.

Source

pub fn first_key(&mut self) -> Result<Option<ArcBytes<'static>>, Error>

Returns the first key of the tree.

Source

pub fn first( &mut self, ) -> Result<Option<(ArcBytes<'static>, ArcBytes<'static>)>, Error>

Returns the first key and value of the tree.

Source

pub fn last_key(&mut self) -> Result<Option<ArcBytes<'static>>, Error>

Returns the last key of the tree.

Source

pub fn last( &mut self, ) -> Result<Option<(ArcBytes<'static>, ArcBytes<'static>)>, Error>

Returns the last key and value of the tree.

Auto Trait Implementations§

§

impl<Root, File> Freeze for TransactionTree<Root, File>

§

impl<Root, File> !RefUnwindSafe for TransactionTree<Root, File>

§

impl<Root, File> Send for TransactionTree<Root, File>

§

impl<Root, File> Sync for TransactionTree<Root, File>

§

impl<Root, File> Unpin for TransactionTree<Root, File>

§

impl<Root, File> !UnwindSafe for TransactionTree<Root, File>

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.