MCPcopy Create free account
hub / github.com/argumentcomputer/ix / plan_input

Function plan_input

zisk/host/src/main.rs:371–409  ·  view source on GitHub ↗

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,
)

Source from the content-addressed store, hash-verified

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).
389fn 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 );

Callers 1

mainFunction · 0.85

Calls 8

plan_shards_by_costFunction · 0.85
plan_shardsFunction · 0.85
item_cost_bytesFunction · 0.85
targetsMethod · 0.80
load_env_bytesFunction · 0.70
build_anon_workFunction · 0.50
lenMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected