peter-toth commented on code in PR #7942:
URL: https://github.com/apache/arrow-datafusion/pull/7942#discussion_r1432840105
##########
datafusion/common/src/tree_node.rs:
##########
@@ -289,15 +492,80 @@ pub enum RewriteRecursion {
Skip,
}
-/// Controls how the [`TreeNode`] recursion should proceed for
[`TreeNode::visit`].
+/// Controls how the [`TreeNode`] recursion should proceed for
[`TreeNode::visit_down()`] and
+/// [`TreeNode::visit()`].
#[derive(Debug)]
-pub enum VisitRecursion {
- /// Continue the visit to this node tree.
+pub enum TreeNodeRecursion {
+ /// Continue the visit to the next node.
Continue,
- /// Keep recursive but skip applying op on the children
- Skip,
- /// Stop the visit to this node tree.
+
+ /// Prune the current subtree.
+ /// If a preorder visit of a tree node returns
[`TreeNodeRecursion::Prune`] then inner
+ /// children and children will not be visited and postorder visit of the
node will not
+ /// be invoked.
+ Prune,
+
+ /// Stop recursion on current tree.
+ /// If recursion runs on an inner tree then returning
[`TreeNodeRecursion::Stop`] doesn't
+ /// stop recursion on the outer tree.
Stop,
+
+ /// Stop recursion on all (including outer) trees.
+ StopAll,
+}
+
+impl TreeNodeRecursion {
+ pub fn and_then_on_continue<F>(self, f: F) -> Result<TreeNodeRecursion>
Review Comment:
Added comment to `and_then_on_continue()` this in
https://github.com/apache/arrow-datafusion/pull/7942/commits/888228584d9dd95beae6644e648ee0bb2b34ba6e.
I will add more details and comments to other helpers later. Let's see first
if we need `fail_on_prune()` at all in
https://github.com/apache/arrow-datafusion/pull/7942#discussion_r1431805017.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]