查询Hadoop 0.20.203的MultipleOutputs

时间:2012-02-25 00:50:55

标签: hadoop mapreduce

我正在尝试在Reducer中使用MultipleOutputs,以便使用分区程序写入多个文件。为此,我试图在Reducer.setup()中使用如下构造其对象:

public static class MOReduce extends Reducer<Text, Integer, Text, Integer> {
    private MultipleOutputs mos;

    public void setup( Reducer.Context context ) {
        mos = new MultipleOutputs( context.getConfiguration() );
    }

但由于以下原因我面临问题:

  • 根据documentation,setup函数将Reducer.Context作为参数
  • 虽然根据此documentation,MultipleOutputs构造函数需要JobConf。所以,基本上我无法从Reducer.Context
  • 中提取JobConf
  • 我已经尝试过任何函数,比如Reducer.Context.getConfXXX,它返回JobConf,但只有一个函数getConfiguration()返回JobContext

那么,您能否建议我如何解决此问题并实例化MultipleOutputs对象。

1 个答案:

答案 0 :(得分:0)

看看这个Multiple Output in Reducer

hadoop中有两个API可用于创建和管理mapreduce作业。一个是JobConf,一个是Job。您似乎正在使用Job。对于您的情况,如上面的链接,您需要创建自己的RecordWriter类和OutputFormat类。使用RecordWriter,您可以控制要写入的文件和时间。