You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by te...@apache.org on 2019/03/18 11:45:12 UTC

[hadoop] branch trunk updated: MAPREDUCE-7188. [Clean-up] Remove NULL check before instanceof and fix checkstyle issue in TaskResult (Contributed by Shweta Yakkali via Daniel Templeton)

This is an automated email from the ASF dual-hosted git repository.

templedf pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git


The following commit(s) were added to refs/heads/trunk by this push:
     new cb4d911  MAPREDUCE-7188. [Clean-up] Remove NULL check before instanceof and fix checkstyle issue in TaskResult (Contributed by Shweta Yakkali via Daniel Templeton)
cb4d911 is described below

commit cb4d911a82c0ca7a31092da868471ad711c9afcf
Author: Shweta Yakkali <sh...@cloudera.com>
AuthorDate: Sat Mar 16 12:34:16 2019 -0700

    MAPREDUCE-7188. [Clean-up] Remove NULL check before instanceof and fix checkstyle issue in TaskResult
    (Contributed by Shweta Yakkali via Daniel Templeton)
    
    Change-Id: Ie5eb9462f94e45cfd9d2a4b85c081ac8be949c07
---
 .../org/apache/hadoop/examples/pi/TaskResult.java  | 34 ++++++++++++++--------
 1 file changed, 22 insertions(+), 12 deletions(-)

diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/main/java/org/apache/hadoop/examples/pi/TaskResult.java b/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/main/java/org/apache/hadoop/examples/pi/TaskResult.java
index d60d4ce..cd8eba3 100644
--- a/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/main/java/org/apache/hadoop/examples/pi/TaskResult.java
+++ b/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/main/java/org/apache/hadoop/examples/pi/TaskResult.java
@@ -25,7 +25,8 @@ import org.apache.hadoop.examples.pi.math.Summation;
 import org.apache.hadoop.io.Writable;
 
 /** A class for map task results or reduce task results. */
-public class TaskResult implements Container<Summation>, Combinable<TaskResult>, Writable {
+public class TaskResult implements Container<Summation>,
+    Combinable<TaskResult>, Writable {
   private Summation sigma;
   private long duration;
 
@@ -38,10 +39,14 @@ public class TaskResult implements Container<Summation>, Combinable<TaskResult>,
 
   /** {@inheritDoc} */
   @Override
-  public Summation getElement() {return sigma;}
+  public Summation getElement() {
+    return sigma;
+  }
 
   /** @return The time duration used */
-  long getDuration() {return duration;}
+  long getDuration() {
+    return duration;
+  }
 
   /** {@inheritDoc} */
   @Override
@@ -54,7 +59,7 @@ public class TaskResult implements Container<Summation>, Combinable<TaskResult>,
   public boolean equals(Object obj) {
     if (this == obj)
       return true;
-    else if (obj != null && obj instanceof TaskResult) {
+    else if (obj instanceof TaskResult) {
       final TaskResult that = (TaskResult)obj;
       return this.compareTo(that) == 0;
     }
@@ -62,7 +67,7 @@ public class TaskResult implements Container<Summation>, Combinable<TaskResult>,
       "obj.getClass()=" + obj.getClass());
   }
 
-  /** Not supported */
+  /** Not supported. */
   @Override
   public int hashCode() {
     throw new UnsupportedOperationException();
@@ -72,7 +77,7 @@ public class TaskResult implements Container<Summation>, Combinable<TaskResult>,
   @Override
   public TaskResult combine(TaskResult that) {
     final Summation s = sigma.combine(that.sigma);
-    return s == null? null: new TaskResult(s, this.duration + that.duration);
+    return s == null ? null : new TaskResult(s, this.duration + that.duration);
   }
 
   /** {@inheritDoc} */
@@ -92,22 +97,27 @@ public class TaskResult implements Container<Summation>, Combinable<TaskResult>,
   /** {@inheritDoc} */
   @Override
   public String toString() {
-    return "sigma=" + sigma + ", duration=" + duration + "(" + Util.millis2String(duration) + ")";
+    return "sigma=" + sigma + ", duration=" + duration + "(" +
+        Util.millis2String(duration) + ")";
   }
 
-  /** Covert a String to a TaskResult */
+  /** Covert a String to a TaskResult. */
   public static TaskResult valueOf(String s) {
     int i = 0;
     int j = s.indexOf(", duration=");
     if (j < 0)
-      throw new IllegalArgumentException("i=" + i + ", j=" + j + " < 0, s=" + s);
-    final Summation sigma = Summation.valueOf(Util.parseStringVariable("sigma", s.substring(i, j)));
+      throw new IllegalArgumentException("i=" + i + ", j=" + j +
+          " < 0, s=" + s);
+    final Summation sigma =
+        Summation.valueOf(Util.parseStringVariable("sigma", s.substring(i, j)));
 
     i = j + 2;
     j = s.indexOf("(", i);
     if (j < 0)
-      throw new IllegalArgumentException("i=" + i + ", j=" + j + " < 0, s=" + s);
-    final long duration = Util.parseLongVariable("duration", s.substring(i, j));
+      throw new IllegalArgumentException("i=" + i + ", j=" + j +
+          " < 0, s=" + s);
+    final long duration =
+        Util.parseLongVariable("duration", s.substring(i, j));
 
     return new TaskResult(sigma, duration);
   }


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org