Quellcode durchsuchen

HADOOP-176. Fix a bug in IntWritable.Comparator. Contributed by Dick King.

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk@432385 13f79535-47bb-0310-9956-ffa450edef68
Doug Cutting vor 18 Jahren
Ursprung
Commit
98ce062704
2 geänderte Dateien mit 5 neuen und 2 gelöschten Zeilen
  1. 3 0
      CHANGES.txt
  2. 2 2
      src/java/org/apache/hadoop/io/IntWritable.java

+ 3 - 0
CHANGES.txt

@@ -51,6 +51,9 @@ Trunk (unreleased changes)
     the jobs it depends on have successfully completed.
     (Runping Qi via cutting)
 
+12. HADOOP-176.  Fix a bug in IntWritable.Comparator.
+    (Dick King via cutting)
+
 
 Release 0.5.0 - 2006-08-04
 

+ 2 - 2
src/java/org/apache/hadoop/io/IntWritable.java

@@ -56,7 +56,7 @@ public class IntWritable implements WritableComparable {
   public int compareTo(Object o) {
     int thisValue = this.value;
     int thatValue = ((IntWritable)o).value;
-    return thisValue - thatValue;
+    return (thisValue<thatValue ? -1 : (thisValue==thatValue ? 0 : 1));
   }
 
   public String toString() {
@@ -73,7 +73,7 @@ public class IntWritable implements WritableComparable {
                        byte[] b2, int s2, int l2) {
       int thisValue = readInt(b1, s1);
       int thatValue = readInt(b2, s2);
-      return thisValue - thatValue;
+      return (thisValue<thatValue ? -1 : (thisValue==thatValue ? 0 : 1));
     }
   }