0
私は、reduce関数を記述して、Iterableの値を出力するためにreduce関数を書くことを新しくしました。以下は私の印刷機能である:一意の値または別個の値を出力する
public class Reduce extends Reducer<Text, Text, Text, Text> {
protected void reduce(Text key, Iterable<Text> values, Context context) throws IOException, InterruptedException {
StringBuilder builder = new StringBuilder();
for (Text value : values) {
builder.append("<");
builder.append(value);
builder.append(",");
builder.append(key);
builder.append(">");
builder.append("\n");
context.write(new Text(builder.substring(0, builder.length())), key);
}
}
}
出力は次のとおりです。
問題は、値がすなわち< 2,1>を繰り返し取得していることであるが2回繰り返される...私の要件は、後にあります< 2,1>私は直接< 3,1>を取得し、次に< 4,1>を取得する必要があります。要するに私は一意でなければなりません。
私の最終的な出力は次のようになります。
<2,1>
<3,1>
<4,1>
<3,2>
<4,2>
<1,2>
<4,3>
示唆してください。
こんにちはそれは働いた...私はとてもダムです...私は再びそれを使用する前に私のビルダーをクリアしていない...ありがとうございます:) – user1277070