pub struct Histogram {
pub buckets: Vec<Bucket>,
pub total_count: u64,
}Expand description
Equi-depth histogram over a single column.
Buckets are non-overlapping and sorted by min. Each bucket holds
roughly total_count / bucket_count rows. Range selectivity is
computed by counting buckets fully inside the query interval and
approximating the partial buckets at the edges.
Fields§
§buckets: Vec<Bucket>§total_count: u64Implementations§
Source§impl Histogram
impl Histogram
Sourcepub fn equi_depth_from_sample(
values: Vec<ColumnValue>,
bucket_count: usize,
) -> Histogram
pub fn equi_depth_from_sample( values: Vec<ColumnValue>, bucket_count: usize, ) -> Histogram
Build an equi-depth histogram from an in-memory sample.
bucket_count is clamped between 1 and values.len(). The
caller is responsible for sampling — passing the full table
works but is expensive on large columns.
Sourcepub fn range_selectivity(
&self,
lo: Option<&ColumnValue>,
hi: Option<&ColumnValue>,
) -> f64
pub fn range_selectivity( &self, lo: Option<&ColumnValue>, hi: Option<&ColumnValue>, ) -> f64
Estimate the fraction of rows whose value falls in
[lo, hi] (both bounds inclusive when present).
None for either bound means “open” — [lo..] for upper-open,
[..hi] for lower-open, and None/None returns 1.0
(every row qualifies).
Returns a value clamped to [0.0, 1.0].
Sourcepub fn bucket_count(&self) -> usize
pub fn bucket_count(&self) -> usize
Number of buckets in the histogram.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Histogram
impl RefUnwindSafe for Histogram
impl Send for Histogram
impl Sync for Histogram
impl Unpin for Histogram
impl UnsafeUnpin for Histogram
impl UnwindSafe for Histogram
Blanket Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request