- package test;
-
- 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.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 test {
-
- public static class findMaxMinMapper
- extends Mapper<Object, Text, Text, IntWritable>{
-
- public void map(Object key, Text value, Context context
- ) throws IOException, InterruptedException {
-
- context.write(new Text("flag"), new IntWritable(1));
-
- }
-
- }
-
- public static class findMaxMinCombiner
- extends Reducer<Text,IntWritable,Text,Text> {
-
- public void reduce(Text key, Iterable<IntWritable> values,
- Context context
- ) throws IOException, InterruptedException {
- context.write(new Text(key), new Text(""));
- }
- }
-
- public static class findMaxMinReducer
- extends Reducer<Text,Text,Text,Text> {
-
- public void reduce(Text key, Iterable<Text> values,
- Context context
- ) throws IOException, InterruptedException {
- context.write(new Text(key), new Text(""));
- }
- }
-
- public static void main(String[] args) throws Exception {
- Configuration conf = new Configuration();
- Job job = Job.getInstance(conf, "findMinMax");
- job.setJarByClass(test.class);
- job.setMapperClass(findMaxMinMapper.class);
- job.setCombinerClass(findMaxMinCombiner.class);
- job.setReducerClass(findMaxMinReducer.class);
- job.setOutputKeyClass(Text.class);
- job.setOutputValueClass(Text.class);
- FileInputFormat.addInputPath(job, new Path(args[0]));
- FileOutputFormat.setOutputPath(job, new Path(args[1]));
- if(!job.waitForCompletion(true))
- System.exit(1);
-
- }
- }
复制代码
输出的目录为空目录,麻烦大神帮忙看看是错在哪个地方?
|