hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From omal...@apache.org
Subject svn commit: r669639 - in /hadoop/core/trunk: CHANGES.txt src/core/org/apache/hadoop/fs/kfs/KFSInputStream.java src/test/org/apache/hadoop/fs/kfs/TestKosmosFileSystem.java
Date Thu, 19 Jun 2008 18:42:35 GMT
Author: omalley
Date: Thu Jun 19 11:42:35 2008
New Revision: 669639

URL: http://svn.apache.org/viewvc?rev=669639&view=rev
Log:
HADOOP-3569. KFS input stream read() now correctly reads 1 byte
instead of 4. Contributed by Sriram Rao.

Modified:
    hadoop/core/trunk/CHANGES.txt
    hadoop/core/trunk/src/core/org/apache/hadoop/fs/kfs/KFSInputStream.java
    hadoop/core/trunk/src/test/org/apache/hadoop/fs/kfs/TestKosmosFileSystem.java

Modified: hadoop/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=669639&r1=669638&r2=669639&view=diff
==============================================================================
--- hadoop/core/trunk/CHANGES.txt (original)
+++ hadoop/core/trunk/CHANGES.txt Thu Jun 19 11:42:35 2008
@@ -631,6 +631,9 @@
     HADOOP-3546. TaskTracker re-initialization gets stuck in cleaning up.
     (Amareshwari Sriramadasu via ddas)
 
+    HADOOP-3569. KFS input stream read() now correctly reads 1 byte
+    instead of 4. (Sriram Rao via omalley)
+
 Release 0.17.1 - Unreleased
 
   INCOMPATIBLE CHANGES

Modified: hadoop/core/trunk/src/core/org/apache/hadoop/fs/kfs/KFSInputStream.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/core/org/apache/hadoop/fs/kfs/KFSInputStream.java?rev=669639&r1=669638&r2=669639&view=diff
==============================================================================
--- hadoop/core/trunk/src/core/org/apache/hadoop/fs/kfs/KFSInputStream.java (original)
+++ hadoop/core/trunk/src/core/org/apache/hadoop/fs/kfs/KFSInputStream.java Thu Jun 19 11:42:35
2008
@@ -79,13 +79,13 @@
         if (kfsChannel == null) {
             throw new IOException("File closed");
         }
-        byte b[] = new byte[4];
-        int res = read(b, 0, 4);
-        if (res == 4) {
+        byte b[] = new byte[1];
+        int res = read(b, 0, 1);
+        if (res == 1) {
           if (statistics != null) {
             statistics.incrementBytesRead(1);
           }
-          return (b[0] + (b[1] << 8) + (b[2] << 16) + (b[3] << 24));  
       
+          return ((int) (b[0] & 0xff));
         }
         return -1;
     }

Modified: hadoop/core/trunk/src/test/org/apache/hadoop/fs/kfs/TestKosmosFileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/test/org/apache/hadoop/fs/kfs/TestKosmosFileSystem.java?rev=669639&r1=669638&r2=669639&view=diff
==============================================================================
--- hadoop/core/trunk/src/test/org/apache/hadoop/fs/kfs/TestKosmosFileSystem.java (original)
+++ hadoop/core/trunk/src/test/org/apache/hadoop/fs/kfs/TestKosmosFileSystem.java Thu Jun
19 11:42:35 2008
@@ -134,7 +134,10 @@
         for (int i = 0; i < data.length; i++)
             data[i] = (byte) (i % 16);
 
-        // write an integer
+        // write 4 bytes and read them back; read API should return a byte per call
+        s1.write(32);
+        s1.write(32);
+        s1.write(32);
         s1.write(32);
         // write some data
         s1.write(data, 0, data.length);
@@ -147,6 +150,12 @@
 
         v = s2.read();
         assertEquals(v, 32);
+        v = s2.read();
+        assertEquals(v, 32);
+        v = s2.read();
+        assertEquals(v, 32);
+        v = s2.read();
+        assertEquals(v, 32);
 
         assertEquals(s2.available(), data.length);
 



Mime
View raw message