You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-user@hadoop.apache.org by liw_goldgov <li...@163.com> on 2010/07/24 09:02:15 UTC

It is possible a bug,about BooleanWritable

hello common-user:


I use BooleanWritable type as Mapper's out key,bug it seems have a problem.

such as:

10/07/22 04:01:42 INFO mapred.JobClient:  map 100% reduce 30%
10/07/22 04:01:44 INFO mapred.JobClient: Task Id : attempt_201007220357_0001_r_000000_1, Status : FAILED
java.lang.ArrayIndexOutOfBoundsException: 1
        at org.apache.hadoop.io.WritableComparator.readInt(WritableComparator.java:153)
        at org.apache.hadoop.io.BooleanWritable$Comparator.compare(BooleanWritable.java:103)
        at org.apache.hadoop.mapreduce.ReduceContext.nextKeyValue(ReduceContext.java:120)
        at org.apache.hadoop.mapreduce.ReduceContext.nextKey(ReduceContext.java:92)
        at org.apache.hadoop.mapreduce.Reducer.run(Reducer.java:175)
        at org.apache.hadoop.mapred.ReduceTask.runNewReducer(ReduceTask.java:566)
        at org.apache.hadoop.mapred.ReduceTask.run(ReduceTask.java:408)
        at org.apache.hadoop.mapred.Child.main(Child.java:170)

and I change it to Text type ,the problem was solved.

        Best BadGuys
        wlwolf87@gmail.com 
          2010-07-24 

Re: It is possible a bug,about BooleanWritable

Posted by Owen O'Malley <om...@apache.org>.
It is a bug. It was fixed as part of MAPREDUCE-365. The relevant fix is:

Index: src/java/org/apache/hadoop/io/BooleanWritable.java
===================================================================
--- src/java/org/apache/hadoop/io/BooleanWritable.java  (revision 769338)
+++ src/java/org/apache/hadoop/io/BooleanWritable.java  (revision 769339)
@@ -100,9 +100,7 @@

     public int compare(byte[] b1, int s1, int l1,
                        byte[] b2, int s2, int l2) {
-      boolean a = (readInt(b1, s1) == 1) ? true : false;
-      boolean b = (readInt(b2, s2) == 1) ? true : false;
-      return ((a == b) ? 0 : (a == false) ? -1 : 1);
+      return compareBytes(b1, s1, l1, b2, s2, l2);
     }
   }


-- Owen