pub trait ParallelRebalancer<S: Store> {
// Required methods
fn parallel_rebalance(
&self,
store: &S,
prolly: &Prolly<S>,
nodes: Vec<(Node, Vec<(Node, usize)>)>,
config: &ParallelConfig,
) -> Result<Vec<Cid>, Error>;
fn parallel_batch(
&self,
_store: &S,
prolly: &Prolly<S>,
tree: &Tree,
mutations: Vec<Mutation>,
config: &ParallelConfig,
) -> Result<Tree, Error>;
}Expand description
Trait for parallel rebalancing operations.
Implementations of this trait provide parallel processing capabilities for tree rebalancing and batch mutation operations.
§Example
use prolly::{Prolly, MemStore, Config, Mutation, ParallelRebalancer, DefaultParallelRebalancer, ParallelConfig};
let store = MemStore::new();
let prolly = Prolly::new(store, Config::default());
let tree = prolly.create();
let rebalancer = DefaultParallelRebalancer;
let config = ParallelConfig::default();
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() },
];
// Note: For direct trait usage, store and prolly must use the same store type
// For convenience, use prolly.parallel_batch() insteadRequired Methods§
Sourcefn parallel_rebalance(
&self,
store: &S,
prolly: &Prolly<S>,
nodes: Vec<(Node, Vec<(Node, usize)>)>,
config: &ParallelConfig,
) -> Result<Vec<Cid>, Error>
fn parallel_rebalance( &self, store: &S, prolly: &Prolly<S>, nodes: Vec<(Node, Vec<(Node, usize)>)>, config: &ParallelConfig, ) -> Result<Vec<Cid>, Error>
Rebalance multiple nodes in parallel.
Processes independent subtrees concurrently using a thread pool. Falls back to sequential processing when below the parallelism threshold.
§Arguments
store- The storage backendprolly- The Prolly tree managernodes- Nodes to rebalance with their ancestor pathsconfig- Parallel configuration
§Returns
Ok(Vec<Cid>)- Vector of new root CIDs for each rebalanced subtreeErr(Error)- On storage or processing errors
Sourcefn parallel_batch(
&self,
_store: &S,
prolly: &Prolly<S>,
tree: &Tree,
mutations: Vec<Mutation>,
config: &ParallelConfig,
) -> Result<Tree, Error>
fn parallel_batch( &self, _store: &S, prolly: &Prolly<S>, tree: &Tree, mutations: Vec<Mutation>, config: &ParallelConfig, ) -> Result<Tree, Error>
Apply batch mutations with parallel leaf processing.
Groups mutations by target leaf and processes independent leaf groups in parallel when beneficial. Uses batch_get and batch_put for efficient I/O.
§Arguments
store- The storage backendprolly- The Prolly tree managertree- The tree to modifymutations- Vector of mutations to applyconfig- Parallel configuration
§Returns
Ok(Tree)- New tree with all mutations appliedErr(Error)- On storage or processing errors
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".