From 9749bd1785b06e094f40add475a739bbafcf228d Mon Sep 17 00:00:00 2001 From: Robert Kruszewski Date: Wed, 11 Feb 2026 17:20:28 +0000 Subject: [PATCH 1/4] Implement ReduceNode for ScalarFnArray to avoid boxing Signed-off-by: Robert Kruszewski --- vortex-array/src/arrays/scalar_fn/rules.rs | 31 ++++++++++++++++++---- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/vortex-array/src/arrays/scalar_fn/rules.rs b/vortex-array/src/arrays/scalar_fn/rules.rs index 4cc3b5b79bd..fea1cb6914b 100644 --- a/vortex-array/src/arrays/scalar_fn/rules.rs +++ b/vortex-array/src/arrays/scalar_fn/rules.rs @@ -90,11 +90,10 @@ impl ArrayReduceRule for ScalarFnConstantRule { struct ScalarFnAbstractReduceRule; impl ArrayReduceRule for ScalarFnAbstractReduceRule { fn reduce(&self, array: &ScalarFnArray) -> VortexResult> { - if let Some(reduced) = array.scalar_fn.reduce( - // Blergh, re-boxing - &array.to_array(), - &ArrayReduceCtx { len: array.len }, - )? { + if let Some(reduced) = array + .scalar_fn + .reduce(array, &ArrayReduceCtx { len: array.len })? + { return Ok(Some( reduced .as_any() @@ -107,6 +106,28 @@ impl ArrayReduceRule for ScalarFnAbstractReduceRule { } } +impl ReduceNode for ScalarFnArray { + fn as_any(&self) -> &dyn Any { + self + } + + fn node_dtype(&self) -> VortexResult { + Ok(self.dtype().clone()) + } + + fn scalar_fn(&self) -> Option<&ScalarFn> { + Some(ScalarFnArray::scalar_fn(self)) + } + + fn child(&self, idx: usize) -> ReduceNodeRef { + Arc::new(self.children()[idx].clone()) + } + + fn child_count(&self) -> usize { + self.children.len() + } +} + impl ReduceNode for ArrayRef { fn as_any(&self) -> &dyn Any { self From bb3af6e1f2236290634f44e8328ee6d812de838f Mon Sep 17 00:00:00 2001 From: Robert Kruszewski Date: Wed, 11 Feb 2026 17:42:15 +0000 Subject: [PATCH 2/4] allow Signed-off-by: Robert Kruszewski --- vortex-array/src/arrays/scalar_fn/rules.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/vortex-array/src/arrays/scalar_fn/rules.rs b/vortex-array/src/arrays/scalar_fn/rules.rs index fea1cb6914b..0548b3871d0 100644 --- a/vortex-array/src/arrays/scalar_fn/rules.rs +++ b/vortex-array/src/arrays/scalar_fn/rules.rs @@ -106,6 +106,7 @@ impl ArrayReduceRule for ScalarFnAbstractReduceRule { } } +#[allow(clippy::same_name_method)] impl ReduceNode for ScalarFnArray { fn as_any(&self) -> &dyn Any { self From 82f00e2badc60b56d4e1c34c1973a1521c411dbe Mon Sep 17 00:00:00 2001 From: Robert Kruszewski Date: Wed, 11 Feb 2026 17:45:22 +0000 Subject: [PATCH 3/4] allow Signed-off-by: Robert Kruszewski --- vortex-array/src/arrays/scalar_fn/rules.rs | 2 +- vortex-array/src/expr/vtable.rs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/vortex-array/src/arrays/scalar_fn/rules.rs b/vortex-array/src/arrays/scalar_fn/rules.rs index 0548b3871d0..d95bac016c4 100644 --- a/vortex-array/src/arrays/scalar_fn/rules.rs +++ b/vortex-array/src/arrays/scalar_fn/rules.rs @@ -106,7 +106,6 @@ impl ArrayReduceRule for ScalarFnAbstractReduceRule { } } -#[allow(clippy::same_name_method)] impl ReduceNode for ScalarFnArray { fn as_any(&self) -> &dyn Any { self @@ -116,6 +115,7 @@ impl ReduceNode for ScalarFnArray { Ok(self.dtype().clone()) } + #[allow(clippy::same_name_method)] fn scalar_fn(&self) -> Option<&ScalarFn> { Some(ScalarFnArray::scalar_fn(self)) } diff --git a/vortex-array/src/expr/vtable.rs b/vortex-array/src/expr/vtable.rs index 8bf9eee62f2..a1c5c4db46a 100644 --- a/vortex-array/src/expr/vtable.rs +++ b/vortex-array/src/expr/vtable.rs @@ -243,6 +243,7 @@ pub trait ReduceNode { fn child_count(&self) -> usize; /// Returns the children of this node. + #[allow(clippy::same_name_method)] fn children(&self) -> Vec { (0..self.child_count()).map(|i| self.child(i)).collect() } From 47d54777fb6a3798adaddd16c3b3bed21e05ef63 Mon Sep 17 00:00:00 2001 From: Robert Kruszewski Date: Wed, 11 Feb 2026 18:06:01 +0000 Subject: [PATCH 4/4] clippy Signed-off-by: Robert Kruszewski --- vortex-array/src/arrays/scalar_fn/array.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vortex-array/src/arrays/scalar_fn/array.rs b/vortex-array/src/arrays/scalar_fn/array.rs index 31cfd663c94..26422c1bc09 100644 --- a/vortex-array/src/arrays/scalar_fn/array.rs +++ b/vortex-array/src/arrays/scalar_fn/array.rs @@ -40,11 +40,13 @@ impl ScalarFnArray { } /// Get the scalar function bound to this array. + #[allow(clippy::same_name_method)] pub fn scalar_fn(&self) -> &ScalarFn { &self.scalar_fn } /// Get the children arrays of this scalar function array. + #[allow(clippy::same_name_method)] pub fn children(&self) -> &[ArrayRef] { &self.children }