peter-toth commented on code in PR #8664:
URL: https://github.com/apache/arrow-datafusion/pull/8664#discussion_r1438886026


##########
datafusion/common/src/tree_node.rs:
##########
@@ -136,6 +172,23 @@ pub trait TreeNode: Sized {
         after_op.map_children(|node| node.transform_down_mut(op))
     }
 
+    /// Transforms the tree using `f` pre-preorder (top-down) traversal. The 
`f_down`
+    /// closure takes payloads that it propagates down during the 
transformation.
+    ///
+    /// The `f_down` closure takes `FD` type payload from its parent and 
returns `Vec<FD>`
+    /// type payload to propagate down to its children. One `FD` element is 
propagated
+    /// down to each child.
+    fn transform_down_with_payload<F, P>(self, f: &mut F, payload: P) -> 
Result<Self>
+    where
+        F: FnMut(Self, P) -> Result<(Transformed<Self>, Vec<P>)>,
+    {
+        let (new_node, new_payload) = f(self, payload)?;

Review Comment:
   You are right, both the down and up versions can be implemented using 
`transform_with_payload`. But I would keep them separated in this PR and check 
later what happens if we we use empty f_up and  `PU=()`. Does the "up logic" 
get optimized out by the compiler at "down invocations"? I.e. `payload_up` vec 
is not allocated?



-- 
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]

Reply via email to