hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject svn commit: r1425187 - in /hadoop/common/branches/branch-1: CHANGES.txt src/mapred/org/apache/hadoop/mapred/SortedRanges.java
Date Fri, 21 Dec 2012 23:20:28 GMT
Author: llu
Date: Fri Dec 21 23:20:28 2012
New Revision: 1425187

URL: http://svn.apache.org/viewvc?rev=1425187&view=rev
Log:
MAPREDUCE-4272. SortedRanges.Range#compareTo is not spec compliant.  (Yu Gao via llu)

Modified:
    hadoop/common/branches/branch-1/CHANGES.txt
    hadoop/common/branches/branch-1/src/mapred/org/apache/hadoop/mapred/SortedRanges.java

Modified: hadoop/common/branches/branch-1/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1/CHANGES.txt?rev=1425187&r1=1425186&r2=1425187&view=diff
==============================================================================
--- hadoop/common/branches/branch-1/CHANGES.txt (original)
+++ hadoop/common/branches/branch-1/CHANGES.txt Fri Dec 21 23:20:28 2012
@@ -161,6 +161,9 @@ Release 1.2.0 - unreleased
 
   BUG FIXES
 
+    MAPREDUCE-4272. SortedRanges.Range#compareTo is not spec compliant.
+    (Yu Gao via llu)
+
     HADOOP-9051 Fix ant clean/test with circular symlinks in build dir. (llu)
 
     MAPREDUCE-4396. Port support private distributed cache to 

Modified: hadoop/common/branches/branch-1/src/mapred/org/apache/hadoop/mapred/SortedRanges.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1/src/mapred/org/apache/hadoop/mapred/SortedRanges.java?rev=1425187&r1=1425186&r2=1425187&view=diff
==============================================================================
--- hadoop/common/branches/branch-1/src/mapred/org/apache/hadoop/mapred/SortedRanges.java
(original)
+++ hadoop/common/branches/branch-1/src/mapred/org/apache/hadoop/mapred/SortedRanges.java
Fri Dec 21 23:20:28 2012
@@ -271,7 +271,7 @@ class SortedRanges implements Writable{
     }
     
     public boolean equals(Object o) {
-      if(o!=null && o instanceof Range) {
+      if (o instanceof Range) {
         Range range = (Range)o;
         return startIndex==range.startIndex &&
         length==range.length;
@@ -285,10 +285,11 @@ class SortedRanges implements Writable{
     }
     
     public int compareTo(Range o) {
-      if(this.equals(o)) {
-        return 0;
-      }
-      return (this.startIndex > o.startIndex) ? 1:-1;
+      // Ensure sgn(x.compareTo(y) == -sgn(y.compareTo(x))
+      return this.startIndex < o.startIndex ? -1 :
+          (this.startIndex > o.startIndex ? 1 :
+          (this.length < o.length ? -1 :
+          (this.length > o.length ? 1 : 0)));
     }
 
     public void readFields(DataInput in) throws IOException {



Mime
View raw message