Struct nebari::tree::VersionedTreeRoot
source · [−]pub struct VersionedTreeRoot<EmbeddedIndex> where
EmbeddedIndex: EmbeddedIndex, {
pub transaction_id: TransactionId,
pub sequence: SequenceId,
pub by_sequence_root: BTreeEntry<BySequenceIndex<EmbeddedIndex>, BySequenceStats>,
pub by_id_root: BTreeEntry<VersionedByIdIndex<EmbeddedIndex>, ByIdStats<EmbeddedIndex::Reduced>>,
/* private fields */
}
Expand description
A versioned B-Tree root. This tree root internally uses two btrees, one to keep track of all writes using a unique “sequence” ID, and one that keeps track of all key-value pairs.
Fields
transaction_id: TransactionId
The transaction ID of the tree root. If this transaction ID isn’t present in the transaction log, this root should not be trusted.
sequence: SequenceId
The last sequence ID inside of this root.
by_sequence_root: BTreeEntry<BySequenceIndex<EmbeddedIndex>, BySequenceStats>
The by-sequence B-Tree.
by_id_root: BTreeEntry<VersionedByIdIndex<EmbeddedIndex>, ByIdStats<EmbeddedIndex::Reduced>>
The by-id B-Tree.
Trait Implementations
sourceimpl<EmbeddedIndex: Clone> Clone for VersionedTreeRoot<EmbeddedIndex> where
EmbeddedIndex: EmbeddedIndex,
EmbeddedIndex::Reduced: Clone,
EmbeddedIndex::Indexer: Clone,
impl<EmbeddedIndex: Clone> Clone for VersionedTreeRoot<EmbeddedIndex> where
EmbeddedIndex: EmbeddedIndex,
EmbeddedIndex::Reduced: Clone,
EmbeddedIndex::Indexer: Clone,
sourcefn clone(&self) -> VersionedTreeRoot<EmbeddedIndex>
fn clone(&self) -> VersionedTreeRoot<EmbeddedIndex>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<EmbeddedIndex: Debug> Debug for VersionedTreeRoot<EmbeddedIndex> where
EmbeddedIndex: EmbeddedIndex,
EmbeddedIndex::Reduced: Debug,
EmbeddedIndex::Indexer: Debug,
impl<EmbeddedIndex: Debug> Debug for VersionedTreeRoot<EmbeddedIndex> where
EmbeddedIndex: EmbeddedIndex,
EmbeddedIndex::Reduced: Debug,
EmbeddedIndex::Indexer: Debug,
sourceimpl<EmbeddedIndex> Default for VersionedTreeRoot<EmbeddedIndex> where
EmbeddedIndex: EmbeddedIndex + Clone + Debug + 'static,
EmbeddedIndex::Indexer: Default,
impl<EmbeddedIndex> Default for VersionedTreeRoot<EmbeddedIndex> where
EmbeddedIndex: EmbeddedIndex + Clone + Debug + 'static,
EmbeddedIndex::Indexer: Default,
sourceimpl<EmbeddedIndex> Root for VersionedTreeRoot<EmbeddedIndex> where
EmbeddedIndex: EmbeddedIndex + Clone + Debug + 'static,
impl<EmbeddedIndex> Root for VersionedTreeRoot<EmbeddedIndex> where
EmbeddedIndex: EmbeddedIndex + Clone + Debug + 'static,
sourceconst HEADER: PageHeader
const HEADER: PageHeader
The unique header byte for this root.
type Index = VersionedByIdIndex<EmbeddedIndex>
type Index = VersionedByIdIndex<EmbeddedIndex>
The primary index type contained within this root.
type ReducedIndex = ByIdStats<EmbeddedIndex::Reduced>
type ReducedIndex = ByIdStats<EmbeddedIndex::Reduced>
The primary index type contained within this root.
type Reducer = ByIdIndexer<EmbeddedIndex::Indexer>
type Reducer = ByIdIndexer<EmbeddedIndex::Indexer>
The reducer that reduces Index
es and re-reduces ReducedIndex
es.
sourcefn default_with(reducer: Self::Reducer) -> Self
fn default_with(reducer: Self::Reducer) -> Self
Returns a new instance with the provided reducer.
sourcefn initialized(&self) -> bool
fn initialized(&self) -> bool
Returns true if the tree is initialized.
sourcefn initialize_default(&mut self)
fn initialize_default(&mut self)
Resets the state to the default, initialized state. After calling this,
Self::initialized()
will return true. Read more
sourcefn count(&self) -> u64
fn count(&self) -> u64
Returns the number of values contained in this tree, not including deleted records. Read more
sourcefn deserialize(
bytes: ArcBytes<'_>,
reducer: Self::Reducer
) -> Result<Self, Error>
fn deserialize(
bytes: ArcBytes<'_>,
reducer: Self::Reducer
) -> Result<Self, Error>
Deserializes the root from bytes
.
sourcefn serialize(
&mut self,
paged_writer: &mut PagedWriter<'_>,
output: &mut Vec<u8>
) -> Result<(), Error>
fn serialize(
&mut self,
paged_writer: &mut PagedWriter<'_>,
output: &mut Vec<u8>
) -> Result<(), Error>
Serialize the root and return the bytes. Writes any additional data to
paged_writer
in the process of serialization. Read more
sourcefn transaction_id(&self) -> TransactionId
fn transaction_id(&self) -> TransactionId
Returns the current transaction id.
sourcefn modify(
&mut self,
modification: Modification<'_, ArcBytes<'static>, Self::Index>,
writer: &mut PagedWriter<'_>,
max_order: Option<usize>
) -> Result<Vec<ModificationResult<Self::Index>>, Error>
fn modify(
&mut self,
modification: Modification<'_, ArcBytes<'static>, Self::Index>,
writer: &mut PagedWriter<'_>,
max_order: Option<usize>
) -> Result<Vec<ModificationResult<Self::Index>>, Error>
Modifies the tree. Returns a list of modified keys and their updated indexes, if the keys are still present. Read more
sourcefn get_multiple<'keys, KeyEvaluator, KeyReader, Keys>(
&self,
keys: &mut Keys,
key_evaluator: &mut KeyEvaluator,
key_reader: &mut KeyReader,
file: &mut dyn File,
vault: Option<&dyn AnyVault>,
cache: Option<&ChunkCache>
) -> Result<(), Error> where
KeyEvaluator: FnMut(&ArcBytes<'static>, &Self::Index) -> ScanEvaluation,
KeyReader: FnMut(ArcBytes<'static>, ArcBytes<'static>, Self::Index) -> Result<(), Error>,
Keys: Iterator<Item = &'keys [u8]>,
fn get_multiple<'keys, KeyEvaluator, KeyReader, Keys>(
&self,
keys: &mut Keys,
key_evaluator: &mut KeyEvaluator,
key_reader: &mut KeyReader,
file: &mut dyn File,
vault: Option<&dyn AnyVault>,
cache: Option<&ChunkCache>
) -> Result<(), Error> where
KeyEvaluator: FnMut(&ArcBytes<'static>, &Self::Index) -> ScanEvaluation,
KeyReader: FnMut(ArcBytes<'static>, ArcBytes<'static>, Self::Index) -> Result<(), Error>,
Keys: Iterator<Item = &'keys [u8]>,
Iterates over the tree looking for keys
. keys
must be sorted.
key_evaluator
is invoked for each key as it is found, allowing for
decisions on how to handle each key. key_reader
will be invoked for
each key that is requested to be read, but it might be invoked at a
later time and in a different order. Read more
sourcefn scan<'keys, CallerError: Display + Debug, NodeEvaluator, KeyRangeBounds, KeyEvaluator, ScanDataCallback>(
&self,
range: &'keys KeyRangeBounds,
args: &mut ScanArgs<Self::Index, Self::ReducedIndex, CallerError, NodeEvaluator, KeyEvaluator, ScanDataCallback>,
file: &mut dyn File,
vault: Option<&dyn AnyVault>,
cache: Option<&ChunkCache>
) -> Result<bool, AbortError<CallerError>> where
NodeEvaluator: FnMut(&ArcBytes<'static>, &Self::ReducedIndex, usize) -> ScanEvaluation,
KeyEvaluator: FnMut(&ArcBytes<'static>, &Self::Index) -> ScanEvaluation,
KeyRangeBounds: RangeBounds<&'keys [u8]> + Debug + ?Sized,
ScanDataCallback: FnMut(ArcBytes<'static>, &Self::Index, ArcBytes<'static>) -> Result<(), AbortError<CallerError>>,
fn scan<'keys, CallerError: Display + Debug, NodeEvaluator, KeyRangeBounds, KeyEvaluator, ScanDataCallback>(
&self,
range: &'keys KeyRangeBounds,
args: &mut ScanArgs<Self::Index, Self::ReducedIndex, CallerError, NodeEvaluator, KeyEvaluator, ScanDataCallback>,
file: &mut dyn File,
vault: Option<&dyn AnyVault>,
cache: Option<&ChunkCache>
) -> Result<bool, AbortError<CallerError>> where
NodeEvaluator: FnMut(&ArcBytes<'static>, &Self::ReducedIndex, usize) -> ScanEvaluation,
KeyEvaluator: FnMut(&ArcBytes<'static>, &Self::Index) -> ScanEvaluation,
KeyRangeBounds: RangeBounds<&'keys [u8]> + Debug + ?Sized,
ScanDataCallback: FnMut(ArcBytes<'static>, &Self::Index, ArcBytes<'static>) -> Result<(), AbortError<CallerError>>,
Scans the tree over range
. args.key_evaluator
is invoked for each key as
it is found, allowing for decisions on how to handle each key.
args.key_reader
will be invoked for each key that is requested to be read,
but it might be invoked at a later time and in a different order. Read more
sourcefn copy_data_to(
&mut self,
include_nodes: bool,
file: &mut dyn File,
copied_chunks: &mut HashMap<u64, u64>,
writer: &mut PagedWriter<'_>,
vault: Option<&dyn AnyVault>
) -> Result<(), Error>
fn copy_data_to(
&mut self,
include_nodes: bool,
file: &mut dyn File,
copied_chunks: &mut HashMap<u64, u64>,
writer: &mut PagedWriter<'_>,
vault: Option<&dyn AnyVault>
) -> Result<(), Error>
Copies all data from file
into writer
, updating self
with the new
file positions. Read more
sourcefn tree<File: ManagedFile>(
name: impl Into<Cow<'static, str>>
) -> TreeRoot<Self, File> where
Self::Reducer: Default,
fn tree<File: ManagedFile>(
name: impl Into<Cow<'static, str>>
) -> TreeRoot<Self, File> where
Self::Reducer: Default,
Returns a reference to a named tree that contains this type of root.
sourcefn tree_with_reducer<File: ManagedFile>(
name: impl Into<Cow<'static, str>>,
reducer: Self::Reducer
) -> TreeRoot<Self, File>
fn tree_with_reducer<File: ManagedFile>(
name: impl Into<Cow<'static, str>>,
reducer: Self::Reducer
) -> TreeRoot<Self, File>
Returns a reference to a named tree that contains this type of root.
Auto Trait Implementations
impl<EmbeddedIndex> RefUnwindSafe for VersionedTreeRoot<EmbeddedIndex> where
EmbeddedIndex: RefUnwindSafe,
<EmbeddedIndex as EmbeddedIndex>::Indexer: RefUnwindSafe,
<EmbeddedIndex as EmbeddedIndex>::Reduced: RefUnwindSafe,
impl<EmbeddedIndex> Send for VersionedTreeRoot<EmbeddedIndex>
impl<EmbeddedIndex> Sync for VersionedTreeRoot<EmbeddedIndex>
impl<EmbeddedIndex> Unpin for VersionedTreeRoot<EmbeddedIndex> where
EmbeddedIndex: Unpin,
<EmbeddedIndex as EmbeddedIndex>::Indexer: Unpin,
<EmbeddedIndex as EmbeddedIndex>::Reduced: Unpin,
impl<EmbeddedIndex> UnwindSafe for VersionedTreeRoot<EmbeddedIndex> where
EmbeddedIndex: UnwindSafe,
<EmbeddedIndex as EmbeddedIndex>::Indexer: UnwindSafe,
<EmbeddedIndex as EmbeddedIndex>::Reduced: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more