-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-41097][CORE][SQL][SS][PROTOBUF] Remove redundant collection conversion base on Scala 2.13 code #38598
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-41097][CORE][SQL][SS][PROTOBUF] Remove redundant collection conversion base on Scala 2.13 code #38598
Conversation
|
Will manually test Scala 2.13 |
|
These are probably fine. Some may be hold-overs from earlier versions of Scala. I'm slightly worried that in some cases they cause a copy and we actually rely on that, though this is a bad way to rely on it. SKimming it, I am not sure that's true in these cases. |
|
Let me check again |
| // We don't want to change our target number of executors, because we already did that | ||
| // when the task backlog decreased. | ||
| if (decommissionEnabled) { | ||
| val executorIdsWithoutHostLoss = executorIdsToBeRemoved.toSeq.map( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to toSeq here because executorIdsToBeRemoved(ArrayBuffer).map finally calls toArray
|
|
||
| def apply(fields: java.util.List[StructField]): StructType = { | ||
| import scala.collection.JavaConverters._ | ||
| StructType(fields.asScala.toSeq) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This represents fields.asScala.toSeq.toArray, seems toSeq is redundant
| case None => | ||
| properties.filterKeys(!_.startsWith(CatalogTable.VIEW_PREFIX)) | ||
| .toSeq.sortBy(_._1).map(p => Row(p._1, p._2)).toSeq | ||
| .toSeq.sortBy(_._1).map(p => Row(p._1, p._2)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
toSeq has been called previously
| case None => | ||
| properties.toSeq.sortBy(_._1).map(kv => | ||
| toCatalystRow(kv._1, kv._2)).toSeq | ||
| toCatalystRow(kv._1, kv._2)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
toSeq has been called previously
|
Seems there is no API involved in lazy computing. I think it should be safe. Let me verify full UTs with 2.13 again |
|
Let me know when it seems ready to merge |
|
ready to merge |
|
Merged to master |
…nversion base on Scala 2.13 code ### What changes were proposed in this pull request? This pr aims clean up redundant collection conversion base on Scala 2.13 code ### Why are the changes needed? Code clean up. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? - Pass GitHub Actions Closes apache#38598 from LuciferYang/redundant-collection-conversion. Lead-authored-by: YangJie <[email protected]> Co-authored-by: yangjie01 <[email protected]> Signed-off-by: Sean Owen <[email protected]>
…nversion base on Scala 2.13 code ### What changes were proposed in this pull request? This pr aims clean up redundant collection conversion base on Scala 2.13 code ### Why are the changes needed? Code clean up. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? - Pass GitHub Actions Closes apache#38598 from LuciferYang/redundant-collection-conversion. Lead-authored-by: YangJie <[email protected]> Co-authored-by: yangjie01 <[email protected]> Signed-off-by: Sean Owen <[email protected]>
What changes were proposed in this pull request?
This pr aims clean up redundant collection conversion base on Scala 2.13 code
Why are the changes needed?
Code clean up.
Does this PR introduce any user-facing change?
No
How was this patch tested?