我在使用hadoop v2的这个减速机上的输出遇到了一些问题
出于某种原因,如果我尝试将string.valueof(pagerank)连接到字符串上,则更新的值不会写入输出。而是为每个值写入值0.15。有人能帮我吗?如果需要的话,我会提供更多的信息。谢谢!
static class LoopingPRReducer extends Reducer<Text, Text, Text, Text> {
// The main reduce() function; the input key/value classes must match the first two above, and the key/value classes in your emit() statement must match the latter two above.
// Make sure that the output key/value classes also match those set in your job's configuration (see below).
@Override
protected void reduce(Text key, Iterable<Text> values, Context context) throws IOException, InterruptedException {
String outlinks = null;
double sum = 0.0;
for (Text value: values) {
String rank = value.toString();
if (rank.contains("[")) {
outlinks = rank;
continue;
}
sum += Double.parseDouble(rank);
}
double pageRank = (sum)*0.85+0.15;
String newRank = "[" + String.valueOf(pageRank)+"]"; //formatted output doesn't work
context.write(key, new Text(newRank));}
暂无答案!
目前还没有任何答案,快来回答吧!