32 lines
1.2 KiB
Java
32 lines
1.2 KiB
Java
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 CharacterCountDriver {
|
|
public static void main(String[] args) throws Exception {
|
|
if (args.length != 2) {
|
|
System.err.println("Usage: CharacterCountDriver <input path> <output path>");
|
|
System.exit(-1);
|
|
}
|
|
|
|
Configuration conf = new Configuration();
|
|
Job job = Job.getInstance(conf, "Character Count");
|
|
job.setJarByClass(CharacterCountDriver.class);
|
|
job.setMapperClass(CharacterCountMapper.class);
|
|
job.setCombinerClass(CharacterCountReducer.class);
|
|
job.setReducerClass(CharacterCountReducer.class);
|
|
job.setOutputKeyClass(Text.class);
|
|
job.setOutputValueClass(IntWritable.class);
|
|
|
|
FileInputFormat.addInputPath(job, new Path(args[0]));
|
|
FileOutputFormat.setOutputPath(job, new Path(args[1]));
|
|
|
|
System.exit(job.waitForCompletion(true) ? 0 : 1);
|
|
}
|
|
}
|
|
|