-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-13702][CORE][SQL][MLLIB] Use diamond operator for generic instance creation in Java code. #11541
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
Conversation
|
Although I personally like this change, I'm less certain about it since it does not add any functional improvement or avoid a potential bug. It does add a little readability and only touches the relatively fewer Java files. I'd like to wait for others to give an opinion. |
|
Thank you for review, @srowen . |
|
+1 on the code changes, which simplifies the Java code and shows some benefits from dropping Java 6, but the changes to the pom file should be discussed in a separate PR. |
|
add to whitelist |
|
ok to test |
|
Thank you, @mengxr ! |
…ance creation in Java code. Java 7 or higher supports `diamond` operator which replaces the type arguments required to invoke the constructor of a generic class with an empty set of type parameters (<>). Currently, Spark Java code use mixed usage of this. This issue replaces existing codes to use `diamond` operator and add Checkstyle rule. ``` -List<JavaPairDStream<String, String>> kafkaStreams = new ArrayList<JavaPairDStream<String, String>>(numStreams); +List<JavaPairDStream<String, String>> kafkaStreams = new ArrayList<>(numStreams); -Set<Tuple2<Integer, Integer>> edges = new HashSet<Tuple2<Integer, Integer>>(numEdges); +Set<Tuple2<Integer, Integer>> edges = new HashSet<>(numEdges); ```
|
Hi, @mengxr . |
|
Test build #52697 has finished for PR 11541 at commit
|
|
Test build #52699 has finished for PR 11541 at commit
|
|
Hi, @mengxr . |
|
Test build #52696 has finished for PR 11541 at commit
|
|
The latest one is at commit |
|
LGTM, merging to master. This is now just straightforward use of the diamond operator only. |
|
Thank you, @srowen . Yes, it is. |
…ance creation in Java code. ## What changes were proposed in this pull request? In order to make `docs/examples` (and other related code) more simple/readable/user-friendly, this PR replaces existing codes like the followings by using `diamond` operator. ``` - final ArrayList<Product2<Object, Object>> dataToWrite = - new ArrayList<Product2<Object, Object>>(); + final ArrayList<Product2<Object, Object>> dataToWrite = new ArrayList<>(); ``` Java 7 or higher supports **diamond** operator which replaces the type arguments required to invoke the constructor of a generic class with an empty set of type parameters (<>). Currently, Spark Java code use mixed usage of this. ## How was this patch tested? Manual. Pass the existing tests. Author: Dongjoon Hyun <[email protected]> Closes apache#11541 from dongjoon-hyun/SPARK-13702.
What changes were proposed in this pull request?
In order to make
docs/examples(and other related code) more simple/readable/user-friendly, this PR replaces existing codes like the followings by usingdiamondoperator.Java 7 or higher supports diamond operator which replaces the type arguments required to invoke the constructor of a generic class with an empty set of type parameters (<>). Currently, Spark Java code use mixed usage of this.
How was this patch tested?
Manual.
Pass the existing tests.