Expand description
Parallel fold-reduce utilities using Rayon.
This module provides ergonomic patterns for parallel data processing
using Rayon’s fold and reduce operations. These patterns are useful
for batch operations like import, export, and statistics collection.
§Why Fold-Reduce?
The fold-reduce pattern provides:
- No contention: Each thread has its own accumulator
- Work-stealing: Rayon handles load balancing automatically
- Composable: Easy to combine multiple aggregations
§Example
ⓘ
use grafeo_core::execution::parallel::fold::{parallel_count, parallel_sum};
use rayon::prelude::*;
let numbers: Vec<i32> = (0..1000).collect();
// Count even numbers
let even_count = parallel_count(numbers.par_iter(), |n| *n % 2 == 0);
// Sum all numbers
let total: f64 = parallel_sum(numbers.par_iter(), |n| *n as f64);Traits§
- Mergeable
- Trait for types that can be merged in parallel fold-reduce operations.
Functions§
- fold_
reduce - Execute parallel fold-reduce with custom accumulator.
- fold_
reduce_ with - Fold-reduce with a custom identity/factory function.
- parallel_
count - Count items matching a predicate in parallel.
- parallel_
max - Find maximum value in parallel.
- parallel_
min - Find minimum value in parallel.
- parallel_
partition - Partition items into groups based on a key extractor.
- parallel_
stats - Compute multiple aggregations in a single parallel pass.
- parallel_
sum - Sum values extracted from items in parallel.
- parallel_
sum_ i64 - Sum integers extracted from items in parallel.
- parallel_
try_ collect - Collect results with errors separated.