Skip to main content

ValueTextCache

Struct ValueTextCache 

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

Formula the current generation’s texts were calibrated with.

§generation: u32

Current generation, never 0.

§lookups: u32

Lookups in the current window.

§hits: u32

Hits in the current window.

§bypass: u32

Rows still to format without the table.

Implementations§

Source§

impl ValueTextCache

Source

pub(crate) fn new() -> Self

Creates an empty cache.

Source

pub(crate) fn write( &mut self, out: &mut Vec<u8>, raw: f64, spec: &CalibrationSpec, ) -> usize

Appends {raw},{calibrated} to out, calibrated being formula applied to raw.

§Returns

Where the calibrated text starts in out; it runs to the end of out.

Auto Trait Implementations§

Blanket Implementations§

§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more