pub trait Mergeable: Sized + Send {
// Required method
fn merge(&mut self, other: Self);
// Provided method
fn merge_all(stats: Vec<Self>) -> Option<Self> { ... }
}Expand description
Trait for statistics that can be merged from parallel computations
This is the key trait that enables parallel processing:
- Each thread computes partial statistics on its chunk
- Partial statistics are merged at the end
§Properties
For correct parallel computation, merge must be:
- Associative: (a ⊕ b) ⊕ c = a ⊕ (b ⊕ c)
- Commutative: a ⊕ b = b ⊕ a
Where ⊕ represents the merge operation.
Required Methods§
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementors§
impl Mergeable for BamStats
Implementation of Mergeable for parallel statistics computation
Merges BAM statistics from multiple threads/chunks. All statistics are correctly combined using the underlying Mergeable implementations for RunningStats and CategoryCounter.
impl Mergeable for BedStats
Implementation of Mergeable for parallel statistics computation
Merges BED statistics from multiple threads/chunks. All statistics are correctly combined using the underlying Mergeable implementations for RunningStats and CategoryCounter.
impl Mergeable for FastqStats
Implementation of Mergeable for parallel statistics computation
Merges FASTQ statistics from multiple threads/chunks. All statistics are correctly combined using the underlying Mergeable implementations for RunningStats and CategoryCounter.
impl Mergeable for SamStats
Implementation of Mergeable for parallel statistics computation
Merges SAM statistics from multiple threads/chunks. All statistics are correctly combined using the underlying Mergeable implementations for RunningStats and CategoryCounter.
impl Mergeable for RunningStats
Implementation of Mergeable for parallel statistics computation
Uses Chan’s parallel variance algorithm to correctly merge running statistics from multiple threads.
Reference: https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Parallel_algorithm
impl<T: Hash + Eq + Send> Mergeable for CategoryCounter<T>
Implementation of Mergeable for parallel statistics computation
Merges category counts from multiple threads by summing counts for each category.