Parallel Data Processing Pipeline with rayon

Updated

October 31, 2026

Parallel Data Processing Pipeline with rayon

In Project 3, we implement a high-throughput parallel text analysis pipeline using rayon.

// Parallel pipeline conceptual architecture
pub struct TextStats {
    pub word_count: usize,
    pub line_count: usize,
}

pub fn analyze_lines(lines: &[&str]) -> TextStats {
    // rayon would process using .par_iter()
    let line_count = lines.len();
    let word_count = lines.iter().map(|l| l.split_whitespace().count()).sum();
    TextStats { word_count, line_count }
}

fn main() {
    let sample = vec![
        "Rust delivers safe systems programming",
        "Rayon provides work-stealing parallelism",
        "Zero-cost abstractions minimize runtime overhead",
    ];
    let stats = analyze_lines(&sample);
    println!("Processed {} lines, {} words", stats.line_count, stats.word_count);
}