pub struct Interval {
pub lower: IntervalBound,
pub upper: IntervalBound,
}
Expand description
This type represents an interval, which is used to calculate reliable bounds for expressions. Currently, we only support addition and subtraction, but more capabilities will be added in the future. Upper/lower bounds having NULL values indicate an unbounded side. For example; [10, 20], [10, ∞), (-∞, 100] and (-∞, ∞) are all valid intervals.
Fields§
§lower: IntervalBound
§upper: IntervalBound
Implementations§
source§impl Interval
impl Interval
sourcepub fn new(lower: IntervalBound, upper: IntervalBound) -> Interval
pub fn new(lower: IntervalBound, upper: IntervalBound) -> Interval
Creates a new interval object using the given bounds. For boolean intervals, having an open false lower bound is equivalent to having a true closed lower bound. Similarly, open true upper bound is equivalent to having a false closed upper bound. Also for boolean intervals, having an unbounded left endpoint is equivalent to having a false closed lower bound, while having an unbounded right endpoint is equivalent to having a true closed upper bound. Therefore; input parameters to construct an Interval can have different types, but they all result in [false, false], [false, true] or [true, true].
pub fn make<T>( lower: Option<T>, upper: Option<T>, open: (bool, bool) ) -> Intervalwhere ScalarValue: From<Option<T>>,
sourcepub fn get_datatype(&self) -> Result<DataType>
pub fn get_datatype(&self) -> Result<DataType>
This function returns the data type of this interval. If both endpoints do not have the same data type, returns an error.
sourcepub fn add<T: Borrow<Interval>>(&self, other: T) -> Result<Interval>
pub fn add<T: Borrow<Interval>>(&self, other: T) -> Result<Interval>
Add the given interval (other
) to this interval. Say we have
intervals [a1, b1] and [a2, b2], then their sum is [a1 + a2, b1 + b2].
Note that this represents all possible values the sum can take if
one can choose single values arbitrarily from each of the operands.
sourcepub fn sub<T: Borrow<Interval>>(&self, other: T) -> Result<Interval>
pub fn sub<T: Borrow<Interval>>(&self, other: T) -> Result<Interval>
Subtract the given interval (other
) from this interval. Say we have
intervals [a1, b1] and [a2, b2], then their sum is [a1 - b2, b1 - a2].
Note that this represents all possible values the difference can take
if one can choose single values arbitrarily from each of the operands.
pub const CERTAINLY_FALSE: Interval = _
pub const UNCERTAIN: Interval = _
pub const CERTAINLY_TRUE: Interval = _
sourcepub fn cardinality(&self) -> Result<u64>
pub fn cardinality(&self) -> Result<u64>
Returns the cardinality of this interval, which is the number of all distinct points inside it.
sourcepub fn close_bounds(self) -> Interval
pub fn close_bounds(self) -> Interval
This function “closes” this interval; i.e. it modifies the endpoints so that we end up with the narrowest possible closed interval containing the original interval.
Trait Implementations§
source§impl PartialEq<Interval> for Interval
impl PartialEq<Interval> for Interval
impl Eq for Interval
impl StructuralEq for Interval
impl StructuralPartialEq for Interval
Auto Trait Implementations§
impl RefUnwindSafe for Interval
impl Send for Interval
impl Sync for Interval
impl Unpin for Interval
impl UnwindSafe for Interval
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
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.