2012-04-06 98 views

回答

1

直接從命令行使用hadoop fs的一些混合物 - 除非您想深入研究通過awk腳本輸出輸出,否則不太可能。

你可以只寫一個簡單的Java類讀取該文件,我猜是這樣的:

public class IntFileReader extends Configured implements Tool { 
    public static void main(String[] args) throws Exception { 
     ToolRunner.run(new IntFileReader(), args); 
    } 

    public int run(String[] args) throws Exception { 
     FileSystem fs = FileSystem.get(getConf()); 

     FSDataInputStream is = fs.open(new Path(args[0])); 

     while (is.available() != -1) { 
      System.out.println(is.readInt()); 
     } 

     is.close(); 

     return 0; 
    } 
} 

然後你就可以在一個罐子捆綁並執行:

hadoop jar myJar.jar IntFileReader /path/to/file/in/hdfs 
相關問題