pub struct EquiDepthHistogram { /* private fields */ }Expand description
An equi-depth histogram for selectivity estimation.
Equi-depth histograms partition data into buckets where each bucket contains approximately the same number of rows. This provides more accurate selectivity estimates than assuming uniform distribution, especially for skewed data.
§Example
ⓘ
use grafeo_engine::query::optimizer::cardinality::EquiDepthHistogram;
// Build a histogram from sorted values
let values = vec![1.0, 2.0, 3.0, 4.0, 5.0, 10.0, 20.0, 30.0, 40.0, 50.0];
let histogram = EquiDepthHistogram::build(&values, 4);
// Estimate selectivity for age > 25
let selectivity = histogram.range_selectivity(Some(25.0), None);Implementations§
Source§impl EquiDepthHistogram
impl EquiDepthHistogram
Sourcepub fn new(buckets: Vec<HistogramBucket>) -> Self
pub fn new(buckets: Vec<HistogramBucket>) -> Self
Creates a new histogram from pre-built buckets.
Sourcepub fn num_buckets(&self) -> usize
pub fn num_buckets(&self) -> usize
Returns the number of buckets in this histogram.
Sourcepub fn total_rows(&self) -> u64
pub fn total_rows(&self) -> u64
Returns the total number of rows represented.
Sourcepub fn buckets(&self) -> &[HistogramBucket]
pub fn buckets(&self) -> &[HistogramBucket]
Returns the histogram buckets.
Sourcepub fn equality_selectivity(&self, value: f64) -> f64
pub fn equality_selectivity(&self, value: f64) -> f64
Estimates selectivity for an equality predicate.
Uses the distinct count within matching buckets for better accuracy.
Trait Implementations§
Source§impl Clone for EquiDepthHistogram
impl Clone for EquiDepthHistogram
Source§fn clone(&self) -> EquiDepthHistogram
fn clone(&self) -> EquiDepthHistogram
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for EquiDepthHistogram
impl RefUnwindSafe for EquiDepthHistogram
impl Send for EquiDepthHistogram
impl Sync for EquiDepthHistogram
impl Unpin for EquiDepthHistogram
impl UnwindSafe for EquiDepthHistogram
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
Mutably borrows from an owned value. Read more