hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cdoug...@apache.org
Subject svn commit: r641613 - in /hadoop/core/trunk: CHANGES.txt src/java/org/apache/hadoop/io/BytesWritable.java src/test/org/apache/hadoop/io/TestBytesWritable.java
Date Wed, 26 Mar 2008 22:37:40 GMT
Author: cdouglas
Date: Wed Mar 26 15:37:36 2008
New Revision: 641613

URL: http://svn.apache.org/viewvc?rev=641613&view=rev
Log:
HADOOP-3094. Fix BytesWritable.toString to avoid extending the sign bit.
Contributed by Owen O'Malley.



Modified:
    hadoop/core/trunk/CHANGES.txt
    hadoop/core/trunk/src/java/org/apache/hadoop/io/BytesWritable.java
    hadoop/core/trunk/src/test/org/apache/hadoop/io/TestBytesWritable.java

Modified: hadoop/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=641613&r1=641612&r2=641613&view=diff
==============================================================================
--- hadoop/core/trunk/CHANGES.txt (original)
+++ hadoop/core/trunk/CHANGES.txt Wed Mar 26 15:37:36 2008
@@ -371,6 +371,9 @@
     HADOOP-3046. Fix the raw comparators for Text and BytesWritables
     to use the provided length rather than recompute it. (omalley)
 
+    HADOOP-3094. Fix BytesWritable.toString to avoid extending the sign bit
+    (Owen O'Malley via cdouglas)
+
 Release 0.16.2 - Unreleased
 
   BUG FIXES

Modified: hadoop/core/trunk/src/java/org/apache/hadoop/io/BytesWritable.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/java/org/apache/hadoop/io/BytesWritable.java?rev=641613&r1=641612&r2=641613&view=diff
==============================================================================
--- hadoop/core/trunk/src/java/org/apache/hadoop/io/BytesWritable.java (original)
+++ hadoop/core/trunk/src/java/org/apache/hadoop/io/BytesWritable.java Wed Mar 26 15:37:36
2008
@@ -174,7 +174,7 @@
       if (idx != 0) {
         sb.append(' ');
       }
-      String num = Integer.toHexString((int) bytes[idx]);
+      String num = Integer.toHexString(0xff & bytes[idx]);
       // if it is only one digit, add a leading 0.
       if (num.length() < 2) {
         sb.append('0');

Modified: hadoop/core/trunk/src/test/org/apache/hadoop/io/TestBytesWritable.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/test/org/apache/hadoop/io/TestBytesWritable.java?rev=641613&r1=641612&r2=641613&view=diff
==============================================================================
--- hadoop/core/trunk/src/test/org/apache/hadoop/io/TestBytesWritable.java (original)
+++ hadoop/core/trunk/src/test/org/apache/hadoop/io/TestBytesWritable.java Wed Mar 26 15:37:36
2008
@@ -80,5 +80,16 @@
     assertTrue(buf[2].compareTo(buf[3]) > 0);
     assertTrue(buf[3].compareTo(buf[4]) < 0);
   }
+  
+  private void checkToString(byte[] input, String expected) {
+    String actual = new BytesWritable(input).toString();
+    assertEquals(expected, actual);
+  }
+
+  public void testToString() {
+    checkToString(new byte[]{0,1,2,0x10}, "00 01 02 10");
+    checkToString(new byte[]{-0x80, -0x7f, -0x1, -0x2, 1, 0}, 
+                  "80 81 ff fe 01 00");
+  }
 }
 



Mime
View raw message