Skip to main content

ReduceNode

Trait ReduceNode 

Source
pub trait ReduceNode: Clone {
    // Required methods
    fn node_dtype(&self) -> VortexResult<DType>;
    fn scalar_fn(&self) -> Option<&ScalarFnRef>;
    fn child(&self, idx: usize) -> Self;
    fn child_count(&self) -> usize;
    fn new_node(
        &self,
        scalar_fn: ScalarFnRef,
        children: &[Self],
    ) -> VortexResult<Self>;
    fn new_constant(&self, value: Scalar) -> Self;
    fn validity(&self) -> VortexResult<ReduceNodeValidity<Self>>
       where Self: Sized;

    // Provided method
    fn as_constant(&self) -> Option<Scalar> { ... }
}
Expand description

A node used for implementing abstract reduction rules over a tree of scalar functions.

Reduction rules are generic over the node type, so a rule is written once and monomorphized per reducible tree kind: ExpressionReduceNode for bound expression trees and ArrayReduceNode for array trees. Nodes borrow from the tree being reduced, making traversal allocation-free, while nodes produced by ReduceNode::new_node own their freshly-built subtrees.

Required Methods§

Source

fn node_dtype(&self) -> VortexResult<DType>

Return the data type of this node.

Source

fn scalar_fn(&self) -> Option<&ScalarFnRef>

Return this node’s scalar function if it is indeed a scalar fn.

Source

fn child(&self, idx: usize) -> Self

Descend to the child of this node.

Source

fn child_count(&self) -> usize

Returns the number of children of this node.

Source

fn new_node( &self, scalar_fn: ScalarFnRef, children: &[Self], ) -> VortexResult<Self>

Create a new node from the given scalar function and children, inheriting this node’s reduction context (e.g. the expression scope, or the array row count).

Source

fn new_constant(&self, value: Scalar) -> Self

Produce a new constant node in the same scope as “self”

Source

fn validity(&self) -> VortexResult<ReduceNodeValidity<Self>>
where Self: Sized,

Symbolic validity of this node. Reduced() if you can get from node’s validity to validity of its children or a constant without evaluating node.

Provided Methods§

Source

fn as_constant(&self) -> Option<Scalar>

Return a scalar value if this node is constant

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§