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 } diff --git a/vortex-array/src/arrays/scalar_fn/rules.rs b/vortex-array/src/arrays/scalar_fn/rules.rs index 4cc3b5b79bd..d95bac016c4 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,29 @@ impl ArrayReduceRule for ScalarFnAbstractReduceRule { } } +impl ReduceNode for ScalarFnArray { + fn as_any(&self) -> &dyn Any { + self + } + + fn node_dtype(&self) -> VortexResult { + Ok(self.dtype().clone()) + } + + #[allow(clippy::same_name_method)] + 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 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() }