hadoop源码阅读之mapreduce再理解
来源:互联网 发布:曲面电视优缺点知乎 编辑:程序博客网 时间:2024/05/19 14:37
map类
实现于库类中的Mapper接口, Mapper<keyin,valuein,keyout,valueout>,其中包括了map方法void map(K1 key, V1 value, OutputCollector<K2, V2> output, Reporter reporter)
throws IOException; 当然一般要重写;,并且执行会执行该方法;该方法中,包括了四个参数,经过处理,将结果送到上下文,使用context.write(keyout,valueout;
完整方法为
protected void map(Object key, Value value, Context context) throws IOException, InterruptedException{ context.write((KEYOUT) key, (VALUEOUT) value);}reduce类实现了Reducer接口,并一般重写reduce方法,有点不同的是方法参数为(key,valuelist,context);最后将结果返回到context.write(Text key,IntWritable value);来返回结果;然后有个入口,来配置和启动两个类,可以说是mapreduce驱动Configuration conf =new Configuration();得到配置对象;tring[] otherArgs = {"hdfs://localhost:9000/user/hadoop/input/","hdfs://localhost:9000/user/hadoop/output/"};new GenericOptionParser(conf,otherArgs).getRemainingArgs();获得输入输出路径配置指定类;Job job=new Job(conf,"WordCount");定义驱动名?job.setJarbyClass(WordCount.class);job.setMapperClass(Map.class);指定map实现类;job.setCombinerClass(IntSumReducer.class);指定combiner(合并实现类)
job.setReducerClass(reduce.class);指定reduce实现类;
job.setOutputKeyClass(Text.class);指定输出的键的类型的类;
job.setOutputValueClass(IntWritable.class); 制定输出的值的类型的类;
FileInputFormat.addInputPath(job,new Path(otherArgs[0]));指定文件输入输出格式和路径;
FileOutputFormat.addOutpuPath(job,new Path(otherArgs[1]));
还有个mapreduceDriver最小实现类,就叫这个名好像;
阅读全文
0 0
- hadoop源码阅读之mapreduce再理解
- Hadoop之MapReduce运行理解
- hadoop源码分析之MapReduce(一)
- Hadoop源码分析之-MapReduce篇
- hadoop 源码阅读之io篇
- hadoop源码阅读之FileSystem简记
- [Hadoop源码解读]之MapReduce篇之Job类
- Hadoop之Mapreduce------>Mapreduce原理
- MapReduce源码理解
- Hadoop源码之我见--MapReduce部分(一)--Job类
- Hadoop源码之我见--MapReduce部分(二)--RPC调用接口
- [Hadoop源码解读](一)MapReduce篇之InputFormat
- [Hadoop源码解读](二)MapReduce篇之Mapper类
- [Hadoop源码解读](三)MapReduce篇之Job类
- [Hadoop源码解读](六)MapReduce篇之MapTask类
- [Hadoop源码解读](一)MapReduce篇之InputFormat
- [Hadoop源码解读](二)MapReduce篇之Mapper类
- [Hadoop源码解读](三)MapReduce篇之Job类
- Leetcode 303
- Centos7 配置 JDK8
- 【LintCode-93】平衡二叉树(Java实现-递归算法)
- ABP官方文档(四十二)【CSRF和XSRF保护】
- [LeetCode] Maximum Subarray
- hadoop源码阅读之mapreduce再理解
- react native 的赋值比较,空字符串以及undefined
- memcpy(b,a,sizeof(a))
- Android 淡入淡出动画
- Java模拟鼠标键盘输入事件 --- Robot 类
- 判断是否能构成三角形并计算面积
- 【备忘】年薪50万2017年最新Spark2.0从入门到精通教程
- PHP二维数组按照指定的字段排序的函数
- laravel项目中出现mysql嵌套事务的分析