0

Multioutputformat クラスを使用して MR コードを実行しています。part**** が出力ファイルの最後に追加されています。どうすればそれを回避できますか?

public class MR_reducer extends 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();
}

}

4

1 に答える 1

0

このコード スニペットは私から機能しています。違いはほとんどありません。

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();
    }
}
于 2015-12-11T10:15:22.290 に答える