risingwave_frontend::utils

Trait Endo

source
pub trait Endo<T: Tree> {
    // Required method
    fn apply(&mut self, t: T) -> T;

    // Provided methods
    fn pre(&mut self, t: T) -> T { ... }
    fn post(&mut self, t: T) -> T { ... }
    fn tree_apply(&mut self, t: T) -> T { ... }
}
Expand description

Given a tree-like structure T, we usually can specify a transformation T -> T by providing a pre-order transformation pre : T -> T and a post-order transformation post : T -> T. Specifically, the derived transformation apply : T -> T first applies pre, then maps itself over the subtrees, and finally applies post. This allows us to obtain a global transformation acting recursively on all levels by specifying simpler transformations at acts locally.

Required Methods§

source

fn apply(&mut self, t: T) -> T

The real application function is left undefined. If we want the derived transformation we can simply call tree_apply in the implementation. But for more complicated requirements, e.g. skipping over certain subtrees, custom logic can be added.

Provided Methods§

source

fn pre(&mut self, t: T) -> T

source

fn post(&mut self, t: T) -> T

source

fn tree_apply(&mut self, t: T) -> T

The derived transformation based on pre and post.

Implementors§

source§

impl Endo<PlanRef> for Pruner<'_>

source§

impl<V: Hash + Eq> Endo<PlanRef> for Merger<V>
where PlanRef: Semantics<V>,