【问题标题】:Avoid part-r-00***** from appending in the end of MapReduce job output file避免在 MapReduce 作业输出文件的末尾附加 part-r-00*****
【发布时间】:2015-12-11 09:22:48
【问题描述】:

我正在使用 Multioutputformat 类运行 MR 代码。 part**** 被附加到我的输出文件的末尾。我该如何避免呢?

公共类 MR_reducer 扩展 减速器{

private MultipleOutputs multipleOutputs;

@Override
protected void setup(Context context) throws IOException,
        InterruptedException {
    multipleOutputs = new MultipleOutputs(context);
}


@Override
protected void reduce(Text key, Iterable<Text> values, Context context)
        throws IOException, InterruptedException {
    for (Text value : values) {
        multipleOutputs.write(value, new Text(""), key.toString());
    }
}


@Override
protected void cleanup(Context context) throws IOException,
        InterruptedException {
    multipleOutputs.close();
}

}

【问题讨论】:

    标签: hadoop mapreduce multipleoutputs


    【解决方案1】:

    这个代码 sn-p 是我的工作。你有一些不同:

    public static class Reduce extends Reducer<Text, Text, NullWritable, Text> {
    
        private MultipleOutputs<NullWritable, Text> multipleOutputs;
    
        protected void setup(Context context) throws IOException, InterruptedException {
            multipleOutputs = new MultipleOutputs<NullWritable, Text>(context);
    
        }
    
        public void reduce(Text key, Iterable<Text> values, Context output) throws IOException, InterruptedException {
            while (values.iterator().hasNext()) {
                multipleOutputs.write(NullWritable.get(), values.iterator().next(), key.toString());
            }
        }
    
        protected void cleanup(Context context) throws IOException, InterruptedException {
            multipleOutputs.close();
        }
    }
    

    【讨论】:

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