Expand description
Progress tracking for table generation.
§Overview
ProgressTracker is a small, dyn-compatible trait that receives
generation events from crate::tpch_cli::runner::PlanRunner. The runner calls:
ProgressTracker::registeronce per table, before any worker starts, with the total number of output units the table will produce (chunks for TBL/CSV, row groups for Parquet).ProgressTracker::incrementafter output units are written. Multiple table-generation tasks may call it concurrently, so impls must beSend + Syncandincrementitself should be lightweight.ProgressTracker::finishonce on the success path when the runner exits. Implementations should usefinishfor normal success cleanup andDroponly as an error or panic fallback.
register and finish are invoked serially by the runner and may
do bookkeeping or I/O; increment may run concurrently while output
is being written.
Implementations must not panic and must not propagate I/O errors — progress reporting is best-effort and must never affect the data path.
§Default implementation
When the indicatif-progress feature is enabled (on by default), the
crate provides an IndicatifProgress implementation, which renders
one progress bar per table on stderr using the indicatif crate.
Library users who do not want to pull in indicatif can disable default
features and still supply their own ProgressTracker implementation.
Without indicatif-progress and without a custom tracker, progress
reporting is a no-op.
§Example: a custom logging tracker
use std::sync::atomic::{AtomicU64, Ordering};
use tpcgen_cli::tpch_cli::progress::ProgressTracker;
use tpcgen_cli::tpch_cli::Table;
#[derive(Debug)]
struct LoggingTracker {
written: AtomicU64,
}
impl ProgressTracker for LoggingTracker {
fn register(&self, table: Table, total: u64) {
eprintln!("plan: {table:?} -> {total} output units");
}
fn increment(&self, _table: Table, units: u64) {
self.written.fetch_add(units, Ordering::Relaxed);
}
fn finish(&self) {
eprintln!("done: {} output units", self.written.load(Ordering::Relaxed));
}
}Structs§
- Indicatif
Progress - Default
ProgressTrackerimplementation backed byindicatif::MultiProgress.
Traits§
- Progress
Tracker - Receives generation-progress events for one
PlanRunnerinvocation.