pub struct BatchWriter { /* private fields */ }Expand description
Batch writer with configurable settings.
BatchWriter provides a configurable interface for applying batch mutations
to Prolly trees. It wraps the batch operation logic and applies the configured
optimizations.
§Example
use prolly::{BatchWriter, BatchWriterConfig, Prolly, MemStore, Config, Mutation};
let store = MemStore::new();
let prolly = Prolly::new(store, Config::default());
let tree = prolly.create();
// Create a batch writer with custom configuration
let config = BatchWriterConfig::new()
.with_optimized_merge(true);
let writer = BatchWriter::with_config(config);
// Apply mutations using the configured writer
let mutations = vec![
Mutation::Upsert { key: b"a".to_vec(), val: b"1".to_vec() },
Mutation::Upsert { key: b"b".to_vec(), val: b"2".to_vec() },
];
let new_tree = writer.apply_batch(&prolly, &tree, mutations).unwrap();Implementations§
Source§impl BatchWriter
impl BatchWriter
Sourcepub fn with_config(config: BatchWriterConfig) -> Self
pub fn with_config(config: BatchWriterConfig) -> Self
Create a new batch writer with custom configuration.
§Arguments
config- The configuration to use
§Returns
A new BatchWriter with the specified configuration.
§Example
use prolly::{BatchWriter, BatchWriterConfig};
let config = BatchWriterConfig::new()
.with_prefetch_parallelism(32);
let writer = BatchWriter::with_config(config);Sourcepub fn config(&self) -> &BatchWriterConfig
pub fn config(&self) -> &BatchWriterConfig
Sourcepub fn apply_batch<S: Store>(
&self,
prolly: &Prolly<S>,
tree: &Tree,
mutations: Vec<Mutation>,
) -> Result<Tree, Error>
pub fn apply_batch<S: Store>( &self, prolly: &Prolly<S>, tree: &Tree, mutations: Vec<Mutation>, ) -> Result<Tree, Error>
Apply batch mutations using the configured settings.
This method applies mutations to a tree using the optimizations specified in the configuration:
- Stores that prefer batched reads hydrate mutation paths in ordered batches
- If
use_optimized_mergeis true, uses O(n+m) two-pointer merge - Otherwise, uses O(m log n) binary search approach
- If
use_bottom_up_rebuildis true, uses bottom-up rebuild strategy for parent reconstruction (ensures each node is written exactly once)
§Arguments
prolly- Reference to the Prolly tree managertree- The tree to modifymutations- Vector of mutations to apply
§Returns
Ok(Tree)- New tree with all mutations appliedErr(Error)- On storage or processing errors
§Example
use prolly::{BatchWriter, Prolly, MemStore, Config, Mutation};
let store = MemStore::new();
let prolly = Prolly::new(store, Config::default());
let tree = prolly.create();
let writer = BatchWriter::new();
let mutations = vec![
Mutation::Upsert { key: b"key".to_vec(), val: b"value".to_vec() },
];
let new_tree = writer.apply_batch(&prolly, &tree, mutations).unwrap();Sourcepub fn apply_batch_with_stats<S: Store>(
&self,
prolly: &Prolly<S>,
tree: &Tree,
mutations: Vec<Mutation>,
) -> Result<BatchApplyResult, Error>
pub fn apply_batch_with_stats<S: Store>( &self, prolly: &Prolly<S>, tree: &Tree, mutations: Vec<Mutation>, ) -> Result<BatchApplyResult, Error>
Apply batch mutations and return store-neutral execution stats.
This is useful for tuning workload shape across storage backends. The returned stats report tree-level work such as affected leaves and unique prolly nodes/bytes written, independent of backend compaction or object layout.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BatchWriter
impl RefUnwindSafe for BatchWriter
impl Send for BatchWriter
impl Sync for BatchWriter
impl Unpin for BatchWriter
impl UnsafeUnpin for BatchWriter
impl UnwindSafe for BatchWriter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more