Parse one input env and partition it into shards. When `print_plan` is set, emit the per-shard breakdown (range, items, bytes).
( ixe: Option<&PathBuf>, shard_consts: u32, shard_bytes: Option<usize>, print_plan: bool, )
| 369 | s.human_count_bytes(), |
| 370 | shard_bytes.human_count_bytes(), |
| 371 | ); |
| 372 | } |
| 373 | let i = i as u32; |
| 374 | if current_bytes > 0 && current_bytes + s > shard_bytes { |
| 375 | out.push((current_start, i)); |
| 376 | current_start = i; |
| 377 | current_bytes = 0; |
| 378 | } |
| 379 | current_bytes += s; |
| 380 | } |
| 381 | if current_start < work.len() as u32 { |
| 382 | out.push((current_start, work.len() as u32)); |
| 383 | } |
| 384 | Ok(out) |
| 385 | } |
| 386 | |
| 387 | /// Parse one input env and partition it into shards. When `print_plan` |
| 388 | /// is set, emit the per-shard breakdown (range, items, bytes). |
| 389 | fn plan_input( |
| 390 | ixe: Option<&PathBuf>, |
| 391 | shard_consts: u32, |
| 392 | shard_bytes: Option<usize>, |
| 393 | print_plan: bool, |
| 394 | ) -> Result<InputPlan> { |
| 395 | let label = ixe |
| 396 | .map(|p| p.display().to_string()) |
| 397 | .unwrap_or_else(|| "<empty env>".to_string()); |
| 398 | let env_bytes = load_env_bytes(ixe); |
| 399 | let env = |
| 400 | IxonEnv::get_anon(&mut &env_bytes[..]).expect("invalid Ixon environment"); |
| 401 | let work = build_anon_work(&env).expect("build_anon_work"); |
| 402 | let total: u32 = work.len().try_into().expect("work-item count fits in u32"); |
| 403 | let target_count: usize = work.iter().map(|item| item.targets().len()).sum(); |
| 404 | let shards = match shard_bytes { |
| 405 | Some(budget) => plan_shards_by_cost(&work, &env, budget)?, |
| 406 | None => plan_shards(total, shard_consts), |
| 407 | }; |
| 408 | println!( |
| 409 | "input {label}: {total} work items ({target_count} target constants), \ |
| 410 | {} shard(s)", |
| 411 | shards.len(), |
| 412 | ); |
no test coverage detected