static class MyReducer extends Reducer<Text, MyObj, Text, Text>{
@Override
protected void reduce(Text key, Iterable<MyObj> v2,Context con)
throws IOException, InterruptedException {
System.out.println("这是一个reduce ");
long count=0L;
List<MyObj> list=new ArrayList<MyObj>();
for(MyObj mm:v2){
count++;
System.out.println("放入list之前time值 "+mm.getUser()+" "+mm.getTime());
list.add(mm);
}
System.out.println("----------------------------------");
for(MyObj mm2:list){
mm2.setCount(new Text(String.valueOf(count)));
System.out.println("放入list之后time值 "+mm2.getUser()+" "+mm2.getTime());
}
}
}
这是reduce的整个代码
|