@Override
protected void reduce(LongWritable key, Iterable<Text> values, Context context) throws IOException, InterruptedException {
int k = context.getConfiguration().getInt("k", -1);
double[] result = new double[k];
for (Text value : values) {
String[] ai = value.toString().split(",");
for (int j = 0; j < k; j++) {
result[j] += Double.parseDouble(ai[j]);
}
}
StringBuilder res = new StringBuilder(prefix);
for (int i = 0; i < k; i++) {
res.append(result[i]);
if (i < k - 1) {
res.append(",");
}
}
context.write(key, new Text(res.toString()));
}
MM2.java 文件源码
java
阅读 21
收藏 0
点赞 0
评论 0
项目:MRNMF
作者:
评论列表
文章目录