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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
//! OxiGDAL Distributed Processing
//!
//! This crate provides distributed processing capabilities for large-scale geospatial
//! workflows using Apache Arrow Flight for zero-copy data transfer.
//!
//! # Features
//!
//! - **Arrow Flight RPC**: Zero-copy data transfer between nodes
//! - **Worker Nodes**: Execute processing tasks with resource management
//! - **Coordinator**: Schedule and manage distributed execution
//! - **Data Partitioning**: Spatial, hash, range, and load-balanced partitioning
//! - **Shuffle Operations**: Efficient data redistribution for group-by and joins
//! - **Fault Tolerance**: Automatic retry and failure recovery
//! - **Progress Monitoring**: Real-time tracking of distributed execution
//!
//! # Architecture
//!
//! ```text
//! ┌─────────────┐
//! │ Coordinator │ ──── Schedules tasks
//! └──────┬──────┘
//! │
//! ┌────┴────┐
//! │ Flight │
//! │ Server │
//! └────┬────┘
//! │
//! ┌────┴────────────────┐
//! │ │
//! ┌─▼──────┐ ┌───▼─────┐
//! │ Worker │ │ Worker │
//! │ Node 1 │ │ Node 2 │
//! └────────┘ └─────────┘
//! ```
//!
//! # Example: Distributed NDVI Calculation
//!
//! ```rust,no_run
//! use oxigdal_distributed::*;
//! # async fn example() -> std::result::Result<(), Box<dyn std::error::Error>> {
//!
//! // Create coordinator
//! let config = CoordinatorConfig::new("localhost:50051".to_string());
//! let coordinator = Coordinator::new(config);
//!
//! // Add workers
//! coordinator.add_worker("worker-1".to_string(), "localhost:50052".to_string())?;
//! coordinator.add_worker("worker-2".to_string(), "localhost:50053".to_string())?;
//!
//! // Partition data spatially
//! let extent = SpatialExtent::new(0.0, 0.0, 1000.0, 1000.0)?;
//! let partitioner = TilePartitioner::new(extent, 4, 4)?;
//! let partitions = partitioner.partition();
//!
//! // Submit tasks for each partition
//! for partition in partitions {
//! coordinator.submit_task(
//! partition.id,
//! TaskOperation::CalculateIndex {
//! index_type: "NDVI".to_string(),
//! bands: vec![3, 4], // Red and NIR
//! },
//! )?;
//! }
//!
//! // Monitor progress
//! while !coordinator.is_complete() {
//! let progress = coordinator.get_progress()?;
//! println!(
//! "Progress: {}/{} completed",
//! progress.completed_tasks,
//! progress.total_tasks()
//! );
//! tokio::time::sleep(tokio::time::Duration::from_secs(1)).await;
//! }
//!
//! // Collect results
//! let results = coordinator.collect_results()?;
//! println!("Processing complete: {} results", results.len());
//! # Ok(())
//! # }
//! ```
//!
//! # Example: Custom Processing with Workers
//!
//! ```rust,no_run
//! use oxigdal_distributed::*;
//! # async fn example() -> std::result::Result<(), Box<dyn std::error::Error>> {
//!
//! // Create worker
//! let config = WorkerConfig::new("worker-1".to_string())
//! .with_max_concurrent_tasks(4)
//! .with_memory_limit(8 * 1024 * 1024 * 1024); // 8 GB
//!
//! let worker = Worker::new(config);
//!
//! // Execute tasks
//! // (Tasks would be received from coordinator in real implementation)
//! # Ok(())
//! # }
//! ```
//!
//! # Example: Data Shuffle
//!
//! ```rust,no_run
//! use oxigdal_distributed::*;
//! use arrow::array::{Int32Array, StringArray};
//! use arrow::datatypes::{DataType, Field, Schema};
//! use arrow::record_batch::RecordBatch;
//! use std::sync::Arc;
//!
//! # fn example() -> std::result::Result<(), Box<dyn std::error::Error>> {
//! // Create test data
//! let schema = Arc::new(Schema::new(vec![
//! Field::new("id", DataType::Int32, false),
//! Field::new("name", DataType::Utf8, false),
//! ]));
//!
//! let batch = RecordBatch::try_new(
//! schema,
//! vec![
//! Arc::new(Int32Array::from(vec![1, 2, 3, 4, 5])),
//! Arc::new(StringArray::from(vec!["a", "b", "c", "d", "e"])),
//! ],
//! )?;
//!
//! // Hash shuffle by ID column
//! let shuffle = HashShuffle::new("id".to_string(), 2)?;
//! let partitions = shuffle.shuffle(&batch)?;
//!
//! println!("Data shuffled into {} partitions", partitions.len());
//! # Ok(())
//! # }
//! ```
// Re-export main types
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;