【问题标题】:Reduce output to desired file based on Key/value pair (HADOOP)根据键/值对 (HADOOP) 将输出减少到所需文件
【发布时间】:2013-04-15 15:46:31
【问题描述】:

是否可以根据 key 将 reducer 输出发送到多个文件?喜欢,

if(key1)
 {
        //output to file1 using context.write() or otherwise
  }
 else
 {
        //output to file2 using context.write() or otherwise
 }

【问题讨论】:

    标签: java hadoop mapreduce key-value reduce


    【解决方案1】:

    您应该能够在您的 reducer 中使用条件逻辑以及 MultipleOutputs 类来实现您想要做的事情。他们在链接的 javadoc 中有一个如何执行此操作的示例。

    【讨论】:

      【解决方案2】:

      另一种可能的方法是实现自定义Partitioner。这样,一个人可以只运行两个(多个)reducer 并根据键的值进行相应的分区。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-10-01
        • 1970-01-01
        • 2018-04-01
        • 2020-03-25
        • 1970-01-01
        • 2010-12-23
        相关资源
        最近更新 更多