import java.io.IOException;import java.util.regex.Matcher;import java.util.regex.Pattern;import org.apache.hadoop.io.LongWritable;import org.apache.hadoop.io.Text;import org.apache.hadoop.mapreduce.Mapper;public class FilterCidMap2 extends Mapper{ private long count=0; @Override protected void map(LongWritable key, Text value, Mapper .Context context) throws IOException, InterruptedException { try { //取得读取的行数 count=key.get(); //正常逻辑 context.write(new Text(), new LongWritable(1)); } catch (Exception e) { e.printStackTrace(); } } //map 方法调用完后才调用的 @Override protected void cleanup(Mapper .Context context) throws IOException, InterruptedException { //map清理资源的操作 //在reduce中把linescount取出来就行了 context.write(new Text("linesCount"), new LongWritable(count)); }}