ParentReduceRule

Trait ParentReduceRule 

Source
pub trait ParentReduceRule<Child: VTable, Parent: Matcher, C: RewriteContext>:
    Debug
    + Send
    + Sync
    + 'static {
    // Required method
    fn reduce_parent(
        &self,
        expr: &ExpressionView<'_, Child>,
        parent: Parent::View<'_>,
        child_idx: usize,
        ctx: &C,
    ) -> VortexResult<Option<Expression>>;
}
Expand description

A rewrite rule that can transform expressions based on parent context.

Called during top-down traversal from the root. This is useful for rules that need to know about the parent expression.

Note: This rule is only called for non-root expressions (i.e., when there is a parent).

§Type Parameters

  • Child - The VTable type this rule applies to (the child expression type). The rule will only be invoked for expressions with this vtable type, providing compile-time type safety.
  • Parent - The parent matcher. Can be a specific VTable type (e.g., Binary) for typed parent access, or AnyParent to match any parent type with untyped access.
  • C - The rewrite context type (RuleContext or TypedRuleContext)

Required Methods§

Source

fn reduce_parent( &self, expr: &ExpressionView<'_, Child>, parent: Parent::View<'_>, child_idx: usize, ctx: &C, ) -> VortexResult<Option<Expression>>

Try to rewrite an expression based on its parent.

§Arguments
  • expr - The expression to potentially rewrite (already downcast to type Child)
  • parent - The parent view (type depends on Parent matcher - typed for specific VTables, untyped &Expression for AnyParent)
  • child_idx - The index of the child expression within the parent.
  • ctx - Context for the rewrite (dtype, etc.)
§Returns
  • Some(new_expr) if the rule applies and produces a rewritten expression
  • None if the rule does not apply

Implementors§