diff --git a/src/expr/src/expr/expr_literal.rs b/src/expr/src/expr/expr_literal.rs index 7235c477d5f8e..ae0e73b1169e7 100644 --- a/src/expr/src/expr/expr_literal.rs +++ b/src/expr/src/expr/expr_literal.rs @@ -38,7 +38,7 @@ impl Expression for LiteralExpression { self.return_type.clone() } - async fn eval_new(&self, input: &DataChunk) -> Result { + async fn eval_v2(&self, input: &DataChunk) -> Result { Ok(ValueImpl::Scalar { value: self.literal.clone(), capacity: input.capacity(), diff --git a/src/expr/src/expr/mod.rs b/src/expr/src/expr/mod.rs index 7a1c015643f39..5aac6f0a0c3b2 100644 --- a/src/expr/src/expr/mod.rs +++ b/src/expr/src/expr/mod.rs @@ -83,8 +83,8 @@ use super::{ExprError, Result}; /// Interface of an expression. /// -/// There're two functions to evaluate an expression: `eval` and `eval_new`, exactly one of them -/// should be implemented. Prefer calling and implementing `eval_new` instead of `eval` if possible, +/// 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. #[async_trait::async_trait] pub trait Expression: std::fmt::Debug + Sync + Send { @@ -103,9 +103,9 @@ pub trait Expression: std::fmt::Debug + Sync + Send { /// Evaluate the expression in vectorized execution. Returns an array. /// - /// The default implementation calls `eval_new` and always converts the result to an array. + /// The default implementation calls `eval_v2` and always converts the result to an array. async fn eval(&self, input: &DataChunk) -> Result { - let value = self.eval_new(input).await?; + let value = self.eval_v2(input).await?; Ok(match value { ValueImpl::Array(array) => array, ValueImpl::Scalar { value, capacity } => { @@ -120,7 +120,7 @@ pub trait Expression: std::fmt::Debug + Sync + Send { /// 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. - async fn eval_new(&self, input: &DataChunk) -> Result { + async fn eval_v2(&self, input: &DataChunk) -> Result { self.eval(input).map_ok(ValueImpl::Array).await } diff --git a/src/expr/src/expr/template.rs b/src/expr/src/expr/template.rs index cbf9a4ff008a9..3f6e94484d6c2 100644 --- a/src/expr/src/expr/template.rs +++ b/src/expr/src/expr/template.rs @@ -21,7 +21,7 @@ use std::sync::Arc; use itertools::{multizip, Itertools}; use paste::paste; -use risingwave_common::array::{Array, ArrayBuilder, ArrayImpl, DataChunk, Utf8Array}; +use risingwave_common::array::{Array, ArrayBuilder, DataChunk, Utf8Array}; use risingwave_common::row::OwnedRow; use risingwave_common::types::{option_as_scalar_ref, DataType, Datum, Scalar}; use risingwave_common::util::iter_util::ZipEqDebug; @@ -30,7 +30,7 @@ use crate::expr::{BoxedExpression, Expression, ValueImpl, ValueRef}; macro_rules! gen_eval { { ($macro:ident, $macro_row:ident), $ty_name:ident, $OA:ty, $($arg:ident,)* } => { - fn eval_new<'a, 'b, 'async_trait>(&'a self, data_chunk: &'b DataChunk) + fn eval_v2<'a, 'b, 'async_trait>(&'a self, data_chunk: &'b DataChunk) -> Pin> + Send + 'async_trait>> where 'a: 'async_trait, @@ -38,7 +38,7 @@ macro_rules! gen_eval { { Box::pin(async move { paste! { $( - let [] = self.[].eval_new(data_chunk).await?; + let [] = self.[].eval_v2(data_chunk).await?; let []: ValueRef<'_, $arg> = (&[]).into(); )* @@ -58,7 +58,6 @@ macro_rules! gen_eval { } // Otherwise, fallback to array computation. - // TODO: match all possible combinations to further get rid of the overhead of `Either` iterators. ($([], )*) => { let bitmap = data_chunk.visibility(); let mut output_array = <$OA as Array>::Builder::with_meta(data_chunk.capacity(), (&self.return_type).into());