import java.io.IOException;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
public class sexCount {
public static void main(String[] args) throws Exception {
Job job = new Job();
job.setJarByClass(sexCount.class);
job.setJobName("Job2 MapReduce");
FileInputFormat.addInputPath(job, new Path("/data/zzti/lec/input"));
FileOutputFormat.setOutputPath(job, new Path("/data/zzti/lec/Job2/output"));
job.setMapperClass(Job2Mapper.class);
job.setReducerClass(Job2Reducer.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(Text.class);
System.exit(job.waitForCompletion(true) ? 0 : 1);
}
private static class Job2Mapper extends Mapper<LongWritable, Text, Text, Text> {
@Override
protected void setup(Mapper<LongWritable, Text, Text, Text>.Context context)
throws IOException, InterruptedException {
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余2页未读,立即下载