pub trait TreeNodeRewritable: Clone {
    fn map_children<F>(self, transform: F) -> Result<Self>
    where
        F: FnMut(Self) -> Result<Self>
; fn transform_using<R: TreeNodeRewriter<Self>>(
        self,
        rewriter: &mut R
    ) -> Result<Self> { ... } fn transform<F>(self, op: &F) -> Result<Self>
    where
        F: Fn(Self) -> Result<Option<Self>>
, { ... } fn transform_down<F>(self, op: &F) -> Result<Self>
    where
        F: Fn(Self) -> Result<Option<Self>>
, { ... } fn transform_up<F>(self, op: &F) -> Result<Self>
    where
        F: Fn(Self) -> Result<Option<Self>>
, { ... } }
Expand description

a Trait for marking tree node types that are rewritable

Required Methods§

source

fn map_children<F>(self, transform: F) -> Result<Self>where
    F: FnMut(Self) -> Result<Self>,

Apply transform F to the node’s children, the transform F might have a direction(Preorder or Postorder)

Provided Methods§

source

fn transform_using<R: TreeNodeRewriter<Self>>(
    self,
    rewriter: &mut R
) -> Result<Self>

Transform the tree node using the given TreeNodeRewriter It performs a depth first walk of an node and its children.

For an node tree such as

ParentNode
   left: ChildNode1
   right: ChildNode2

The nodes are visited using the following order

pre_visit(ParentNode)
pre_visit(ChildNode1)
mutate(ChildNode1)
pre_visit(ChildNode2)
mutate(ChildNode2)
mutate(ParentNode)

If an Err result is returned, recursion is stopped immediately

If false is returned on a call to pre_visit, no children of that node are visited, nor is mutate called on that node

source

fn transform<F>(self, op: &F) -> Result<Self>where
    F: Fn(Self) -> Result<Option<Self>>,

Convenience utils for writing optimizers rule: recursively apply the given op to the node tree. When op does not apply to a given node, it is left unchanged. The default tree traversal direction is transform_up(Postorder Traversal).

source

fn transform_down<F>(self, op: &F) -> Result<Self>where
    F: Fn(Self) -> Result<Option<Self>>,

Convenience utils for writing optimizers rule: recursively apply the given ‘op’ to the node and all of its children(Preorder Traversal). When the op does not apply to a given node, it is left unchanged.

source

fn transform_up<F>(self, op: &F) -> Result<Self>where
    F: Fn(Self) -> Result<Option<Self>>,

Convenience utils for writing optimizers rule: recursively apply the given ‘op’ first to all of its children and then itself(Postorder Traversal). When the op does not apply to a given node, it is left unchanged.

Implementations on Foreign Types§

source§

impl TreeNodeRewritable for Arc<dyn PhysicalExpr>

source§

fn map_children<F>(self, transform: F) -> Result<Self>where
    F: FnMut(Self) -> Result<Self>,

Implementors§