MapReduce八股文模板
来源:互联网 发布:tensorflow 物体识别 编辑:程序博客网 时间:2024/06/12 23:34
package com.bruce.mapreduce;import java.io.IOException;import org.apache.hadoop.conf.Configuration;import org.apache.hadoop.conf.Configured;import org.apache.hadoop.fs.Path;import org.apache.hadoop.io.IntWritable;import org.apache.hadoop.io.LongWritable;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;import org.apache.hadoop.util.Tool;import org.apache.hadoop.util.ToolRunner;public class moduleMapReduce extends Configured implements Tool {// step 1: Map Class/** * Mapper<KEYIN, VALUEIN, KEYOUT, VALUEOUT> * *///TODO update paragrampublic static class ModuleMapper extendsMapper<LongWritable, Text, Text, IntWritable> {@Overrideprotected void map(LongWritable key, Text value, Context context)throws IOException, InterruptedException {// TODO Auto-generated method stub}}// step 2: Reduce Class/** * Reducer<KEYIN, VALUEIN, KEYOUT, VALUEOUT> * *///TODOpublic static class ModuleReducer extendsReducer<Text, IntWritable, Text, IntWritable> {@Overrideprotected void reduce(Text key, Iterable<IntWritable> values,Context context) throws IOException, InterruptedException {// TODO Auto-generated method stub}}// step 3: Driver ,component job, implements Toolpublic int run(String[] args) throws Exception {// 1: get configrationConfiguration configuration = getConf();// 2: create JobJob job = Job.getInstance(configuration, this.getClass().getSimpleName());// run jarjob.setJarByClass(this.getClass());// 3: set job// input -> map -> reduce -> output// 3.1 inputPath inPath = new Path(args[0]);FileInputFormat.addInputPath(job, inPath);// 3.2: mapjob.setMapperClass(ModuleMapper.class);//TODO update paragramjob.setMapOutputKeyClass(Text.class);job.setMapOutputValueClass(IntWritable.class);// 3.3: reducejob.setReducerClass(ModuleReducer.class);//TODOjob.setOutputKeyClass(Text.class);job.setOutputValueClass(IntWritable.class);// 3.4: outputPath outPath = new Path(args[1]);FileOutputFormat.setOutputPath(job, outPath);// 4: submit jobboolean isSuccess = job.waitForCompletion(true);return isSuccess ? 0 : 1;}// step 4: run programpublic static void main(String[] args) throws Exception {// 1: get configrationConfiguration configuration = new Configuration();//int status = new moduleMapReduce().run(args);int status = ToolRunner.run(configuration, new moduleMapReduce(), args);System.exit(status);}}
阅读全文
0 0
- MapReduce八股文模板
- 八股文
- 技术八股文
- MapReduce模板
- Mapreduce模板
- MapReduce模板程序
- MapReduce模板程序
- MapReduce模板2
- mapreduce 模板代码
- MapReduce 编程模板
- MapReduce编程模板
- MapReduce的模板
- 写八股文的几个想法
- hadoop 中的mapreduce编程模板
- 辩证法是八股文的形式源泉
- 基于【八股文】格式编写WordCount程序
- 新版MapReduce的API编程简单模板
- hadoop mapReduce程序模板-倒排索引
- htonl()函数学习
- JTable表头排序后,row获取错乱的问题解决
- C++学习日志之二—贪吃蛇网游化框架搭建2
- 明日工作中需要用到的两个方法 java中File的基本使用
- 同步代码块、同步方法、锁总结
- MapReduce八股文模板
- Healthy Holsteins 健康的好斯坦奶牛
- webpack搭建ES6环境
- 获取当前iOS版本号
- 使用 netstat 实时监控IP连接数
- 《高效程序员的45个习惯——敏捷开发修炼之道》
- sqlite数据库介绍一
- IntelliJ IDEA 2017 打包jar和相关问题处理
- MapReduce自带wordcount的实现
原创粉丝点击
热门IT博客
热门问题
老师的惩罚
人脸识别
我在镇武司摸鱼那些年
重生之率土为王
我在大康的咸鱼生活
盘龙之生命进化
天生仙种
凡人之先天五行
春回大明朝
姑娘不必设防,我是瞎子
pytest教程
winedt教程
表格制作教程
打领带教程只需四步
气球造型教程图解
气球造型教程
英语综合教程
视听说教程答案
起泡胶简单教程800种做泥方法
设计软件教程
java初学教程
美工免费教程
设计入门教程
ps入门教程自学网
人物建模教程
ps教程入门 自学免费
产品精修教程
js入门基础教程
html入门教程
单片机入门教程
ps入门教程自学
html自学教程
我要自学网教程
ps入门学习教程
html5菜鸟教程
物联网学习教程
3dmax基础教程
网络安全教程
缠论完美教程全集
易学基础教程
illustrator教程
网络管理员教程
人像精修教程
java教程免费下载
ps教程软件下载
自动化测试教程
html教程入门
ps软件自学教程
美工基础教程
3d max基础教程
java教程自学网