import [Link].
IOException;
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
import [Link];
import [Link];
import [Link];
import [Link];
public class WordCount {
public static class Map extends Mapper<LongWritable, Text, Text, IntWritable> {
private final static IntWritable one = new IntWritable(1);
private Text word = new Text();
public void map(LongWritable key, Text value, Context context) throws
IOException, InterruptedException {
String line = [Link]();
StringTokenizer tokenizer = new StringTokenizer(line);
while ([Link]()) {
[Link]([Link]());
[Link](word, one);
}
}
}
public static class Reduce extends Reducer<Text, IntWritable, Text,
IntWritable> {
public void reduce(Text key, Iterable<IntWritable> values, Context context)
throws IOException, InterruptedException {
int sum = 0;
for (IntWritable val : values) {
sum += [Link]();
}
[Link](key, new IntWritable(sum));
}
}
public static void main(String[] args) throws Exception {
if ([Link] != 2) {
[Link]("Usage: WordCount <input path> <output path>");
[Link](-1);
}
Configuration conf = new Configuration();
Job job = [Link](conf, "WordCount");
[Link]([Link]); // Specify the Jar class
[Link]([Link]);
[Link]([Link]);
[Link]([Link]);
[Link]([Link]);
[Link]([Link]);
[Link]([Link]);
// Delete output path if it exists
FileSystem fs = [Link](conf);
Path outputPath = new Path(args[1]);
if ([Link](outputPath)) {
[Link](outputPath, true);
}
[Link](job, new Path(args[0]));
[Link](job, outputPath);
// Wait for job completion
[Link]([Link](true) ? 0 : 1);
}
}