20,808
社区成员
发帖
与我相关
我的任务
分享
public static class MyMapper extends TableMapper<Text,IntWritable>{
private final IntWritable one = new IntWritable(1);
@Override
public void map(ImmutableBytesWritable row, Result value, Context context)
throws IOException,InterruptedException{
for(KeyValue kv : value.list()){
context.write(new Text(kv.getKey()), one);
}
}
}
public static class MyReducer extends Reducer<Text, IntWritable, Text, IntWritable> {
private static Map<String,Integer> countMap = new HashMap<String,Integer>();
public void reduce(Text key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException {
int i = 0;
for (IntWritable val : values) {
i += val.get();
}
countMap.put(key.toString(),i);
}
}