Struct mz_expr::ResultSpec
source · pub struct ResultSpec<'a> {
nullable: bool,
fallible: bool,
values: Values<'a>,
}
Expand description
An approximation of the set of values an expression might have, including whether or not it might be null or an error value. This is generally an overapproximation, in the sense that ResultSpec::may_contain may return true even if the argument is not included in the set. (However, it should never return false when the value is included!)
Fields§
§nullable: bool
True if the expression may evaluate to Datum::Null.
fallible: bool
True if the expression may evaluate to an error.
values: Values<'a>
The range of possible (non-null) values that the expression may evaluate to.
Implementations§
source§impl<'a> ResultSpec<'a>
impl<'a> ResultSpec<'a>
sourcepub fn any_infallible() -> Self
pub fn any_infallible() -> Self
Every result matches this spec.
sourcepub fn has_type(col: &ColumnType, fallible: bool) -> ResultSpec<'a>
pub fn has_type(col: &ColumnType, fallible: bool) -> ResultSpec<'a>
A spec that matches all values of a given type.
sourcepub fn value(value: Datum<'a>) -> ResultSpec<'a>
pub fn value(value: Datum<'a>) -> ResultSpec<'a>
A spec that only matches the given value.
sourcepub fn value_between(min: Datum<'a>, max: Datum<'a>) -> ResultSpec<'a>
pub fn value_between(min: Datum<'a>, max: Datum<'a>) -> ResultSpec<'a>
A spec that matches values between the given (non-null) min and max.
sourcepub fn value_all() -> ResultSpec<'a>
pub fn value_all() -> ResultSpec<'a>
A spec that matches any non-null value.
sourcepub fn map_spec(map: BTreeMap<Datum<'a>, ResultSpec<'a>>) -> ResultSpec<'a>
pub fn map_spec(map: BTreeMap<Datum<'a>, ResultSpec<'a>>) -> ResultSpec<'a>
A spec that matches Datum::Maps of the given type.
sourcepub fn union(self, other: ResultSpec<'a>) -> ResultSpec<'a>
pub fn union(self, other: ResultSpec<'a>) -> ResultSpec<'a>
Given two specs, returns a new spec that matches anything that either original spec would match.
sourcepub fn intersect(self, other: ResultSpec<'a>) -> ResultSpec<'a>
pub fn intersect(self, other: ResultSpec<'a>) -> ResultSpec<'a>
Given two specs, returns a new spec that only matches things that both original specs would match.
sourcepub fn may_contain(&self, value: Datum<'a>) -> bool
pub fn may_contain(&self, value: Datum<'a>) -> bool
Check if a particular value matches the spec.
sourcefn flat_map(
&self,
is_monotone: bool,
result_map: impl FnMut(Result<Datum<'a>, EvalError>) -> ResultSpec<'a>,
) -> ResultSpec<'a>
fn flat_map( &self, is_monotone: bool, result_map: impl FnMut(Result<Datum<'a>, EvalError>) -> ResultSpec<'a>, ) -> ResultSpec<'a>
This method “maps” a function across the ResultSpec
.
As mentioned above, ResultSpec
represents an approximate set of results.
If we actually stored each result in the set, flat_map
could be implemented by passing
each result to the function one-by-one and unioning the resulting sets. This is possible
when our values set is empty or contains a single datum, but when it contains a range,
we can’t enumerate all possible values of the set. We handle this by:
- tracking whether the function is monotone, in which case we can map the range by just mapping the endpoints;
- using a safe default when we can’t infer a tighter bound on the set, eg. Self::anything.
Trait Implementations§
source§impl<'a> Clone for ResultSpec<'a>
impl<'a> Clone for ResultSpec<'a>
source§fn clone(&self) -> ResultSpec<'a>
fn clone(&self) -> ResultSpec<'a>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<'a> Debug for ResultSpec<'a>
impl<'a> Debug for ResultSpec<'a>
source§impl<'a> PartialEq for ResultSpec<'a>
impl<'a> PartialEq for ResultSpec<'a>
impl<'a> Eq for ResultSpec<'a>
impl<'a> StructuralPartialEq for ResultSpec<'a>
Auto Trait Implementations§
impl<'a> Freeze for ResultSpec<'a>
impl<'a> RefUnwindSafe for ResultSpec<'a>
impl<'a> Send for ResultSpec<'a>
impl<'a> Sync for ResultSpec<'a>
impl<'a> Unpin for ResultSpec<'a>
impl<'a> UnwindSafe for ResultSpec<'a>
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§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default 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§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.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.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<T> FutureExt for T
impl<T> FutureExt for T
source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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> 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
source§impl<T, U> OverrideFrom<Option<&T>> for Uwhere
U: OverrideFrom<T>,
impl<T, U> OverrideFrom<Option<&T>> for Uwhere
U: OverrideFrom<T>,
source§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<T> ProgressEventTimestamp for T
impl<T> ProgressEventTimestamp for T
source§impl<P, R> ProtoType<R> for Pwhere
R: RustType<P>,
impl<P, R> ProtoType<R> for Pwhere
R: RustType<P>,
source§fn into_rust(self) -> Result<R, TryFromProtoError>
fn into_rust(self) -> Result<R, TryFromProtoError>
RustType::from_proto
.source§fn from_rust(rust: &R) -> P
fn from_rust(rust: &R) -> P
RustType::into_proto
.source§impl<'a, S, T> Semigroup<&'a S> for Twhere
T: Semigroup<S>,
impl<'a, S, T> Semigroup<&'a S> for Twhere
T: Semigroup<S>,
source§fn plus_equals(&mut self, rhs: &&'a S)
fn plus_equals(&mut self, rhs: &&'a S)
std::ops::AddAssign
, for types that do not implement AddAssign
.