Skip to main content

sort_and_drop_duplicates

Function sort_and_drop_duplicates 

Source
pub(crate) fn sort_and_drop_duplicates(
    rows: &mut Vec<(i64, f64, usize)>,
    calibrations: &[(CalibrationSpec, String)],
)
Expand description

Sorts rows by timestamp and removes exact duplicates.

Two rows are duplicates when their timestamps are equal and their values have the same bit pattern (f64::to_bits), so NaN copies collapse too. Rows with the same timestamp but different values are all kept, in their original order. The sort is stable and skipped when the rows are already in order, so rows of a single clean file come out exactly as stored.

When duplicates carry different calibrations, the kept row takes the most preferred one (see calibration_preference); on a tie the earliest row’s calibration stays.

§Arguments

  • rows - (timestamp_unix_ns, raw_value, calibration index) rows, in file order; replaced by the result.
  • calibrations - Calibrations the indices refer to.