-
Notifications
You must be signed in to change notification settings - Fork 29.2k
[SPARK-40398][CORE][SQL] Use Loop instead of Arrays.stream api #37843
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
Changes from 13 commits
5c92faa
71ff5ff
5c5365f
bc19399
1ecf017
9c979c4
e90991c
8ff3b77
a16a89b
1ee7c4a
46d4a57
a64f608
e00330f
4892423
1a6a3c8
528f3c5
2343dc8
db94018
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,7 +17,9 @@ | |
|
|
||
| package org.apache.spark.sql.connector.expressions; | ||
|
|
||
| import java.util.Arrays; | ||
| import java.util.Collections; | ||
| import java.util.HashSet; | ||
| import java.util.Set; | ||
|
|
||
| import org.apache.spark.annotation.Evolving; | ||
|
|
||
|
|
@@ -44,7 +46,12 @@ public interface Expression { | |
| * List of fields or columns that are referenced by this expression. | ||
| */ | ||
| default NamedReference[] references() { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Compare and
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use following method build test object and test -1, 5, 100
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Java 8 Java 11 Java 17
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For Java 11 and 17, using loop looks more better, |
||
| return Arrays.stream(children()).map(e -> e.references()) | ||
| .flatMap(Arrays::stream).distinct().toArray(NamedReference[]::new); | ||
| // SPARK-40398: Replace `Arrays.stream()...distinct()` | ||
| // to this for perf gain, the result order is not important. | ||
| Set<NamedReference> set = new HashSet<>(); | ||
| for (Expression e : children()) { | ||
| Collections.addAll(set, e.references()); | ||
| } | ||
| return set.toArray(new NamedReference[0]); | ||
|
||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.