pub struct DecimalTrack {
pub scale: u8,
pub sum: i128,
pub min: i128,
pub max: i128,
pub first: i128,
pub last: i128,
pub overflow: bool,
}Expand description
The exact half of an accumulator, allocated only for decimal columns.
Boxed behind an Option so a float column pays eight bytes for it and
nothing else — a group-by over a high-cardinality tag holds one
accumulator per (group, field), and making every one of them 128 bytes
wider to support a column type it does not have is a cost the gateway
would feel.
Fields§
§scale: u8The scale everything tracked here is expressed at.
sum: i128Running total.
min: i128Smallest mantissa seen.
max: i128Largest mantissa seen.
first: i128Mantissa at the earliest timestamp.
last: i128Mantissa at the latest timestamp.
overflow: boolA sum or a rescale needed more than 38 significant digits. The
affected results are NULL: a number that is not the answer is
worse than no number.
Implementations§
Source§impl DecimalTrack
impl DecimalTrack
Sourcepub fn align(&mut self, mantissa: i128, scale: u8) -> Option<i128>
pub fn align(&mut self, mantissa: i128, scale: u8) -> Option<i128>
Bring an incoming mantissa to the track’s scale, widening the track if the incoming value is finer. Both directions are exact.
Returns None when the alignment would overflow 38 digits; the
caller sets overflow.
Sourcepub fn sum_result(&self) -> AggResult
pub fn sum_result(&self) -> AggResult
The sum, or Null if it overflowed 38 digits.
Sourcepub fn avg_result(&self, count: u64) -> AggResult
pub fn avg_result(&self, count: u64) -> AggResult
The mean, carried to AVG_EXTRA_SCALE extra digits and rounded
half away from zero. See that constant for why this is the one
aggregate that rounds.
Trait Implementations§
Source§impl Clone for DecimalTrack
impl Clone for DecimalTrack
Source§fn clone(&self) -> DecimalTrack
fn clone(&self) -> DecimalTrack
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more