You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/04/06 03:43:18 UTC

[GitHub] [arrow-datafusion] mingmwang opened a new pull request, #2168: Implement fast path of with_new_children() in ExecutionPlan

mingmwang opened a new pull request, #2168:
URL: https://github.com/apache/arrow-datafusion/pull/2168

   # Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   Closes #1965.
   
    # Rationale for this change
   <!--
    Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.  
   -->
   
   # What changes are included in this PR?
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   # Are there any user-facing changes?
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!--
   If there are any breaking changes to public APIs, please add the `api change` label.
   -->
   


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] yjshen commented on a diff in pull request #2168: Implement fast path of with_new_children() in ExecutionPlan

Posted by GitBox <gi...@apache.org>.
yjshen commented on code in PR #2168:
URL: https://github.com/apache/arrow-datafusion/pull/2168#discussion_r844824354


##########
datafusion/core/src/physical_plan/mod.rs:
##########
@@ -258,6 +258,32 @@ pub trait ExecutionPlan: Debug + Send + Sync {
     fn statistics(&self) -> Statistics;
 }
 
+/// Returns a new plan where all children were replaced by new plans if the provided children
+/// do not share the same point references with the existing children.
+/// The size of `children` must be equal to the size of `ExecutionPlan::children()`.
+/// Allow the vtable address comparisons for ExecutionPlan Trait Objects,it is harmless even
+/// in the case of 'false-native'.

Review Comment:
   Since we are reporting two equal items to be non-equal, it results in making a copy, so I term it 'false-positive'. 
   
   It should be 'false negative' if you only mean data equality.  😆



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] mingmwang commented on a diff in pull request #2168: Implement fast path of with_new_children() in ExecutionPlan

Posted by GitBox <gi...@apache.org>.
mingmwang commented on code in PR #2168:
URL: https://github.com/apache/arrow-datafusion/pull/2168#discussion_r844531090


