You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bahir.apache.org by lr...@apache.org on 2016/06/10 15:24:18 UTC

[39/50] [abbrv] bahir git commit: [SPARK-13702][CORE][SQL][MLLIB] Use diamond operator for generic instance creation in Java code.

[SPARK-13702][CORE][SQL][MLLIB] Use diamond operator for generic instance 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 <do...@apache.org>

Closes #11541 from dongjoon-hyun/SPARK-13702.


Project: http://git-wip-us.apache.org/repos/asf/bahir/repo
Commit: http://git-wip-us.apache.org/repos/asf/bahir/commit/84a14711
Tree: http://git-wip-us.apache.org/repos/asf/bahir/tree/84a14711
Diff: http://git-wip-us.apache.org/repos/asf/bahir/diff/84a14711

Branch: refs/heads/master
Commit: 84a147111c86c7bc219c959fa652829991c2b074
Parents: 3b4a1c0
Author: Dongjoon Hyun <do...@apache.org>
Authored: Wed Mar 9 10:31:26 2016 +0000
Committer: Sean Owen <so...@cloudera.com>
Committed: Wed Mar 9 10:31:26 2016 +0000

----------------------------------------------------------------------
 .../apache/spark/examples/streaming/akka/JavaActorWordCount.java   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/bahir/blob/84a14711/streaming-akka/examples/src/main/java/org/apache/spark/examples/streaming/akka/JavaActorWordCount.java
----------------------------------------------------------------------
diff --git a/streaming-akka/examples/src/main/java/org/apache/spark/examples/streaming/akka/JavaActorWordCount.java b/streaming-akka/examples/src/main/java/org/apache/spark/examples/streaming/akka/JavaActorWordCount.java
index 7bb70d0..7884b8c 100644
--- a/streaming-akka/examples/src/main/java/org/apache/spark/examples/streaming/akka/JavaActorWordCount.java
+++ b/streaming-akka/examples/src/main/java/org/apache/spark/examples/streaming/akka/JavaActorWordCount.java
@@ -129,7 +129,7 @@ public class JavaActorWordCount {
     }).mapToPair(new PairFunction<String, String, Integer>() {
       @Override
       public Tuple2<String, Integer> call(String s) {
-        return new Tuple2<String, Integer>(s, 1);
+        return new Tuple2<>(s, 1);
       }
     }).reduceByKey(new Function2<Integer, Integer, Integer>() {
       @Override