【问题标题】:Read from reducer output file从减速器输出文件中读取
【发布时间】:2014-12-23 09:56:54
【问题描述】:

我有一些 MapReduce 工作,我想在 Java 代码中进一步使用 Reducer 的输出文件。我如何从这样的文件中读取,因为它在分布式文件系统上?

谢谢

【问题讨论】:

标签: hadoop mapreduce hdfs


【解决方案1】:

由于您想在简单的 java 代码中进一步使用 Reducer 的输出文件,因此您可以使用以下代码:-

` try{
Path pt=new Path("hdfs://npvm11.np.wc1.yellowpages.com:9000/user/john/abc.txt");
    FileSystem fs = FileSystem.get(new Configuration());
    BufferedReader br=new BufferedReader(new InputStreamReader(fs.open(pt)));
    String line;
    line=br.readLine();
    while (line != null){
    System.out.println(line);
    line=br.readLine();
    }
    }
    catch(Exception e){
                }`

将地址替换为您要在java代码中使用的文件地址。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-10
    相关资源
    最近更新 更多