pub trait Root: Debug + Send + Sync + Clone + 'static {
type Index: Clone + Debug + 'static;
type ReducedIndex: Clone + Debug + 'static;
type Reducer: Reducer<Self::Index, Self::ReducedIndex> + 'static;
const HEADER: PageHeader;
Show 15 methods
fn default_with(reducer: Self::Reducer) -> Self;
fn reducer(&self) -> &Self::Reducer;
fn count(&self) -> u64;
fn dirty(&self) -> bool;
fn initialized(&self) -> bool;
fn initialize_default(&mut self);
fn serialize(
&mut self,
paged_writer: &mut PagedWriter<'_>,
output: &mut Vec<u8>
) -> Result<(), Error>;
fn deserialize(
bytes: ArcBytes<'_>,
reducer: Self::Reducer
) -> Result<Self, Error>;
fn transaction_id(&self) -> TransactionId;
fn modify<'a, 'w>(
&'a mut self,
modification: Modification<'_, ArcBytes<'static>, Self::Index>,
writer: &'a mut PagedWriter<'w>,
max_order: Option<usize>
) -> Result<Vec<ModificationResult<Self::Index>>, Error>;
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]>;
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>>;
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>;
fn tree<File: ManagedFile>(
name: impl Into<Cow<'static, str>>
) -> TreeRoot<Self, File>
where
Self::Reducer: Default,
{ ... }
fn tree_with_reducer<File: ManagedFile>(
name: impl Into<Cow<'static, str>>,
reducer: Self::Reducer
) -> TreeRoot<Self, File> { ... }
}
Expand description
A B-Tree root implementation.
Associated Types
type ReducedIndex: Clone + Debug + 'static
type ReducedIndex: Clone + Debug + 'static
The primary index type contained within this root.
type Reducer: Reducer<Self::Index, Self::ReducedIndex> + 'static
type Reducer: Reducer<Self::Index, Self::ReducedIndex> + 'static
The reducer that reduces Index
es and re-reduces ReducedIndex
es.
Associated Constants
const HEADER: PageHeader
const HEADER: PageHeader
The unique header byte for this root.
Required methods
fn default_with(reducer: Self::Reducer) -> Self
fn default_with(reducer: Self::Reducer) -> Self
Returns a new instance with the provided reducer.
Returns the number of values contained in this tree, not including deleted records.
fn initialized(&self) -> bool
fn initialized(&self) -> bool
Returns true if the tree is initialized.
fn 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.
Serialize the root and return the bytes. Writes any additional data to
paged_writer
in the process of serialization.
Deserializes the root from bytes
.
fn transaction_id(&self) -> TransactionId
fn transaction_id(&self) -> TransactionId
Returns the current transaction id.
fn modify<'a, 'w>(
&'a mut self,
modification: Modification<'_, ArcBytes<'static>, Self::Index>,
writer: &'a mut PagedWriter<'w>,
max_order: Option<usize>
) -> Result<Vec<ModificationResult<Self::Index>>, Error>
fn modify<'a, 'w>(
&'a mut self,
modification: Modification<'_, ArcBytes<'static>, Self::Index>,
writer: &'a mut PagedWriter<'w>,
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.
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]>,
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.
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>>,
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.
Provided methods
Returns a reference to a named tree that contains this type of root.
fn 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.