Skip to main content

ColumnStats

Struct ColumnStats 

Source
pub struct ColumnStats {
    pub col_idx: usize,
    pub dtype: ScalarType,
    pub null_count: u64,
    pub distinct_estimate: u64,
    pub min_value: Option<i64>,
    pub max_value: Option<i64>,
    pub avg_width: Option<f32>,
}
Expand description

Per-column statistics for optimizer cost estimation.

Tracks null counts, distinct value estimates, and value ranges for columns. These statistics enable the optimizer to estimate filter selectivity and join cardinalities.

Fields§

§col_idx: usize

Column index within the relation

§dtype: ScalarType

Data type of the column

§null_count: u64

Count of null values (for nullable columns)

§distinct_estimate: u64

HyperLogLog-style distinct value estimate

§min_value: Option<i64>

Minimum value (for orderable types, stored as i64)

§max_value: Option<i64>

Maximum value (for orderable types, stored as i64)

§avg_width: Option<f32>

Average value length for variable-length types (e.g., symbols)

Implementations§

Source§

impl ColumnStats

Source

pub fn new(col_idx: usize, dtype: ScalarType) -> Self

Creates new column statistics with default values.

§Arguments
  • col_idx - The column index within the relation
  • dtype - The scalar type of the column
§Returns

A new ColumnStats instance with zero counts and no range information.

Source

pub fn update_distinct(&mut self, estimate: u64)

Updates the distinct value estimate.

This should be updated from HyperLogLog or similar cardinality estimation algorithms running on the GPU.

§Arguments
  • estimate - The new distinct value estimate
Source

pub fn update_range(&mut self, min: i64, max: i64)

Updates the value range for this column.

§Arguments
  • min - The minimum value (encoded as i64)
  • max - The maximum value (encoded as i64)
Source

pub fn update_null_count(&mut self, count: u64)

Updates the null count for this column.

§Arguments
  • count - The number of null values
Source

pub fn update_avg_width(&mut self, width: f32)

Updates the average width for variable-length columns.

§Arguments
  • width - The average value width in bytes
Source

pub fn equality_selectivity(&self, total_rows: u64) -> f64

Estimates selectivity for an equality predicate.

Uses the distinct value count to estimate selectivity. If no distinct count is available, returns a default estimate.

§Arguments
  • total_rows - The total number of rows in the relation
§Returns

The estimated selectivity (0.0 to 1.0)

Source

pub fn range_selectivity(&self, low: i64, high: i64) -> f64

Estimates selectivity for a range predicate.

Uses min/max values to estimate what fraction of the range is covered. Returns a default estimate if range statistics are unavailable.

§Arguments
  • low - The lower bound of the range (inclusive)
  • high - The upper bound of the range (inclusive)
§Returns

The estimated selectivity (0.0 to 1.0)

Source

pub fn value_size_bytes(&self) -> usize

Returns the storage size per value for this column type.

Trait Implementations§

Source§

impl Clone for ColumnStats

Source§

fn clone(&self) -> ColumnStats

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ColumnStats

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

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
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,