hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acmur...@apache.org
Subject svn commit: r727193 - in /hadoop/core/branches/branch-0.20: ./ CHANGES.txt src/mapred/org/apache/hadoop/mapred/Counters.java src/test/org/apache/hadoop/mapred/TestCounters.java
Date Tue, 16 Dec 2008 22:17:39 GMT
Author: acmurthy
Date: Tue Dec 16 14:17:39 2008
New Revision: 727193

URL: http://svn.apache.org/viewvc?rev=727193&view=rev
Log:
Merge -r 727190:727191 from trunk to branch-0.20 to fix HADOOP-4879.

Modified:
    hadoop/core/branches/branch-0.20/   (props changed)
    hadoop/core/branches/branch-0.20/CHANGES.txt
    hadoop/core/branches/branch-0.20/src/mapred/org/apache/hadoop/mapred/Counters.java
    hadoop/core/branches/branch-0.20/src/test/org/apache/hadoop/mapred/TestCounters.java

Propchange: hadoop/core/branches/branch-0.20/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Dec 16 14:17:39 2008
@@ -1,2 +1,2 @@
 /hadoop/core/branches/branch-0.19:713112
-/hadoop/core/trunk:727001
+/hadoop/core/trunk:727001,727191

Modified: hadoop/core/branches/branch-0.20/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.20/CHANGES.txt?rev=727193&r1=727192&r2=727193&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.20/CHANGES.txt (original)
+++ hadoop/core/branches/branch-0.20/CHANGES.txt Tue Dec 16 14:17:39 2008
@@ -441,6 +441,10 @@
     HADOOP-4458. Add a test creating symlinks in the working directory.
     (Amareshwari Sriramadasu via cdouglas)
 
+    HADOOP-4879. Fix org.apache.hadoop.mapred.Counters to correctly define
+    Object.equals rather than depend on contentEquals api. (omalley via 
+    acmurthy)
+
 Release 0.19.1 - Unreleased
 
   IMPROVEMENTS

Modified: hadoop/core/branches/branch-0.20/src/mapred/org/apache/hadoop/mapred/Counters.java
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.20/src/mapred/org/apache/hadoop/mapred/Counters.java?rev=727193&r1=727192&r2=727193&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.20/src/mapred/org/apache/hadoop/mapred/Counters.java (original)
+++ hadoop/core/branches/branch-0.20/src/mapred/org/apache/hadoop/mapred/Counters.java Tue
Dec 16 14:17:39 2008
@@ -211,13 +211,20 @@
       buf.append(GROUP_CLOSE); // group end
       return buf.toString();
     }
-        
+
+    @Override
+    public int hashCode() {
+      return subcounters.hashCode();
+    }
+
     /** 
      * Checks for (content) equality of Groups
      */
-    synchronized boolean contentEquals(Group g) {
+    @Override
+    public synchronized boolean equals(Object obj) {
       boolean isEqual = false;
-      if (g != null) {
+      if (obj != null && obj instanceof Group) {
+        Group g = (Group) obj;
         if (size() == g.size()) {
           isEqual = true;
           for (Map.Entry<String, Counter> entry : subcounters.entrySet()) {
@@ -671,17 +678,24 @@
     return StringUtils.unEscapeString(string, StringUtils.ESCAPE_CHAR, 
                                       charsToEscape);
   }
-  
-  synchronized boolean contentEquals(Counters counters) {
+
+  @Override 
+  public synchronized int hashCode() {
+    return counters.hashCode();
+  }
+
+  @Override
+  public synchronized boolean equals(Object obj) {
     boolean isEqual = false;
-    if (counters != null) {
-      if (size() == counters.size()) {
+    if (obj != null && obj instanceof Counters) {
+      Counters other = (Counters) obj;
+      if (size() == other.size()) {
         isEqual = true;
         for (Map.Entry<String, Group> entry : this.counters.entrySet()) {
           String key = entry.getKey();
           Group sourceGroup = entry.getValue();
-          Group targetGroup = counters.getGroup(key);
-          if (!sourceGroup.contentEquals(targetGroup)) {
+          Group targetGroup = other.getGroup(key);
+          if (!sourceGroup.equals(targetGroup)) {
             isEqual = false;
             break;
           }

Modified: hadoop/core/branches/branch-0.20/src/test/org/apache/hadoop/mapred/TestCounters.java
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.20/src/test/org/apache/hadoop/mapred/TestCounters.java?rev=727193&r1=727192&r2=727193&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.20/src/test/org/apache/hadoop/mapred/TestCounters.java (original)
+++ hadoop/core/branches/branch-0.20/src/test/org/apache/hadoop/mapred/TestCounters.java Tue
Dec 16 14:17:39 2008
@@ -61,9 +61,10 @@
     Counters recoveredCounter = 
       Counters.fromEscapedCompactString(compactEscapedString);
     // Check for recovery from string
-    assertTrue("Recovered counter does not match on content", 
-               counter.contentEquals(recoveredCounter));
-    
+    assertEquals("Recovered counter does not match on content", 
+                 counter, recoveredCounter);
+    assertEquals("recovered counter has wrong hash code",
+                 counter.hashCode(), recoveredCounter.hashCode());
   }
   
   public void testCounters() throws IOException {



Mime
View raw message