Skip to main content

OptimizableExpr

Trait OptimizableExpr 

Source
pub trait OptimizableExpr:
    Columns
    + VisitChildren<Self>
    + Clone
    + Eq
    + Ord
    + Hash
    + Debug
    + Sized
    + Serialize {
    // Required methods
    fn is_literal(&self) -> bool;
    fn is_literal_err(&self) -> bool;
    fn contains_temporal(&self) -> bool;
    fn size(&self) -> usize;
    fn eager_children(&mut self) -> Option<Vec<&mut Self>>;
    fn equality_column_alias(
        predicate: &Self,
        expr: &Self,
        threshold: usize,
    ) -> Option<Self>;
    fn extract_temporal_bounds(
        temporal: Vec<Self>,
    ) -> Result<(Vec<Self>, Vec<Self>), String>;

    // Provided method
    fn visit_pre<F>(&self, f: &mut F) -> Result<(), RecursionLimitError>
       where F: FnMut(&Self) { ... }
}
Expand description

A scalar expression type that can be optimized inside a MapFilterProject.

Implemented by MirScalarExpr and LirScalarExpr.

Required Methods§

Source

fn is_literal(&self) -> bool

True if this expression is a literal.

Source

fn is_literal_err(&self) -> bool

True if this expression is a literal error.

Source

fn contains_temporal(&self) -> bool

True if this expression contains a temporal reference (mz_now()).

Source

fn size(&self) -> usize

Count of AST nodes in the expression tree.

Source

fn eager_children(&mut self) -> Option<Vec<&mut Self>>

For memoization: which children should be eagerly memoized?

Returns None to visit all children (the common case). Returns Some(children) for selective descent — e.g., for If, only the condition should be eagerly memoized (branches may not be taken).

Source

fn equality_column_alias( predicate: &Self, expr: &Self, threshold: usize, ) -> Option<Self>

If predicate is col = expr (or expr = col) where col is a column with index < threshold, return a clone of that column expression.

Used by optimize() to detect equality-derived column aliases.

Source

fn extract_temporal_bounds( temporal: Vec<Self>, ) -> Result<(Vec<Self>, Vec<Self>), String>

Extract temporal bounds from a list of temporal predicates.

Returns (lower_bounds, upper_bounds) for use in MfpPlan.

Provided Methods§

Source

fn visit_pre<F>(&self, f: &mut F) -> Result<(), RecursionLimitError>
where F: FnMut(&Self),

Visit in a pre-traversal. Defaults to the Visit implementation, but overridable.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§