hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zjs...@apache.org
Subject [42/50] [abbrv] hadoop git commit: MAPREDUCE-5905. CountersStrings.toEscapedCompactStrings outputs unnecessary null strings. Contributed by Akira AJISAKA.
Date Mon, 04 May 2015 20:05:01 GMT
MAPREDUCE-5905. CountersStrings.toEscapedCompactStrings outputs unnecessary null strings. Contributed
by Akira AJISAKA.


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/62d72e26
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/62d72e26
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/62d72e26

Branch: refs/heads/YARN-2928
Commit: 62d72e26fd55ab8e2152ae17f0e99509bd76250a
Parents: 195d746
Author: Tsuyoshi Ozawa <ozawa@apache.org>
Authored: Mon May 4 15:02:21 2015 +0900
Committer: Zhijie Shen <zjshen@apache.org>
Committed: Mon May 4 12:59:00 2015 -0700

----------------------------------------------------------------------
 hadoop-mapreduce-project/CHANGES.txt               |  3 +++
 .../hadoop/mapreduce/util/CountersStrings.java     | 17 ++---------------
 .../org/apache/hadoop/mapred/TestCounters.java     |  3 +++
 3 files changed, 8 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/62d72e26/hadoop-mapreduce-project/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-mapreduce-project/CHANGES.txt b/hadoop-mapreduce-project/CHANGES.txt
index 1b23ee2..86477c3 100644
--- a/hadoop-mapreduce-project/CHANGES.txt
+++ b/hadoop-mapreduce-project/CHANGES.txt
@@ -377,6 +377,9 @@ Release 2.8.0 - UNRELEASED
     MAPREDUCE-6345. Documentation fix for when CRLA is enabled for MRAppMaster
     logs. (Rohit Agarwal via gera)
 
+    MAPREDUCE-5905. CountersStrings.toEscapedCompactStrings outputs
+    unnecessary "null" strings. (Akira AJISAKA via ozawa)
+
 Release 2.7.1 - UNRELEASED
 
   INCOMPATIBLE CHANGES

http://git-wip-us.apache.org/repos/asf/hadoop/blob/62d72e26/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/util/CountersStrings.java
----------------------------------------------------------------------
diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/util/CountersStrings.java
b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/util/CountersStrings.java
index ce799f5..ac16c12 100644
--- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/util/CountersStrings.java
+++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/util/CountersStrings.java
@@ -151,25 +151,12 @@ public class CountersStrings {
   public static <C extends Counter, G extends CounterGroupBase<C>,
                  T extends AbstractCounters<C, G>>
   String toEscapedCompactString(T counters) {
-    String[] groupsArray;
-    int length = 0;
+    StringBuilder builder = new StringBuilder();
     synchronized(counters) {
-      groupsArray = new String[counters.countCounters()];
-      int i = 0;
-      // First up, obtain the escaped string for each group so that we can
-      // determine the buffer length apriori.
       for (G group : counters) {
-        String escapedString = toEscapedCompactString(group);
-        groupsArray[i++] = escapedString;
-        length += escapedString.length();
+        builder.append(toEscapedCompactString(group));
       }
     }
-
-    // Now construct the buffer
-    StringBuilder builder = new StringBuilder(length);
-    for (String group : groupsArray) {
-      builder.append(group);
-    }
     return builder.toString();
   }
 

http://git-wip-us.apache.org/repos/asf/hadoop/blob/62d72e26/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapred/TestCounters.java
----------------------------------------------------------------------
diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapred/TestCounters.java
b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapred/TestCounters.java
index 46e7221..5e2763e 100644
--- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapred/TestCounters.java
+++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapred/TestCounters.java
@@ -18,6 +18,7 @@
 package org.apache.hadoop.mapred;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
 import java.io.IOException;
@@ -84,6 +85,8 @@ public class TestCounters {
    */
   private void testCounter(Counters counter) throws ParseException {
     String compactEscapedString = counter.makeEscapedCompactString();
+    assertFalse("compactEscapedString should not contain null",
+                compactEscapedString.contains("null"));
     
     Counters recoveredCounter = 
       Counters.fromEscapedCompactString(compactEscapedString);


Mime
View raw message