-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathWordCountDriver.java
More file actions
47 lines (36 loc) · 1.34 KB
/
WordCountDriver.java
File metadata and controls
47 lines (36 loc) · 1.34 KB
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
39
40
41
42
43
44
45
46
47
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
public class WordCountDriver {
public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
//Job object
//We create job object by passing configuration
Configuration conf=new Configuration();
//Create Job object
//Job job=new Job();
Job job=Job.getInstance(conf,"Word Count");
//Entry point
job.setJarByClass(WordCountDriver.class);
//what is the mapper
job.setMapperClass(WordCountMapper.class);
//What is reducer
job.setReducerClass(WordCountReducer.class);
//when job ip types and o/p types are diff
//we need to specify the data types which job emits.
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(IntWritable.class);
FileInputFormat.addInputPath(job, new Path(args[0]));
FileOutputFormat.setOutputPath(job, new Path(args[1]));
//FileInputFormat<K, V>
//Start MR job
//wait for the progress
boolean result=job.waitForCompletion(true);
int status=result?0:1;
System.exit(status);
}
}