pub struct ExprIntervalGraph { /* private fields */ }
Expand description

This object implements a directed acyclic expression graph (DAEG) that is used to compute ranges for expressions through interval arithmetic.

Implementations§

source§

impl ExprIntervalGraph

source

pub fn size(&self) -> usize

Estimate size of bytes including Self.

source§

impl ExprIntervalGraph

source

pub fn try_new(expr: Arc<dyn PhysicalExpr>) -> Result<Self>

source

pub fn node_count(&self) -> usize

source

pub fn gather_node_indices( &mut self, exprs: &[Arc<dyn PhysicalExpr>] ) -> Vec<(Arc<dyn PhysicalExpr>, usize)>

This function associates stable node indices with PhysicalExprs so that we can match Arc<dyn PhysicalExpr> and NodeIndex objects during membership tests.

source

pub fn assign_intervals(&mut self, assignments: &[(usize, Interval)])

This function assigns given ranges to expressions in the DAEG. The argument assignments associates indices of sought expressions with their corresponding new ranges.

source

pub fn update_intervals(&self, assignments: &mut [(usize, Interval)])

This function fetches ranges of expressions from the DAEG. The argument assignments associates indices of sought expressions with their ranges, which this function modifies to reflect the intervals in the DAEG.

source

pub fn evaluate_bounds(&mut self) -> Result<&Interval>

Computes bounds for an expression using interval arithmetic via a bottom-up traversal.

Arguments
  • leaf_bounds - &[(usize, Interval)]. Provide NodeIndex, Interval tuples for leaf variables.
Examples
 use std::sync::Arc;
 use datafusion_common::ScalarValue;
 use datafusion_expr::Operator;
 use datafusion_physical_expr::expressions::{BinaryExpr, Column, Literal};
 use datafusion_physical_expr::intervals::{Interval, IntervalBound, ExprIntervalGraph};
 use datafusion_physical_expr::PhysicalExpr;
 let expr = Arc::new(BinaryExpr::new(
            Arc::new(Column::new("gnz", 0)),
            Operator::Plus,
            Arc::new(Literal::new(ScalarValue::Int32(Some(10)))),
        ));
 let mut graph = ExprIntervalGraph::try_new(expr).unwrap();
 // Do it once, while constructing.
 let node_indices = graph
    .gather_node_indices(&[Arc::new(Column::new("gnz", 0))]);
 let left_index = node_indices.get(0).unwrap().1;
 // Provide intervals for leaf variables (here, there is only one).
 let intervals = vec![(
    left_index,
    Interval::make(Some(10), Some(20), (true, true)),
 )];
 // Evaluate bounds for the composite expression:
 graph.assign_intervals(&intervals);
 assert_eq!(
    graph.evaluate_bounds().unwrap(),
    &Interval::make(Some(20), Some(30), (true, true)),
 )
source

pub fn update_ranges( &mut self, leaf_bounds: &mut [(usize, Interval)] ) -> Result<PropagationResult>

Updates intervals for all expressions in the DAEG by successive bottom-up and top-down traversals.

source

pub fn get_interval(&self, index: usize) -> Interval

Returns the interval associated with the node at the given index.

Trait Implementations§

source§

impl Clone for ExprIntervalGraph

source§

fn clone(&self) -> ExprIntervalGraph

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 ExprIntervalGraph

source§

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

Formats the value using the given formatter. Read more

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<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, 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