1、 最小配置的MapReduce Driver

读取输入文件中的内容,输出到指定目录的输出文件中,此时文件中的内容为:

Key---输入文件每行内容的起始位置。

Value---输入文件每行的原始内容。

输出文件中的内容就是:key+\t+value.

 1 package org.dragon.hadoop.mapreduce.app.minDriver;
 2 
 3 import java.io.IOException;
 4 
 5 import org.apache.hadoop.conf.Configuration;
 6 import org.apache.hadoop.fs.Path;
 7 import org.apache.hadoop.mapreduce.Job;
 8 import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
 9 import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
10 
11 /**
12  *
13  * @author ZhuXY  
14  * @time   2016-3-13 下午9:24:49
15  *
16  */
17 
18 /**
19  * function:最小配置的MapReduce Driver
20  * 
21  * 读取输入文件中的内容,输出到指定目录的输出文件中,
22  *     此时文件中的内容为: Key---输入文件每行内容的起始位置。
23  *                 Value---输入文件每行的原始内容。
24  *     输出文件中的内容就是:key+\t+value.
25  * 
26  * @author ZhuXY
27  * 
28  */
29 public class MinimalDriverMapReduce {
30     
31     /*
32      * Mapper Class
33      */
34     
35     /*
36      * Reducer Class
37      */
38     
39     /*
40      * Driver Code
41      */
42     
43     public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
44         args=new String[]{
45             "hdfs://hadoop-master.dragon.org:9000/wc/mininput/",
46             "hdfs://hadoop-master.dragon.org:9000/wc/minoutput"
47         };
48         
49         // get conf
50         Configuration conf=new Configuration();
51         
52         // create job
53         Job job=new Job(conf, MinimalDriverMapReduce.class.getSimpleName());
54         
55         // set job
56         job.setJarByClass(MinimalDriverMapReduce.class);
57         //    1) set input
58         FileInputFormat.addInputPath(job, new Path(args[0]));
59         
60         //    2) set map
61     
62         //    3) set reduce
63         
64         //    4) set output
65         FileOutputFormat.setOutputPath(job, new Path(args[1]));
66         
67         // submit job
68         boolean isSuccess=job.waitForCompletion(true);
69         
70         // return status
71         System.exit(isSuccess?0:1);
72     }
73 }

2、查看默认的配置

  主要在这个类中:026_默认的MapReduce Driver(最小驱动问题)

026_默认的MapReduce Driver(最小驱动问题)

3、Map与reduce的默认输入输出类型。

026_默认的MapReduce Driver(最小驱动问题)

4、写最小配置默认

导包:

 1 package org.dragon.hadoop.mapreduce.app.minDriver;
 2 
 3 import java.io.IOException;
 4 
 5 import org.apache.hadoop.conf.Configuration;
 6 import org.apache.hadoop.fs.Path;
 7 import org.apache.hadoop.io.LongWritable;
 8 import org.apache.hadoop.io.Text;
 9 import org.apache.hadoop.mapreduce.Job;
10 import org.apache.hadoop.mapreduce.Mapper;
11 import org.apache.hadoop.mapreduce.Reducer;
12 import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
13 import org.apache.hadoop.mapreduce.lib.input.TextInputFormat;
14 import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
15 import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;
16 import org.apache.hadoop.mapreduce.lib.partition.HashPartitioner;
View import Code

相关文章:

  • 2022-12-23
  • 2021-11-25
  • 2022-12-23
  • 2022-01-23
  • 2021-06-20
  • 2021-07-14
  • 2021-06-30
猜你喜欢
  • 2021-05-24
  • 2022-12-23
  • 2021-07-30
  • 2021-05-31
  • 2022-12-23
  • 2022-01-20
相关资源
相似解决方案