-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGrepJob.Java
39 lines (32 loc) · 1.19 KB
/
GrepJob.Java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package june_6_2013;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.input.TextInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;
import org.apache.hadoop.mapreduce.Job;
public class GrepJob {
public static void main(String[] args)throws Exception {
Configuration conf=new Configuration();
if(args.length!=2)
{
System.err.println("Grep Job needs 2 args");
System.exit(2);
}
Job job=new Job(conf,"Grep Job");
job.setJarByClass(GrepJob.class);
job.setMapperClass(GrepMapper.class);
//job.setCombinerClass(WordCountReducer.class);
//job.setReducerClass(WordCountReducer.class);
job.setOutputKeyClass(NullWritable.class);
job.setOutputValueClass(Text.class);
job.setInputFormatClass(TextInputFormat.class);
job.setOutputFormatClass(TextOutputFormat.class);
FileInputFormat.addInputPath(job,new Path(args[0]));
FileOutputFormat.setOutputPath(job, new Path(args[1]));
System.exit(job.waitForCompletion(true)?0:1);
}
}