Skip to content

Conversation

@LuciferYang
Copy link
Contributor

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

@LuciferYang
Copy link
Contributor Author

Will manually test Scala 2.13

@LuciferYang LuciferYang changed the title [SPARK-41097][CORE][SQL] Remove redundant collection conversion base on Scala 2.13 code [WIP][SPARK-41097][CORE][SQL] Remove redundant collection conversion base on Scala 2.13 code Nov 10, 2022
@LuciferYang LuciferYang changed the title [WIP][SPARK-41097][CORE][SQL] Remove redundant collection conversion base on Scala 2.13 code [WIP][SPARK-41097][CORE][SQL][SS][PROTOBUF] Remove redundant collection conversion base on Scala 2.13 code Nov 10, 2022
@LuciferYang LuciferYang marked this pull request as ready for review November 11, 2022 09:09
@LuciferYang LuciferYang changed the title [WIP][SPARK-41097][CORE][SQL][SS][PROTOBUF] Remove redundant collection conversion base on Scala 2.13 code [SPARK-41097][CORE][SQL][SS][PROTOBUF] Remove redundant collection conversion base on Scala 2.13 code Nov 11, 2022
@srowen
Copy link
Member

srowen commented Nov 16, 2022

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.

@LuciferYang
Copy link
Contributor Author

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(
Copy link
Contributor Author

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)
Copy link
Contributor Author

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))
Copy link
Contributor Author

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))
Copy link
Contributor Author

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

@LuciferYang
Copy link
Contributor Author

Seems there is no API involved in lazy computing. I think it should be safe. Let me verify full UTs with 2.13 again

@srowen
Copy link
Member

srowen commented Nov 23, 2022

Let me know when it seems ready to merge

@LuciferYang
Copy link
Contributor Author

ready to merge

@srowen
Copy link
Member

srowen commented Nov 24, 2022

Merged to master

@srowen srowen closed this in 483e3c9 Nov 24, 2022
beliefer pushed a commit to beliefer/spark that referenced this pull request Dec 15, 2022
…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]>
beliefer pushed a commit to beliefer/spark that referenced this pull request Dec 18, 2022
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants