Author: llu Date: Fri Dec 21 23:10:52 2012 New Revision: 1425180 URL: http://svn.apache.org/viewvc?rev=1425180&view=rev Log: MAPREDUCE-4272. SortedRanges.Range#compareTo was not spec compliant. (Yu Gao via llu)
Modified: hadoop/common/trunk/hadoop-mapreduce-project/CHANGES.txt hadoop/common/trunk/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/SortedRanges.java Modified: hadoop/common/trunk/hadoop-mapreduce-project/CHANGES.txt URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-mapreduce-project/CHANGES.txt?rev=1425180&r1=1425179&r2=1425180&view=diff ============================================================================== --- hadoop/common/trunk/hadoop-mapreduce-project/CHANGES.txt (original) +++ hadoop/common/trunk/hadoop-mapreduce-project/CHANGES.txt Fri Dec 21 23:10:52 2012 @@ -81,6 +81,9 @@ Trunk (Unreleased) BUG FIXES + MAPREDUCE-4272. SortedRanges.Range#compareTo is not spec compliant. + (Yu Gao via llu) + MAPREDUCE-4356. [Rumen] Provide access to the method ParsedTask.obtainTaskAttempts(). (ravigummadi) Modified: hadoop/common/trunk/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/SortedRanges.java URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/SortedRanges.java?rev=1425180&r1=1425179&r2=1425180&view=diff ============================================================================== --- hadoop/common/trunk/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/SortedRanges.java (original) +++ hadoop/common/trunk/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/SortedRanges.java Fri Dec 21 23:10:52 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 {