pub struct ColumnStats {
pub min_value: i64,
pub max_value: i64,
pub min_value_u64: u64,
pub max_value_u64: u64,
pub null_count: u64,
pub value_count: u64,
pub sum: f64,
pub sum_i128: i128,
pub distinct_count: u32,
}Expand description
Statistics for a single column within a row group.
Fields§
§min_value: i64Minimum value (as raw i64 bits for i64/f64/bool types).
For f64 columns this uses the total-order mapping from
f64_to_ordered_i64 so that min/max comparisons are correct
even for negative values.
max_value: i64Maximum value (as raw i64 bits for i64/f64/bool types).
min_value_u64: u64Minimum u64 value — used only for u64 columns.
max_value_u64: u64Maximum u64 value — used only for u64 columns.
null_count: u64Number of null values.
value_count: u64Number of non-null values.
sum: f64Sum of all values (for numeric types, 0 for others).
For float columns this is the canonical sum. For integer columns,
use sum_i128 for full precision.
sum_i128: i128Precise integer sum (i128) for i64/u64 columns.
Avoids the 2^53 precision loss of the f64 sum field. Set to
zero for float and non-numeric columns.
distinct_count: u32Number of distinct values (for string/tag columns, 0 for others).
Implementations§
Source§impl ColumnStats
impl ColumnStats
Sourcepub fn says_nothing(&self) -> bool
pub fn says_nothing(&self) -> bool
true when these statistics say nothing about the data.
A block with no observed value — every row null, or a block whose
statistics were deliberately suppressed because it is encrypted —
leaves min/max at their sentinels. A zone map must read that as
“unknown”, never as an empty range: min = i64::MAX and
max = i64::MIN make every comparison false, so a predicate on an
encrypted column pruned every row group and the query returned no
rows at all, with the correct key configured.
The distinction from a genuinely all-null block is null_count: an
all-null block is impossible to match, and pruning it is correct.
Sourcepub fn update_i64(&mut self, value: i64)
pub fn update_i64(&mut self, value: i64)
Update statistics with a new i64 value.
Sourcepub fn update_u64(&mut self, value: u64)
pub fn update_u64(&mut self, value: u64)
Update statistics with a new u64 value.
Tracks full-precision u64 min/max in dedicated fields. Clamping to
i64::MAX instead breaks predicate pushdown above 2^63.
Sourcepub fn update_decimal(&mut self, mantissa: i128)
pub fn update_decimal(&mut self, mantissa: i128)
Update statistics with a new decimal mantissa.
The mantissa is an i128 and min_value/max_value are i64, so
the zone map records a saturated range. That is deliberate and
safe in the only direction that matters: a saturated bound is wider
than the true one, so a row group is never pruned that might have
matched — the predicate simply stops being selective above 19
digits. sum_i128 stays exact, because a sum is an answer rather
than a hint.
Sourcepub fn update_f64(&mut self, value: f64)
pub fn update_f64(&mut self, value: f64)
Update statistics with a new f64 value.
Uses f64_to_ordered_i64 for correct ordering of negative values.
NaN values are excluded from min/max tracking (they would sort above
+∞, corrupting predicate pushdown) but are still counted in
value_count. Only finite values contribute to sum, so computing
an average as sum / value_count is only correct when the data
contains no NaN or Infinity values.
Sourcepub fn update_bool(&mut self, value: bool)
pub fn update_bool(&mut self, value: bool)
Update statistics with a new boolean value.
Sourcepub fn record_null(&mut self)
pub fn record_null(&mut self)
Record a null value.
Sourcepub fn from_bytes(data: &[u8]) -> Result<Self>
pub fn from_bytes(data: &[u8]) -> Result<Self>
Trait Implementations§
Source§impl Clone for ColumnStats
impl Clone for ColumnStats
Source§fn clone(&self) -> ColumnStats
fn clone(&self) -> ColumnStats
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ColumnStats
impl Debug for ColumnStats
Source§impl<'de> Deserialize<'de> for ColumnStats
impl<'de> Deserialize<'de> for ColumnStats
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for ColumnStats
impl PartialEq for ColumnStats
Source§impl Serialize for ColumnStats
impl Serialize for ColumnStats
impl StructuralPartialEq for ColumnStats
Auto Trait Implementations§
impl Freeze for ColumnStats
impl RefUnwindSafe for ColumnStats
impl Send for ColumnStats
impl Sync for ColumnStats
impl Unpin for ColumnStats
impl UnsafeUnpin for ColumnStats
impl UnwindSafe for ColumnStats
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more