pub enum Precision<T: Debug + Clone + PartialEq + Eq + PartialOrd> {
Exact(T),
Inexact(T),
Absent,
}
Expand description
Represents a value with a degree of certainty. Precision
is used to
propagate information the precision of statistical values.
Variants§
Exact(T)
The exact value is known
Inexact(T)
The value is not known exactly, but is likely close to this value
Absent
Nothing is known about the value
Implementations§
Source§impl<T: Debug + Clone + PartialEq + Eq + PartialOrd> Precision<T>
impl<T: Debug + Clone + PartialEq + Eq + PartialOrd> Precision<T>
Sourcepub fn get_value(&self) -> Option<&T>
pub fn get_value(&self) -> Option<&T>
If we have some value (exact or inexact), it returns that value.
Otherwise, it returns None
.
Sourcepub fn map<U, F>(self, f: F) -> Precision<U>
pub fn map<U, F>(self, f: F) -> Precision<U>
Transform the value in this Precision
object, if one exists, using
the given function. Preserves the exactness state.
Sourcepub fn is_exact(&self) -> Option<bool>
pub fn is_exact(&self) -> Option<bool>
Returns Some(true)
if we have an exact value, Some(false)
if we
have an inexact value, and None
if there is no value.
Sourcepub fn max(&self, other: &Precision<T>) -> Precision<T>
pub fn max(&self, other: &Precision<T>) -> Precision<T>
Returns the maximum of two (possibly inexact) values, conservatively
propagating exactness information. If one of the input values is
Precision::Absent
, the result is Absent
too.
Sourcepub fn min(&self, other: &Precision<T>) -> Precision<T>
pub fn min(&self, other: &Precision<T>) -> Precision<T>
Returns the minimum of two (possibly inexact) values, conservatively
propagating exactness information. If one of the input values is
Precision::Absent
, the result is Absent
too.
Sourcepub fn to_inexact(self) -> Self
pub fn to_inexact(self) -> Self
Demotes the precision state from exact to inexact (if present).
Source§impl Precision<usize>
impl Precision<usize>
Sourcepub fn add(&self, other: &Precision<usize>) -> Precision<usize>
pub fn add(&self, other: &Precision<usize>) -> Precision<usize>
Calculates the sum of two (possibly inexact) usize
values,
conservatively propagating exactness information. If one of the input
values is Precision::Absent
, the result is Absent
too.
Sourcepub fn sub(&self, other: &Precision<usize>) -> Precision<usize>
pub fn sub(&self, other: &Precision<usize>) -> Precision<usize>
Calculates the difference of two (possibly inexact) usize
values,
conservatively propagating exactness information. If one of the input
values is Precision::Absent
, the result is Absent
too.
Sourcepub fn multiply(&self, other: &Precision<usize>) -> Precision<usize>
pub fn multiply(&self, other: &Precision<usize>) -> Precision<usize>
Calculates the multiplication of two (possibly inexact) usize
values,
conservatively propagating exactness information. If one of the input
values is Precision::Absent
, the result is Absent
too.
Sourcepub fn with_estimated_selectivity(self, selectivity: f64) -> Self
pub fn with_estimated_selectivity(self, selectivity: f64) -> Self
Return the estimate of applying a filter with estimated selectivity
selectivity
to this Precision. A selectivity of 1.0
means that all
rows are selected. A selectivity of 0.5
means half the rows are
selected. Will always return inexact statistics.
Source§impl Precision<ScalarValue>
impl Precision<ScalarValue>
Sourcepub fn add(&self, other: &Precision<ScalarValue>) -> Precision<ScalarValue>
pub fn add(&self, other: &Precision<ScalarValue>) -> Precision<ScalarValue>
Calculates the sum of two (possibly inexact) ScalarValue
values,
conservatively propagating exactness information. If one of the input
values is Precision::Absent
, the result is Absent
too.
Trait Implementations§
impl<T: Copy + Debug + Clone + PartialEq + Eq + PartialOrd> Copy for Precision<T>
impl<T: Eq + Debug + Clone + PartialEq + Eq + PartialOrd> Eq for Precision<T>
impl<T: Debug + Clone + PartialEq + Eq + PartialOrd> StructuralPartialEq for Precision<T>
Auto Trait Implementations§
impl<T> Freeze for Precision<T>where
T: Freeze,
impl<T> RefUnwindSafe for Precision<T>where
T: RefUnwindSafe,
impl<T> Send for Precision<T>where
T: Send,
impl<T> Sync for Precision<T>where
T: Sync,
impl<T> Unpin for Precision<T>where
T: Unpin,
impl<T> UnwindSafe for Precision<T>where
T: UnwindSafe,
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.