Skip to content

Conversation

@HyukjinKwon
Copy link
Member

What changes were proposed in this pull request?

This is a backport of #31110. I ran intelliJ inspection again in this branch.

This PR is basically a followup of #14332.
Calling map alone might leave it not executed due to lazy evaluation, e.g.)

scala> val foo = Seq(1,2,3)
foo: Seq[Int] = List(1, 2, 3)

scala> foo.map(println)
1
2
3
res0: Seq[Unit] = List((), (), ())

scala> foo.view.map(println)
res1: scala.collection.SeqView[Unit,Seq[_]] = SeqViewM(...)

scala> foo.view.foreach(println)
1
2
3

We should better use foreach to make sure it's executed where the output is unused or Unit.

Why are the changes needed?

To prevent the potential issues by not executing map.

Does this PR introduce any user-facing change?

No, the current codes look not causing any problem for now.

How was this patch tested?

I found these item by running IntelliJ inspection, double checked one by one, and fixed them. These should be all instances across the codebase ideally.

@HyukjinKwon
Copy link
Member Author

cc @mridulm and @srowen FYI

@SparkQA
Copy link

SparkQA commented Jan 12, 2021

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/38538/

@SparkQA
Copy link

SparkQA commented Jan 12, 2021

Kubernetes integration test status success
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/38538/

@HyukjinKwon
Copy link
Member Author

Thanks. Merged to branch-3.0.

HyukjinKwon added a commit that referenced this pull request Jan 12, 2021
… sure execute it eagerly

### What changes were proposed in this pull request?

This is a backport of #31110. I ran intelliJ inspection again in this branch.

This PR is basically a followup of #14332.
Calling `map` alone might leave it not executed due to lazy evaluation, e.g.)

```
scala> val foo = Seq(1,2,3)
foo: Seq[Int] = List(1, 2, 3)

scala> foo.map(println)
1
2
3
res0: Seq[Unit] = List((), (), ())

scala> foo.view.map(println)
res1: scala.collection.SeqView[Unit,Seq[_]] = SeqViewM(...)

scala> foo.view.foreach(println)
1
2
3
```

We should better use `foreach` to make sure it's executed where the output is unused or `Unit`.

### Why are the changes needed?

To prevent the potential issues by not executing `map`.

### Does this PR introduce _any_ user-facing change?

No, the current codes look not causing any problem for now.

### How was this patch tested?

I found these item by running IntelliJ inspection, double checked one by one, and fixed them. These should be all instances across the codebase ideally.

Closes #31138 from HyukjinKwon/SPARK-34059-3.0.

Authored-by: HyukjinKwon <gurwls223@apache.org>
Signed-off-by: HyukjinKwon <gurwls223@apache.org>
@SparkQA
Copy link

SparkQA commented Jan 12, 2021

Test build #133951 has finished for PR 31138 at commit 88cfbc9.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@mridulm
Copy link
Contributor

mridulm commented Jan 12, 2021

+1
Thanks for backporting this @HyukjinKwon !

@HyukjinKwon HyukjinKwon deleted the SPARK-34059-3.0 branch January 4, 2022 00:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants