Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions vortex-array/src/arrays/scalar_fn/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
32 changes: 27 additions & 5 deletions vortex-array/src/arrays/scalar_fn/rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,10 @@ impl ArrayReduceRule<ScalarFnVTable> for ScalarFnConstantRule {
struct ScalarFnAbstractReduceRule;
impl ArrayReduceRule<ScalarFnVTable> for ScalarFnAbstractReduceRule {
fn reduce(&self, array: &ScalarFnArray) -> VortexResult<Option<ArrayRef>> {
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()
Expand All @@ -107,6 +106,29 @@ impl ArrayReduceRule<ScalarFnVTable> for ScalarFnAbstractReduceRule {
}
}

impl ReduceNode for ScalarFnArray {
fn as_any(&self) -> &dyn Any {
self
}

fn node_dtype(&self) -> VortexResult<DType> {
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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a followup that maybe lets us remove this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do need this just like we need impl Array for Arc<dyn Array>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When do we pull the trigger on Array vtable that lets us access &self within the Arc.

It should come with a lot of performance

fn as_any(&self) -> &dyn Any {
self
Expand Down
1 change: 1 addition & 0 deletions vortex-array/src/expr/vtable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ReduceNodeRef> {
(0..self.child_count()).map(|i| self.child(i)).collect()
}
Expand Down
Loading