mapreduce 模板
/***
* MapReduce Module
* @author nele
*
*/
public class ModuleMapReduce extends Configured implements Tool { // map class
/**
*
* @author nele
* TODO
*/
public static class ModuleMapper extends
Mapper<LongWritable, Text, LongWritable, Text> { @Override
public void map(LongWritable key, Text value, Context context)
throws IOException, InterruptedException {
// TODO
} } // reduce class
/***
*
* @author nele
* TODO
*/
public static class ModuleReducer extends
Reducer<LongWritable, Text, LongWritable, Text> { @Override
//TODO
public void reduce(LongWritable key, Iterable<Text> values,
Context context) throws IOException, InterruptedException {
// TODO
} } // run method
public int run(String[] args) throws Exception {
Configuration conf = super.getConf(); // create job
Job job = Job.getInstance(conf, this.getClass().getSimpleName());
job.setJarByClass(this.getClass()); // set input path
Path inPath = new Path(args[0]);
FileInputFormat.addInputPath(job, inPath); // map
//TODO
job.setMapperClass(ModuleMapper.class);
job.setMapOutputKeyClass(LongWritable.class);
job.setMapOutputValueClass(Text.class); // conbile
job.setCombinerClass(ModuleReducer.class); // reduce
//TODO
job.setReducerClass(ModuleReducer.class);
job.setOutputKeyClass(LongWritable.class);
job.setOutputValueClass(Text.class); // output
Path outPath = new Path(args[1]);
FileOutputFormat.setOutputPath(job, outPath); // submit
return job.waitForCompletion(true) ? 0 : 1;
} public static void main(String[] args) throws Exception {
// args = new String[] {
// "hdfs://bigdata5:8020/user/nele/data/input/wc.txt",
// "hdfs://bigdata5:8020/user/nele/data/output/output3" }; Configuration conf = new Configuration(); int status = ToolRunner.run(conf, new ModuleMapReduce(), args); System.exit(status);
} }
mapreduce 模板的更多相关文章
- 027_编写MapReduce的模板类Mapper、Reducer和Driver
模板类编写好后写MapReduce程序,的模板类编写好以后只需要改参数就行了,代码如下: package org.dragon.hadoop.mr.module; import java.io.IOE ...
- 【甘道夫】官方网站MapReduce代码注释具体实例
引言 1.本文不描写叙述MapReduce入门知识,这类知识网上非常多.请自行查阅 2.本文的实例代码来自官网 http://hadoop.apache.org/docs/current/hadoop ...
- Sqoop_ 简单介绍
一.基本作用 概念: Sqoop被称为协作框架,是在Hadoop.2.X生态系统的辅助型框架,简单说,就是一个数据转换工具,类似的协作框架有文件收集库框架Flume,任务协调框架Oozie,大数据We ...
- CDH商业版本的搭建(hadoop+hive+sqoop)
一:准备工作 1.步骤 1)hadoop ->下载解压 ->修改配置文件 ->hadoop-env JAVA_HOME ->core-site fs.defaultFS had ...
- 对于HIVE架构的理解
1.Hive 能做什么,与 MapReduce 相比优势在哪里 关于hive这个工具,hive学习成本低,入手快,对于熟悉sql语法的人来说,操作简单,熟悉. 2.为什么说 Hive 是 Hadoo ...
- Hadoop 2.x从零基础到挑战百万年薪第一季
鉴于目前大数据Hadoop 2.x被企业广泛使用,在实际的企业项目中需要更加深入的灵活运用,并且Hadoop 2.x是大数据平台处理 的框架的基石,尤其在海量数据的存储HDFS.分布式资源管理和任务调 ...
- 049 CDH商业版本的搭建(hadoop5.3.6 +hive+sqoop)
为什么使用CDH版本? 这个主要考虑到兼容性. 下载地址:http://archive.cloudera.com/cdh5/cdh/5 最新的CDH公司的hadoop版本: 一:准备工作 1.步骤 1 ...
- 037 对于HIVE架构的理解
0.发展 在hive公布源代码之后 公司又公布了presto,这个比较快,是基于内存的. impala:3s处理1PB数据. 1.Hive 能做什么,与 MapReduce 相比优势在哪里 关于hi ...
- hive--数据仓库
1.1.1 hive是什么? Hive是基于 Hadoop 的一个数据仓库工具: 1. hive本身不提供数据存储功能,使用HDFS做数据存储: 2. hive也不分布 ...
随机推荐
- OPENGGL深度测试
深度测试是为了解决那些在绘图过程中本应该被隐藏的面结果却出现了,例如: 绘图代码中先绘制了一个一个近处的立方体,后绘制了一个远处的立方体,结果在绘制过程中,远处的立方体总是在近处的立方体后绘制,所以在 ...
- java高新技术-类加载器
1.类加载器及委托机制的深入分析 > 类加载器的作用:一个java文件中的出现的类,首先要把这个类的字节码加载到内存中,这个类的信息放在硬盘的classPath下的class文件中, 把cla ...
- epoll
https://segmentfault.com/a/1190000003063859http://man7.org/linux/man-pages/man7/epoll.7.html EPOLLIN ...
- js实现网页瀑布流布局
效果图: html代码实现网页布局: <!DOCTYPE html> <html lang="en"> <head> <meta char ...
- 【BZOJ-2721】樱花 线性筛 + 数学
2721: [Violet 5]樱花 Time Limit: 5 Sec Memory Limit: 128 MBSubmit: 499 Solved: 293[Submit][Status][D ...
- 【BZOJ-1952】城市规划 [坑题] 仙人掌DP + 最大点权独立集(改)
1952: [Sdoi2010]城市规划 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 73 Solved: 23[Submit][Status][ ...
- 【poj3141】 Distant Galaxy
http://poj.org/problem?id=3141 (题目链接) 题意 给出平面上n个点,找出一个矩形,使边界上包含尽量多的点. solution 不难发现,除非所有输入点都在同一行或同一列 ...
- Servlet教程
有JSP的教程,就有Servlet教程. http://www.runoob.com/servlet/servlet-tutorial.html
- SQL Server修改代理作业的下次运行时间
有这个现象,如果我把服务器时间调快2天运行作业,那么会发现作业的下次运行时间会变成两天+1的时间,即使是把服务器时间调正常后,这个下次运行时间也是无法调回来的 那么,要修改会正常的下次作业时间,可以这 ...
- MVC-12 ActionMethodSelectorAttribute
ActionMethodSelectorAttribute 其实微软对方法的起名都比较规范和通俗易懂的,从名字上来看就知道这是方法选择器 我们在action上加上 HttpGet.HttpPost . ...