2012-04-06 83 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 
相关问题