LockedTransactionTree

Struct LockedTransactionTree 

Source
pub struct LockedTransactionTree<'transaction, Root: Root, File: ManagedFile>(/* private fields */);
Expand description

A locked transaction tree. This transactional tree is exclusively available for writing and reading to the thread that locks it.

Methods from Deref<Target = 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.

Trait Implementations§

Source§

impl<'transaction, Root: Root, File: ManagedFile> Deref for LockedTransactionTree<'transaction, Root, File>

Source§

type Target = TransactionTree<Root, File>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<'transaction, Root: Root, File: ManagedFile> DerefMut for LockedTransactionTree<'transaction, Root, File>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.

Auto Trait Implementations§

§

impl<'transaction, Root, File> Freeze for LockedTransactionTree<'transaction, Root, File>

§

impl<'transaction, Root, File> !RefUnwindSafe for LockedTransactionTree<'transaction, Root, File>

§

impl<'transaction, Root, File> !Send for LockedTransactionTree<'transaction, Root, File>

§

impl<'transaction, Root, File> Sync for LockedTransactionTree<'transaction, Root, File>

§

impl<'transaction, Root, File> Unpin for LockedTransactionTree<'transaction, Root, File>

§

impl<'transaction, Root, File> !UnwindSafe for LockedTransactionTree<'transaction, 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.