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>, schema: &Schema ) -> Result<ExprIntervalGraph, DataFusionError>

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 update_ranges( &mut self, leaf_bounds: &mut [(usize, Interval)], given_range: Interval ) -> Result<PropagationResult, DataFusionError>

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

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

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 arrow::datatypes::DataType;
use arrow::datatypes::Field;
use arrow::datatypes::Schema;
use datafusion_common::ScalarValue;
use datafusion_expr::interval_arithmetic::Interval;
use datafusion_expr::Operator;
use datafusion_physical_expr::expressions::{BinaryExpr, Column, Literal};
use datafusion_physical_expr::intervals::cp_solver::ExprIntervalGraph;
use datafusion_physical_expr::PhysicalExpr;
use std::sync::Arc;

let expr = Arc::new(BinaryExpr::new(
    Arc::new(Column::new("gnz", 0)),
    Operator::Plus,
    Arc::new(Literal::new(ScalarValue::Int32(Some(10)))),
));

let schema = Schema::new(vec![Field::new("gnz".to_string(), DataType::Int32, true)]);

let mut graph = ExprIntervalGraph::try_new(expr, &schema).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)).unwrap(),
)];

// Evaluate bounds for the composite expression:
graph.assign_intervals(&intervals);
assert_eq!(
    graph.evaluate_bounds().unwrap(),
    &Interval::make(Some(20), Some(30)).unwrap(),
)
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<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where 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 T
where 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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where 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 T
where 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 T
where 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.
source§

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

source§

fn vzip(self) -> V