我正在尝试运行一个简单的map reduce程序,其中mapper为同一个键写入两个不同的值,但是当我到达reducer时它们总是相同.
这是我的代码:
public class kaka {
public static class Mapper4 extends Mapper<Text, Text, Text, Text>{
public void map(Text key, Text value, Context context) throws IOException, InterruptedException {
context.write(new Text("a"),new Text("b"));
context.write(new Text("a"),new Text("c"));
}
}
public static class Reducer4 extends Reducer<Text,Text,Text,Text> {
public void reduce(Text key, Iterable<Text> values, Context context) throws IOException, InterruptedException {
Vector<Text> vals = new Vector<Text>();
for (Text val : values){
vals.add(val);
}
return;
}
}
public static void main(String[] args) throws Exception {
//deleteDir(new File("eran"));//todo …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用这个简单的代码将二维数组写入文件:
public void writeZ(PrintWriter out) {
for(int i=0;i<z.length;i++) {
int count = 0;
for (int j=0; j<z[i].length; j++) {
out.print(z[i][j] + " ");
count++;
}
System.out.print( count);
out.println();
}
}
Run Code Online (Sandbox Code Playgroud)
注意:计数仅用于调试
我的问题是文件大小与数组大小不匹配.
行数是正确的(45)但最后一行是1643号而不是数组中的6006号.
有什么想法是什么问题?