设计思路:
map阶段:map读取每行记录,将部门作为key,工资作为value输出;
reduce阶段:将相同的key即同部门的工资作叠加运算得出总工资,同时在遍历value时,定义一个计数变量,统计该部门的人员数,最后总工资除以人员数得出该部门的平均工资。
package week06;
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.*;
import org.apache.hadoop.mapreduce.*;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.util.GenericOptionsParser;
import org.apache.hadoop.util.Tool;
import org.apache.hadoop.util.ToolRunner;
// 2) 求各个部门的人数和平均工资
public class Emp_Test2 extends Configured implements Tool {
/**
* 计数器 用于计数各种异常数据
*/
enum Counter {
LINESKIP,
}
/**
* M