【问题标题】:MapReduce with filename as Key, contents as Values, many small filesMapReduce 文件名作为键,内容作为值,许多小文件
【发布时间】:2015-12-07 08:18:52
【问题描述】:

我查看了FileInputFormat where filename is KEY and text contents are VALUEHow to get Filename/File Contents as key/value input for MAP when running a Hadoop MapReduce Job?Getting Filename/FileData as key/value input for Map when running a Hadoop MapReduce Job,但我在起步时遇到了麻烦。以前没有用 Hadoop 做过任何事情,如果其他人可以看到我犯了错误,我很担心会走上错误的道路。

我有一个目录,其中包含大约 10 万个包含 HTML 的小文件,我想使用 Java 实现的 Amazon Elastic MapReduce 创建倒排索引。一旦我有了文件内容,我就知道我想要我的 map 和 reduce 函数做什么。

看了here后,我的理解是我需要继承FileInputFormat并覆盖isSplitable。但是,我的文件名与 HTML 来自的 URL 有关,所以我想保留它们。我只需要用 Text 替换 NullWritable 吗?还有其他建议吗?

【问题讨论】:

    标签: java hadoop elastic-map-reduce


    【解决方案1】:

    您应该使用 WholeFileInputFormat 将整个文件传递给您的映射器

    conf.setInputFormat(WholeFileInputFormat.class);
    conf.setOutputFormat(TextOutputFormat.class);
    FileInputFormat.setInputPaths(conf,new Path("input"));
    FileOutputFormat.setOutputPath(conf,new Path("output"));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-04
      • 2022-01-11
      • 1970-01-01
      • 2017-05-30
      • 2013-05-01
      • 2011-10-09
      相关资源
      最近更新 更多