1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//! Morsel-driven parallel execution engine.
//!
//! This module provides parallel query execution using morsel-driven scheduling
//! with work-stealing. Workers process data chunks (morsels) independently,
//! enabling linear scaling on multi-core systems.
//!
//! # Architecture
//!
//! ```text
//! ┌─────────────────────────────────────────────────────────────────┐
//! │ ParallelPipeline │
//! │ ┌─────────────────────────────────────────────────────────────┐ │
//! │ │ MorselScheduler │ │
//! │ │ ┌─────────┐ ┌──────────────┐ ┌──────────────────┐ │ │
//! │ │ │ Global │ │ Work-Stealing│ │ Local Queues │ │ │
//! │ │ │ Queue │ │ Deques │ │ (per worker) │ │ │
//! │ │ └─────────┘ └──────────────┘ └──────────────────┘ │ │
//! │ └─────────────────────────────────────────────────────────────┘ │
//! │ │
//! │ Workers: [Thread 0] [Thread 1] [Thread 2] ... [Thread N-1] │
//! │ Each has its own operator chain instance │
//! │ │
//! │ Morsels: 64K row units distributed across workers │
//! └─────────────────────────────────────────────────────────────────┘
//! ```
//!
//! # Key Concepts
//!
//! - **Morsel**: A unit of work (typically 64K rows) that a worker processes
//! - **Work-Stealing**: Workers steal morsels from others when their queue is empty
//! - **Per-Worker Pipelines**: Each worker has its own operator chain instances
//! - **Pipeline Breakers**: Operators like Sort/Aggregate that need merge phase
//!
//! # Example
//!
//! ```no_run
//! use grafeo_core::execution::parallel::{
//! ParallelPipeline, ParallelPipelineConfig, CloneableOperatorFactory, RangeSource
//! };
//! use std::sync::Arc;
//!
//! // Create a parallel source
//! let source = Arc::new(RangeSource::new(1_000_000));
//!
//! // Create operator factory (each worker gets its own operators)
//! let factory = Arc::new(CloneableOperatorFactory::new());
//!
//! // Configure and execute
//! let config = ParallelPipelineConfig::default().with_workers(4);
//! let pipeline = ParallelPipeline::new(source, factory, config);
//! let result = pipeline.execute().unwrap();
//!
//! println!("Processed {} rows", result.rows_processed);
//! ```
// Re-export main types
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ParallelTripleScanSource;
pub use ;