You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/03/17 08:12:23 UTC
[GitHub] [spark] LuciferYang opened a new pull request #35890: [SPARK-38585][SQL] Remove the constant arg `forceCopy` for the private method `mapChildren` in `TreeNode`
LuciferYang opened a new pull request #35890:
URL: https://github.com/apache/spark/pull/35890
### What changes were proposed in this pull request?
SPARK-28057 adds `forceCopy` arg to private `mapChildren` method in `TreeNode` to realize the object clone(), and after SPARK-34989, the call corresponding to `forceCopy=false` is changed to use `withNewChildren`, and `forceCopy` always true. So This PR deletes the arg `forceCopy` and the branch that cannot be reached when `forceCopy = true`. On the other hand, the private `mapChildren` is rename `mapChildrenWithForceCopy` in this pr because there is another public `mapChildren` method with the same signature in `TreeNode`.
### Why are the changes needed?
Code simplification.
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
Pass GA
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] sigmod commented on pull request #35890: [SPARK-38585][SQL] Simplify the code of `TreeNode.clone()`
Posted by GitBox <gi...@apache.org>.
sigmod commented on pull request #35890:
URL: https://github.com/apache/spark/pull/35890#issuecomment-1076657254
cc @dbaliafroozeh @hvanhovell
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] cloud-fan commented on pull request #35890: [SPARK-38585][SQL] Simplify the code of `TreeNode.clone()`
Posted by GitBox <gi...@apache.org>.
cloud-fan commented on pull request #35890:
URL: https://github.com/apache/spark/pull/35890#issuecomment-1077270783
thanks, merging to master!
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] LuciferYang commented on a change in pull request #35890: [SPARK-38585][SQL] Remove the constant arg `forceCopy` for the private method `mapChildren` in `TreeNode`
Posted by GitBox <gi...@apache.org>.
LuciferYang commented on a change in pull request #35890:
URL: https://github.com/apache/spark/pull/35890#discussion_r829663269
##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/trees/TreeNode.scala
##########
@@ -610,24 +610,15 @@ abstract class TreeNode[BaseType <: TreeNode[BaseType]] extends Product with Tre
/**
* Returns a copy of this node where `f` has been applied to all the nodes in `children`.
+ * This method force making a copy of the nodes even if no child has been changed.
* @param f The transform function to be applied on applicable `TreeNode` elements.
- * @param forceCopy Whether to force making a copy of the nodes even if no child has been changed.
*/
- private def mapChildren(
- f: BaseType => BaseType,
- forceCopy: Boolean): BaseType = {
- var changed = false
+ private def mapChildrenWithForceCopy(f: BaseType => BaseType): BaseType = {
Review comment:
Should we move this method into `clone()` method? It is now only used by `TreeNode.clone`
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] LuciferYang commented on a change in pull request #35890: [SPARK-38585][SQL] Remove the constant arg `forceCopy` for the private method `mapChildren` in `TreeNode`
Posted by GitBox <gi...@apache.org>.
LuciferYang commented on a change in pull request #35890:
URL: https://github.com/apache/spark/pull/35890#discussion_r829663269
##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/trees/TreeNode.scala
##########
@@ -610,24 +610,15 @@ abstract class TreeNode[BaseType <: TreeNode[BaseType]] extends Product with Tre
/**
* Returns a copy of this node where `f` has been applied to all the nodes in `children`.
+ * This method force making a copy of the nodes even if no child has been changed.
* @param f The transform function to be applied on applicable `TreeNode` elements.
- * @param forceCopy Whether to force making a copy of the nodes even if no child has been changed.
*/
- private def mapChildren(
- f: BaseType => BaseType,
- forceCopy: Boolean): BaseType = {
- var changed = false
+ private def mapChildrenWithForceCopy(f: BaseType => BaseType): BaseType = {
Review comment:
Should we move this method into `clone()` method? Then we can change
```scala
f(arg.asInstanceOf[BaseType])
```
to
```scala
arg.asInstanceOf[BaseType].clone()
```
It is now only used by `TreeNode.clone`
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] sigmod commented on pull request #35890: [SPARK-38585][SQL] Simplify the code of `TreeNode.clone()`
Posted by GitBox <gi...@apache.org>.
sigmod commented on pull request #35890:
URL: https://github.com/apache/spark/pull/35890#issuecomment-1076683438
cc @maryannxue
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] LuciferYang commented on a change in pull request #35890: [WIP][SPARK-38585][SQL] Remove the constant arg `forceCopy` for the private method `mapChildren` in `TreeNode`
Posted by GitBox <gi...@apache.org>.
LuciferYang commented on a change in pull request #35890:
URL: https://github.com/apache/spark/pull/35890#discussion_r828996884
##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/trees/TreeNode.scala
##########
@@ -610,24 +610,15 @@ abstract class TreeNode[BaseType <: TreeNode[BaseType]] extends Product with Tre
/**
* Returns a copy of this node where `f` has been applied to all the nodes in `children`.
+ * This method force making a copy of the nodes even if no child has been changed.
* @param f The transform function to be applied on applicable `TreeNode` elements.
- * @param forceCopy Whether to force making a copy of the nodes even if no child has been changed.
*/
- private def mapChildren(
- f: BaseType => BaseType,
- forceCopy: Boolean): BaseType = {
- var changed = false
+ private def mapChildrenWithForceCopy(f: BaseType => BaseType): BaseType = {
Review comment:
Is there a more suitable method name?
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] LuciferYang commented on a change in pull request #35890: [SPARK-38585][SQL] Remove the constant arg `forceCopy` for the private method `mapChildren` in `TreeNode`
Posted by GitBox <gi...@apache.org>.
LuciferYang commented on a change in pull request #35890:
URL: https://github.com/apache/spark/pull/35890#discussion_r829663269
##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/trees/TreeNode.scala
##########
@@ -610,24 +610,15 @@ abstract class TreeNode[BaseType <: TreeNode[BaseType]] extends Product with Tre
/**
* Returns a copy of this node where `f` has been applied to all the nodes in `children`.
+ * This method force making a copy of the nodes even if no child has been changed.
* @param f The transform function to be applied on applicable `TreeNode` elements.
- * @param forceCopy Whether to force making a copy of the nodes even if no child has been changed.
*/
- private def mapChildren(
- f: BaseType => BaseType,
- forceCopy: Boolean): BaseType = {
- var changed = false
+ private def mapChildrenWithForceCopy(f: BaseType => BaseType): BaseType = {
Review comment:
Should we move this method into `clone()` method? It is now only used by `TreeNode.clone`
##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/trees/TreeNode.scala
##########
@@ -610,24 +610,15 @@ abstract class TreeNode[BaseType <: TreeNode[BaseType]] extends Product with Tre
/**
* Returns a copy of this node where `f` has been applied to all the nodes in `children`.
+ * This method force making a copy of the nodes even if no child has been changed.
* @param f The transform function to be applied on applicable `TreeNode` elements.
- * @param forceCopy Whether to force making a copy of the nodes even if no child has been changed.
*/
- private def mapChildren(
- f: BaseType => BaseType,
- forceCopy: Boolean): BaseType = {
- var changed = false
+ private def mapChildrenWithForceCopy(f: BaseType => BaseType): BaseType = {
Review comment:
Should we move this method into `clone()` method? Then we can change
```scala
f(arg.asInstanceOf[BaseType])
```
to
```scala
arg.asInstanceOf[BaseType].clone()
```
It is now only used by `TreeNode.clone`
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] LuciferYang commented on pull request #35890: [SPARK-38585][SQL] Simplify the code of `TreeNode.clone()`
Posted by GitBox <gi...@apache.org>.
LuciferYang commented on pull request #35890:
URL: https://github.com/apache/spark/pull/35890#issuecomment-1077275939
thanks all
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] cloud-fan closed pull request #35890: [SPARK-38585][SQL] Simplify the code of `TreeNode.clone()`
Posted by GitBox <gi...@apache.org>.
cloud-fan closed pull request #35890:
URL: https://github.com/apache/spark/pull/35890
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org