以下は、MapReduceジョブで使用しているReducer関数のコードです。各値に追加されたイテレータ+カスタム文字列( " * ---")から値を返す必要があります。ただし、代わりにカスタム文字列を2回追加しています。
たとえば、値がabcの場合、印刷する代わりに
abc***---
印刷中です
abc***---***---
なぜそれが起こっているのですか?
コード:
public static class Reduce extends MapReduceBase implements Reducer<Text, Text, Text, Text> {
public void reduce(Text key, Iterator<Text> values, OutputCollector<Text, Text> output, Reporter reporter) throws IOException {
while (values.hasNext()) {
Text t=values.next();
String s = "***---";
t.append(s.getBytes(), 0, s.length());
output.collect(key, t);
}
}
}