hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ha...@apache.org
Subject svn commit: r1355636 - in /hadoop/common/trunk/hadoop-common-project/hadoop-common: CHANGES.txt src/main/java/org/apache/hadoop/fs/shell/Display.java
Date Sat, 30 Jun 2012 05:04:24 GMT
Author: harsh
Date: Sat Jun 30 05:04:23 2012
New Revision: 1355636

URL: http://svn.apache.org/viewvc?rev=1355636&view=rev
Log:
HADOOP-8449. hadoop fs -text fails with compressed sequence files with the codec file extension.
(harsh)

Modified:
    hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt
    hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Display.java

Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt?rev=1355636&r1=1355635&r2=1355636&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt Sat Jun 30 05:04:23
2012
@@ -215,6 +215,9 @@ Branch-2 ( Unreleased changes )
     HADOOP-8524. Allow users to get source of a Configuration
     parameter (harsh)
 
+    HADOOP-8449. hadoop fs -text fails with compressed sequence files
+    with the codec file extension (harsh)
+
   BUG FIXES
 
     HADOOP-8372. NetUtils.normalizeHostName() incorrectly handles hostname

Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Display.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Display.java?rev=1355636&r1=1355635&r2=1355636&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Display.java
(original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Display.java
Sat Jun 30 05:04:23 2012
@@ -107,30 +107,37 @@ class Display extends FsCommand {
     @Override
     protected InputStream getInputStream(PathData item) throws IOException {
       FSDataInputStream i = (FSDataInputStream)super.getInputStream(item);
-      
-      // check codecs
-      CompressionCodecFactory cf = new CompressionCodecFactory(getConf());
-      CompressionCodec codec = cf.getCodec(item.path);
-      if (codec != null) {
-        return codec.createInputStream(i);
-      }
 
+      // Check type of stream first
       switch(i.readShort()) {
         case 0x1f8b: { // RFC 1952
+          // Must be gzip
           i.seek(0);
           return new GZIPInputStream(i);
         }
         case 0x5345: { // 'S' 'E'
+          // Might be a SequenceFile
           if (i.readByte() == 'Q') {
             i.close();
             return new TextRecordInputStream(item.stat);
           }
+        }
+        default: {
+          // Check the type of compression instead, depending on Codec class's
+          // own detection methods, based on the provided path.
+          CompressionCodecFactory cf = new CompressionCodecFactory(getConf());
+          CompressionCodec codec = cf.getCodec(item.path);
+          if (codec != null) {
+            return codec.createInputStream(i);
+          }
           break;
         }
       }
+
+      // File is non-compressed, or not a file container we know.
       i.seek(0);
       return i;
-    }    
+    }
   }
 
   protected class TextRecordInputStream extends InputStream {



Mime
View raw message