我正在尝试运行一个mapreduce作业,它在我的机器上运行得很好,但在其他机器上却没有运行。我的绘图机在生产机器上的输出不正确。
实际输出应该是
1,1 M,1,1
1,1 M,2,3
1,2 M,1,1
等等
Map器输出有一些额外的值,如下所示
0 1,1 M,1,1
0 1,1 M,2,3
0 1,2 M,1,1
除了实际值(即,正确的输出,加上一些额外的不正确的值)之外,Map器代码是
public static class Map extends Mapper<LongWritable, Text, Text, Text> {
//output keys and values
private Text key_ikM = new Text();
private Text key_ikMt = new Text();
private Text outp = new Text();
private Text outpt = new Text();
public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
/*the input is row no, column number, value*/
String[] line = value.toString().split(",", 3);
String row_i = line[0];
String col_j = line[1];
String val_ij = line[2];
/*code to calculate max value of row_id in the dataset*/
int max_row=3;
//int max_col=5;
for(int k=1; k<=max_row; k++){
String keyM = row_i + "," + Integer.toString(k);
String value_ij = "M" + "," + col_j + "," + val_ij;
key_ikM.set(keyM);
outp.set(value_ij);
context.write(key_ikM, outp);
}
for(int i=1; i<=max_row; i++){
String keyMt = Integer.toString(i) + "," + row_i;
String value_ik = "Mt" + "," + col_j + "," + val_ij;
key_ikMt.set(keyMt);
outpt.set(value_ik);
context.write(key_ikMt, outpt); // transpose of M
}
}
}
哪里 row_i
, col_j
以及 val_ij
从输入中获取。
为什么要生成这些额外的0?它是由integer.tostring()创建的吗?我应该用别的东西吗?请帮忙。谢谢您。
暂无答案!
目前还没有任何答案,快来回答吧!