私のマッパーは、次のタプルを送信する必要があります。
<custID,prodID,rate>
そして、reduce フェーズで必要になるため、 custID をキーとして、値として prodID と rate を一緒にレデューサーに送信したいと考えています。これを行う最良の方法はどれですか?
public void map(Object key, Text value, Context context)
throws IOException, InterruptedException {
String[] col = value.toString().split(",");
custID.set(col[0]);
data.set(col[1] + "," + col[2]);
context.write(custID, data);
}
public void reduce(Text key, Iterable<Text> values, Context context)
throws IOException, InterruptedException {
for (Text val : values) {
String[] temp = val.toString().split(",");
Text rate = new Text(temp[1]);
result.set(rate);
context.write(key, result);
}
}