【问题标题】:how to get the filename of all token words in hadoop WordCount app?如何在hadoop WordCount应用程序中获取所有标记词的文件名?
【发布时间】:2015-10-06 12:36:20
【问题描述】:

在hadoop的WordCount任务中,如何获取token word的文件名并在context.write(new Test(filename), one)中使用?

【问题讨论】:

    标签: java apache hadoop mapreduce


    【解决方案1】:

    可以在 Mapper 类中使用以下代码 sn-p 检索文件名。

    FileSplit fileSplit = (FileSplit)context.getInputSplit();
    String filename = fileSplit.getPath().getName();
    

    【讨论】:

    • 嗨 Madhu,您知道在使用 context.write 时如何将文件名作为值发送。在示例 WordCount 中,我想使用 context.write(new Text(stringWord), fileName);而不是 context.write(new Text(stringWord), one);我对 reduce 部分做了一些更改,但仍然无法正常工作。
    • 你能发布你的完整代码吗?...如果你没有通过一个,那么我们将如何找到字数...你能清楚地告诉我
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-01
    • 1970-01-01
    • 2017-06-01
    • 2010-11-19
    相关资源
    最近更新 更多