pub(crate) struct ValueTextCache {
pub(crate) slots: Vec<ValueSlot>,
pub(crate) formula: CalibrationFormula,
pub(crate) generation: u32,
pub(crate) lookups: u32,
pub(crate) hits: u32,
pub(crate) bypass: u32,
}Expand description
Remembers the raw_value,calibrated_value text of recently written raw values.
Values come from a 16-bit converter and repeat heavily (the archive stores them
dictionary-encoded), while formatting two f64 with Display is the largest
cost of a CSV row. This direct-mapped table, keyed by the raw value’s bits under
the current calibration formula, lets a repeated value be copied instead. The
text is exactly what write!(out, "{raw},{calibrated}") produces, because a
cached entry is that output, and a calibrated value is a pure function of the
raw bits and the formula’s coefficients (compared bit for bit, so -0.0 and
0.0 coefficients are different formulas). A different formula starts a new
generation, which empties the table without touching it. Data with few repeats
(a wide-ranging signal) would only pay for the lookups, so after a window of
VALUE_CACHE_WINDOW lookups with fewer than a quarter hits the table is
bypassed for VALUE_CACHE_BYPASS rows.
Fields§
§slots: Vec<ValueSlot>Slots, allocated on first use.
formula: CalibrationFormulaFormula the current generation’s texts were calibrated with.
generation: u32Current generation, never 0.
lookups: u32Lookups in the current window.
hits: u32Hits in the current window.
bypass: u32Rows still to format without the table.