Skip to main content

Module progress

Module progress 

Source
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:

  1. ProgressTracker::register once 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).
  2. ProgressTracker::increment after output units are written. Multiple table-generation tasks may call it concurrently, so impls must be Send + Sync and increment itself should be lightweight.
  3. ProgressTracker::finish once on the success path when the runner exits. Implementations should use finish for normal success cleanup and Drop only 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§

IndicatifProgress
Default ProgressTracker implementation backed by indicatif::MultiProgress.

Traits§

ProgressTracker
Receives generation-progress events for one PlanRunner invocation.