Skip to main content

ParallelRebalancer

Trait ParallelRebalancer 

Source
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() instead

Required Methods§

Source

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 backend
  • prolly - The Prolly tree manager
  • nodes - Nodes to rebalance with their ancestor paths
  • config - Parallel configuration
§Returns
  • Ok(Vec<Cid>) - Vector of new root CIDs for each rebalanced subtree
  • Err(Error) - On storage or processing errors
Source

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 backend
  • prolly - The Prolly tree manager
  • tree - The tree to modify
  • mutations - Vector of mutations to apply
  • config - Parallel configuration
§Returns
  • Ok(Tree) - New tree with all mutations applied
  • Err(Error) - On storage or processing errors

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§