Skip to main content

Expression

Trait Expression 

Source
pub trait Expression:
    Debug
    + Sync
    + Send {
    // Required methods
    fn return_type(&self) -> DataType;
    fn eval_row<'life0, 'life1, 'async_trait>(
        &'life0 self,
        input: &'life1 OwnedRow,
    ) -> Pin<Box<dyn Future<Output = Result<Datum>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided methods
    fn eval<'life0, 'life1, 'async_trait>(
        &'life0 self,
        input: &'life1 DataChunk,
    ) -> Pin<Box<dyn Future<Output = Result<ArrayRef>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn eval_v2<'life0, 'life1, 'async_trait>(
        &'life0 self,
        input: &'life1 DataChunk,
    ) -> Pin<Box<dyn Future<Output = Result<ValueImpl>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn eval_const(&self) -> Result<Datum> { ... }
    fn input_ref_index(&self) -> Option<usize> { ... }
}
Expand description

Interface of an expression.

There’re two functions to evaluate an expression: eval and eval_v2, exactly one of them should be implemented. Prefer calling and implementing eval_v2 instead of eval if possible, to gain the performance benefit of scalar expression.

Required Methods§

Source

fn return_type(&self) -> DataType

Get the return data type.

Source

fn eval_row<'life0, 'life1, 'async_trait>( &'life0 self, input: &'life1 OwnedRow, ) -> Pin<Box<dyn Future<Output = Result<Datum>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Evaluate the expression in row-based execution. Returns a nullable scalar.

Provided Methods§

Source

fn eval<'life0, 'life1, 'async_trait>( &'life0 self, input: &'life1 DataChunk, ) -> Pin<Box<dyn Future<Output = Result<ArrayRef>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Evaluate the expression in vectorized execution. Returns an array.

The default implementation calls eval_v2 and always converts the result to an array.

Source

fn eval_v2<'life0, 'life1, 'async_trait>( &'life0 self, input: &'life1 DataChunk, ) -> Pin<Box<dyn Future<Output = Result<ValueImpl>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Evaluate the expression in vectorized execution. Returns a value that can be either an array, or a scalar if all values in the array are the same.

The default implementation calls eval and puts the result into the Array variant.

Source

fn eval_const(&self) -> Result<Datum>

Evaluate if the expression is constant.

Source

fn input_ref_index(&self) -> Option<usize>

Get the index if the expression is an InputRef.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl<'a, T: 'a + Expression + ?Sized> Expression for &'a T
where &'a T: Debug + Sync + Send,

Source§

fn return_type(&self) -> DataType

Source§

fn eval<'life0, 'life1, 'async_trait>( &'life0 self, input: &'life1 DataChunk, ) -> Pin<Box<dyn Future<Output = Result<ArrayRef>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn eval_v2<'life0, 'life1, 'async_trait>( &'life0 self, input: &'life1 DataChunk, ) -> Pin<Box<dyn Future<Output = Result<ValueImpl>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn eval_row<'life0, 'life1, 'async_trait>( &'life0 self, input: &'life1 OwnedRow, ) -> Pin<Box<dyn Future<Output = Result<Datum>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn eval_const(&self) -> Result<Datum>

Source§

fn input_ref_index(&self) -> Option<usize>

Source§

impl<T: Expression + ?Sized> Expression for Box<T>
where Box<T>: Debug + Sync + Send,

Source§

fn return_type(&self) -> DataType

Source§

fn eval<'life0, 'life1, 'async_trait>( &'life0 self, input: &'life1 DataChunk, ) -> Pin<Box<dyn Future<Output = Result<ArrayRef>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn eval_v2<'life0, 'life1, 'async_trait>( &'life0 self, input: &'life1 DataChunk, ) -> Pin<Box<dyn Future<Output = Result<ValueImpl>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn eval_row<'life0, 'life1, 'async_trait>( &'life0 self, input: &'life1 OwnedRow, ) -> Pin<Box<dyn Future<Output = Result<Datum>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn eval_const(&self) -> Result<Datum>

Source§

fn input_ref_index(&self) -> Option<usize>

Implementors§