##########
ballista/rust/core/src/serde/mod.rs:
##########
@@ -508,15 +508,10 @@ mod tests {
             &self,
             children: Vec<Arc<dyn ExecutionPlan>>,
         ) -> datafusion::error::Result<Arc<dyn ExecutionPlan>> {
-            match children.len() {
-                1 => Ok(Arc::new(TopKExec {
-                    input: children[0].clone(),
-                    k: self.k,
-                })),
-                _ => Err(DataFusionError::Internal(
-                    "TopKExec wrong number of children".to_string(),
-                )),
-            }
+            Ok(Arc::new(TopKExec {

Review Comment:
   I'm not sure in Rust whether I can declare a method in the Trait to `protected` so that it can only be visible in this module and in the Trait implementations.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] alamb merged pull request #2168: Implement fast path of with_new_children() in ExecutionPlan

Posted by GitBox <gi...@apache.org>.
alamb merged PR #2168:
URL: https://github.com/apache/arrow-datafusion/pull/2168


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] mingmwang commented on pull request #2168: Implement fast path of with_new_children() in ExecutionPlan

Posted by GitBox <gi...@apache.org>.
mingmwang commented on PR #2168:
URL: https://github.com/apache/arrow-datafusion/pull/2168#issuecomment-1091026228

   > ExecutionPlan
   
   
   
   > I think this looks great @mingmwang -- thank you very much.
   > 
   > Another thing we might want to consider doing would be to change the signature of `ExecutionPlan` trait to _require_ an `Arc` to call `with_new_children`, like so:
   > 
   > ```rust
   >     fn with_new_children(
   >         self: Arc<Self>,
   >         children: Vec<Arc<dyn ExecutionPlan>>,
   >     ) -> Result<Arc<dyn ExecutionPlan>> {
   >   // put with_new_children_if_necessary implementation here
   > ...
   > }
   > ```
   > 
   > That would ensure that we could always apply the `with_new_children_if_necessary` logic
   
   Done.


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] mingmwang commented on a diff in pull request #2168: Implement fast path of with_new_children() in ExecutionPlan

Posted by GitBox <gi...@apache.org>.
mingmwang commented on code in PR #2168:
URL: https://github.com/apache/arrow-datafusion/pull/2168#discussion_r844808018


##########
datafusion/core/src/physical_plan/mod.rs:
##########
@@ -258,6 +258,32 @@ pub trait ExecutionPlan: Debug + Send + Sync {
     fn statistics(&self) -> Statistics;
 }
 
+/// Returns a new plan where all children were replaced by new plans if the provided children
+/// do not share the same point references with the existing children.
+/// The size of `children` must be equal to the size of `ExecutionPlan::children()`.
+/// Allow the vtable address comparisons for ExecutionPlan Trait Objects,it is harmless even
+/// in the case of 'false-native'.

Review Comment:
   I think it should be 'false-native'(two expected equal things end up not comparing equal) for Trait objects.
   
   
   [https://stackoverflow.com/questions/67109860/how-to-compare-trait-objects-within-an-arc]()
   
   



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] yjshen commented on a diff in pull request #2168: Implement fast path of with_new_children() in ExecutionPlan

Posted by GitBox <gi...@apache.org>.
yjshen commented on code in PR #2168:
URL: https://github.com/apache/arrow-datafusion/pull/2168#discussion_r844790396


##########
datafusion/core/src/physical_plan/mod.rs:
##########
@@ -258,6 +258,32 @@ pub trait ExecutionPlan: Debug + Send + Sync {
     fn statistics(&self) -> Statistics;
 }
 
+/// Returns a new plan where all children were replaced by new plans if the provided children
+/// do not share the same point references with the existing children.

Review Comment:
   ```suggestion
   /// Returns a copy of this plan if we change any child according to pointer comparison.
   ///
   ```



##########
datafusion/core/src/physical_plan/mod.rs:
##########
@@ -258,6 +258,32 @@ pub trait ExecutionPlan: Debug + Send + Sync {
     fn statistics(&self) -> Statistics;
 }
 
+/// Returns a new plan where all children were replaced by new plans if the provided children
+/// do not share the same point references with the existing children.
+/// The size of `children` must be equal to the size of `ExecutionPlan::children()`.
+/// Allow the vtable address comparisons for ExecutionPlan Trait Objects,it is harmless even
+/// in the case of 'false-native'.

Review Comment:
   This should be false-positive I think?



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #2168: Implement fast path of with_new_children() in ExecutionPlan

Posted by GitBox <gi...@apache.org>.
alamb commented on code in PR #2168:
URL: https://github.com/apache/arrow-datafusion/pull/2168#discussion_r844259856


##########
ballista/rust/core/src/serde/mod.rs:
##########
@@ -508,15 +508,10 @@ mod tests {
             &self,
             children: Vec<Arc<dyn ExecutionPlan>>,
         ) -> datafusion::error::Result<Arc<dyn ExecutionPlan>> {
-            match children.len() {
-                1 => Ok(Arc::new(TopKExec {
-                    input: children[0].clone(),
-                    k: self.k,
-                })),
-                _ => Err(DataFusionError::Internal(
-                    "TopKExec wrong number of children".to_string(),
-                )),
-            }
+            Ok(Arc::new(TopKExec {

Review Comment:
   What would you think about adding an assert here such as`assert_eq!(children.len(), 1)`  on the theory it might catch bugs faster when making changes?
   
   The same question applies to other `with_new_children` implementations below



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] mingmwang commented on a diff in pull request #2168: Implement fast path of with_new_children() in ExecutionPlan

Posted by GitBox <gi...@apache.org>.
mingmwang commented on code in PR #2168:
URL: https://github.com/apache/arrow-datafusion/pull/2168#discussion_r844812467


##########
datafusion/core/src/physical_plan/mod.rs:
##########
@@ -258,6 +258,32 @@ pub trait ExecutionPlan: Debug + Send + Sync {
     fn statistics(&self) -> Statistics;
 }
 
+/// Returns a new plan where all children were replaced by new plans if the provided children
+/// do not share the same point references with the existing children.

Review Comment:
   Done.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #2168: Implement fast path of with_new_children() in ExecutionPlan

Posted by GitBox <gi...@apache.org>.
alamb commented on code in PR #2168:
URL: https://github.com/apache/arrow-datafusion/pull/2168#discussion_r844259856


##########
ballista/rust/core/src/serde/mod.rs:
##########
@@ -508,15 +508,10 @@ mod tests {
             &self,
             children: Vec<Arc<dyn ExecutionPlan>>,
         ) -> datafusion::error::Result<Arc<dyn ExecutionPlan>> {
-            match children.len() {
-                1 => Ok(Arc::new(TopKExec {
-                    input: children[0].clone(),
-                    k: self.k,
-                })),
-                _ => Err(DataFusionError::Internal(
-                    "TopKExec wrong number of children".to_string(),
-                )),
-            }
+            Ok(Arc::new(TopKExec {

Review Comment:
   What would you think about adding an assert here such as`assert_eq!(children.len(), 1)`  on the theory it might catch bugs faster when making changes?
   
   The same question applies to other `with_new_children` implementations below



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] mingmwang commented on a diff in pull request #2168: Implement fast path of with_new_children() in ExecutionPlan

Posted by GitBox <gi...@apache.org>.
mingmwang commented on code in PR #2168:
URL: https://github.com/apache/arrow-datafusion/pull/2168#discussion_r844527086


##########
ballista/rust/core/src/serde/mod.rs:
##########
@@ -508,15 +508,10 @@ mod tests {
             &self,
             children: Vec<Arc<dyn ExecutionPlan>>,
         ) -> datafusion::error::Result<Arc<dyn ExecutionPlan>> {
-            match children.len() {
-                1 => Ok(Arc::new(TopKExec {
-                    input: children[0].clone(),
-                    k: self.k,
-                })),
-                _ => Err(DataFusionError::Internal(
-                    "TopKExec wrong number of children".to_string(),
-                )),
-            }
+            Ok(Arc::new(TopKExec {

Review Comment:
   I removed the length check in the  `with_new_children()` method and move the check to `with_new_children_if_necessary()` so that we can avoid the duplicate logic in all the trait implementations. In future if someone misuse this and still call the `with_new_children()` and pass the wrong children param, it will lose the check, but if this is the case,  the real problem is he should not call `with_new_children()` and everyone should call `with_new_children_if_necessary()`.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #2168: Implement fast path of with_new_children() in ExecutionPlan

Posted by GitBox <gi...@apache.org>.
alamb commented on code in PR #2168:
URL: https://github.com/apache/arrow-datafusion/pull/2168#discussion_r844259858


##########
ballista/rust/core/src/serde/mod.rs:
##########
@@ -508,15 +508,10 @@ mod tests {
             &self,
             children: Vec<Arc<dyn ExecutionPlan>>,
         ) -> datafusion::error::Result<Arc<dyn ExecutionPlan>> {
-            match children.len() {
-                1 => Ok(Arc::new(TopKExec {
-                    input: children[0].clone(),
-                    k: self.k,
-                })),
-                _ => Err(DataFusionError::Internal(
-                    "TopKExec wrong number of children".to_string(),
-                )),
-            }
+            Ok(Arc::new(TopKExec {

Review Comment:
   What would you think about adding an assert here such as`assert_eq!(children.len(), 1)`  on the theory it might catch bugs faster when making changes?
   
   The same question applies to other `with_new_children` implementations below



##########
datafusion/core/src/physical_plan/mod.rs:
##########
@@ -258,6 +258,32 @@ pub trait ExecutionPlan: Debug + Send + Sync {
     fn statistics(&self) -> Statistics;
 }
 
+/// Returns a new plan where all children were replaced by new plans if the provided children

Review Comment:
   👍 



##########
datafusion/core/src/physical_plan/mod.rs:
##########
@@ -258,6 +258,32 @@ pub trait ExecutionPlan: Debug + Send + Sync {
     fn statistics(&self) -> Statistics;
 }
 
+/// Returns a new plan where all children were replaced by new plans if the provided children

Review Comment:
   👍 



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #2168: Implement fast path of with_new_children() in ExecutionPlan

Posted by GitBox <gi...@apache.org>.
alamb commented on code in PR #2168:
URL: https://github.com/apache/arrow-datafusion/pull/2168#discussion_r844262754


##########
datafusion/core/src/physical_plan/mod.rs:
##########
@@ -258,6 +258,32 @@ pub trait ExecutionPlan: Debug + Send + Sync {
     fn statistics(&self) -> Statistics;
 }
 
+/// Returns a new plan where all children were replaced by new plans if the provided children

Review Comment:
   👍 



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] mingmwang commented on pull request #2168: Implement fast path of with_new_children() in ExecutionPlan

Posted by GitBox <gi...@apache.org>.
mingmwang commented on PR #2168:
URL: https://github.com/apache/arrow-datafusion/pull/2168#issuecomment-1089987058

   @yjshen @alamb 
   
   Please help to take a look.


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org