Struct nebari::TransactionTree
source · [−]pub struct TransactionTree<Root: Root, File: ManagedFile> { /* private fields */ }Expand description
A tree that is modifiable during a transaction.
Implementations
sourceimpl<File: ManagedFile, Index> TransactionTree<VersionedTreeRoot<Index>, File> where
Index: Clone + Reducer<Index> + EmbeddedIndex + Debug + 'static,
impl<File: ManagedFile, Index> TransactionTree<VersionedTreeRoot<Index>, File> where
Index: Clone + Reducer<Index> + EmbeddedIndex + Debug + 'static,
sourcepub fn current_sequence_id(&self) -> u64
pub fn current_sequence_id(&self) -> u64
Returns the latest sequence id.
sourceimpl<Root: Root, File: ManagedFile> TransactionTree<Root, File>
impl<Root: Root, File: ManagedFile> TransactionTree<Root, File>
sourcepub fn set(
&mut self,
key: impl Into<ArcBytes<'static>>,
value: impl Into<ArcBytes<'static>>
) -> Result<(), Error>
pub fn set(
&mut self,
key: impl Into<ArcBytes<'static>>,
value: impl Into<ArcBytes<'static>>
) -> Result<(), Error>
Sets key to value.
sourcepub fn modify<'a>(
&mut self,
keys: Vec<ArcBytes<'a>>,
operation: Operation<'a, ArcBytes<'static>>
) -> Result<(), Error>
pub fn modify<'a>(
&mut self,
keys: Vec<ArcBytes<'a>>,
operation: Operation<'a, ArcBytes<'static>>
) -> Result<(), Error>
Executes a modification.
sourcepub fn replace(
&mut self,
key: impl Into<ArcBytes<'static>>,
value: impl Into<ArcBytes<'static>>
) -> Result<Option<ArcBytes<'static>>, Error>
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.
sourcepub fn get(&mut self, key: &[u8]) -> Result<Option<ArcBytes<'static>>, Error>
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.
sourcepub fn remove(&mut self, key: &[u8]) -> Result<Option<ArcBytes<'static>>, Error>
pub fn remove(&mut self, key: &[u8]) -> Result<Option<ArcBytes<'static>>, Error>
Removes key and returns the existing value, if present.
sourcepub fn compare_and_swap(
&mut self,
key: &[u8],
old: Option<&[u8]>,
new: Option<ArcBytes<'_>>
) -> Result<(), CompareAndSwapError>
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.
sourcepub 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,
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.
sourcepub fn get_range<'keys, KeyRangeBounds>(
&mut self,
range: &'keys KeyRangeBounds
) -> Result<Vec<(ArcBytes<'static>, ArcBytes<'static>)>, Error> where
KeyRangeBounds: RangeBounds<&'keys [u8]> + Debug + ?Sized,
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.
sourcepub 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,
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.
sourcepub fn reduce<'keys, KeyRangeBounds>(
&mut self,
range: &'keys KeyRangeBounds
) -> Result<Root::ReducedIndex, Error> where
KeyRangeBounds: RangeBounds<&'keys [u8]> + Debug + Clone + ?Sized,
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.
sourcepub fn first_key(&mut self) -> Result<Option<ArcBytes<'static>>, Error>
pub fn first_key(&mut self) -> Result<Option<ArcBytes<'static>>, Error>
Returns the first key of the tree.
sourcepub fn first(
&mut self
) -> Result<Option<(ArcBytes<'static>, ArcBytes<'static>)>, Error>
pub fn first(
&mut self
) -> Result<Option<(ArcBytes<'static>, ArcBytes<'static>)>, Error>
Returns the first key and value of the tree.
Auto Trait Implementations
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> where
<<File as ManagedFile>::Manager as FileManager>::FileHandle: Unpin,
impl<Root, File> !UnwindSafe for TransactionTree<Root, File>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more