pub struct BatchBuilder<S: Store> { /* private fields */ }Expand description
Batch builder for parallel tree construction.
Enables efficient bulk loading of data into a Prolly tree with parallel boundary detection and node creation using rayon.
§Example
use prolly::{BatchBuilder, MemStore, Config};
use std::sync::Arc;
let store = Arc::new(MemStore::new());
let config = Config::default();
let mut builder = BatchBuilder::new(store, config);
builder.add(b"key1".to_vec(), b"val1".to_vec());
builder.add(b"key2".to_vec(), b"val2".to_vec());
builder.add(b"key3".to_vec(), b"val3".to_vec());
let tree = builder.build().unwrap();Implementations§
Source§impl<S: Store + Clone + Send + Sync> BatchBuilder<S>
impl<S: Store + Clone + Send + Sync> BatchBuilder<S>
Sourcepub fn new(store: S, config: Config) -> Self
pub fn new(store: S, config: Config) -> Self
Create a new BatchBuilder with the given store and configuration.
§Arguments
store- Storage backend implementing theStoretraitconfig- Tree configuration (chunking parameters, encoding, etc.)
Sourcepub fn add(&mut self, key: Vec<u8>, val: Vec<u8>)
pub fn add(&mut self, key: Vec<u8>, val: Vec<u8>)
Add a key-value pair to the builder.
Entries will be sorted by key before building the tree.
§Arguments
key- The key bytesval- The value bytes
Sourcepub fn build(self) -> Result<Tree, Error>
pub fn build(self) -> Result<Tree, Error>
Build the tree from the added entries using parallel chunking.
This method:
- Sorts entries by key
- Partitions entries into chunks using parallel boundary detection
- Creates leaf nodes in parallel
- Builds internal nodes level by level
§Returns
Ok(Tree)- The constructed treeErr(Error)- If storage operations fail
Auto Trait Implementations§
impl<S> Freeze for BatchBuilder<S>where
S: Freeze,
impl<S> RefUnwindSafe for BatchBuilder<S>where
S: RefUnwindSafe,
impl<S> Send for BatchBuilder<S>
impl<S> Sync for BatchBuilder<S>
impl<S> Unpin for BatchBuilder<S>where
S: Unpin,
impl<S> UnsafeUnpin for BatchBuilder<S>where
S: UnsafeUnpin,
impl<S> UnwindSafe for BatchBuilder<S>where
S: UnwindSafe,
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