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

source

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].

source

pub fn make<T>( lower: Option<T>, upper: Option<T>, open: (bool, bool) ) -> Intervalwhere ScalarValue: From<Option<T>>,

source

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.

source

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.

source

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.

source

pub const CERTAINLY_FALSE: Interval = _

source

pub const UNCERTAIN: Interval = _

source

pub const CERTAINLY_TRUE: Interval = _

source

pub fn cardinality(&self) -> Result<u64>

Returns the cardinality of this interval, which is the number of all distinct points inside it.

source

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 Clone for Interval

source§

fn clone(&self) -> Interval

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Interval

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Interval

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Display for Interval

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq<Interval> for Interval

source§

fn eq(&self, other: &Interval) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for Interval

source§

impl StructuralEq for Interval

source§

impl StructuralPartialEq for Interval

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> Allocation for Twhere T: RefUnwindSafe + Send + Sync,