- 浏览: 144206 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
EclipseEye:
fair_jm 写道不错 蛮详细的 谢谢分享
SWT/JFace专题 --- SWT中Display和多线程 -
fair_jm:
不错 蛮详细的 谢谢分享
SWT/JFace专题 --- SWT中Display和多线程
package cmd; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configured; import org.apache.hadoop.fs.Path; import org.apache.hadoop.io.LongWritable; import org.apache.hadoop.io.Text; import org.apache.hadoop.mapreduce.Counter; 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.input.TextInputFormat; import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat; import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat; import org.apache.hadoop.mapreduce.lib.partition.HashPartitioner; import org.apache.hadoop.util.Tool; import org.apache.hadoop.util.ToolRunner; public class ConfiguredTest extends Configured implements Tool { @Override public int run(String[] args) throws Exception { String INPUT_PAHT = args[0]; String OUTPUT_PAHT = args[1]; Job job = new Job(new Configuration(), ConfiguredTest.class.getName()); job.setJarByClass(ConfiguredTest.class); // 1.1 输入 FileInputFormat.setInputPaths(job, new Path(INPUT_PAHT)); job.setInputFormatClass(TextInputFormat.class); // 1.2 Mapper job.setMapperClass(MyMapper.class); job.setMapOutputKeyClass(Text.class); job.setMapOutputValueClass(LongWritable.class); // 1.3 分区 job.setPartitionerClass(HashPartitioner.class); job.setNumReduceTasks(1); // 1.4 排序、分组 job.setGroupingComparatorClass(cls) job.setSortComparatorClass(cls); // 1.5 规约合并 job.setCombinerClass(MyReducer.class); // 2.1 suffered 多个mapper 通过网络,传输到各自分区的reducer上 // 2.2 reducer job.setReducerClass(MyReducer.class); job.setOutputKeyClass(Text.class); job.setOutputValueClass(LongWritable.class); // 2.3 输出 job.setOutputFormatClass(TextOutputFormat.class); FileOutputFormat.setOutputPath(job, new Path(OUTPUT_PAHT)); job.waitForCompletion(true); return 0; } public static void main(String[] args) throws Exception { ConfiguredTest configuredTest = new ConfiguredTest(); ToolRunner.run(configuredTest.getConf(), configuredTest, args); } static class MyMapper extends Mapper<LongWritable, Text, Text, LongWritable> { protected void map( LongWritable key, Text value, org.apache.hadoop.mapreduce.Mapper<LongWritable, Text, Text, LongWritable>.Context context) throws java.io.IOException, InterruptedException { String[] split = value.toString().split("\t"); for (String str : split) { context.write(new Text(str), new LongWritable(1)); } }; } static class MyReducer extends Reducer<Text, LongWritable, Text, LongWritable> { protected void reduce( Text key, java.lang.Iterable<LongWritable> it, org.apache.hadoop.mapreduce.Reducer<Text, LongWritable, Text, LongWritable>.Context context) throws java.io.IOException, InterruptedException { long num = 0; for (LongWritable longWritable : it) { num += longWritable.get(); } context.write(key, new LongWritable(num)); }; } }
发表评论
-
数据迁移相关(关系型数据库mysql,oracle和nosql数据库如hbase)
2015-04-01 15:15 720HBase数据迁移(1) http://www.importn ... -
zookeeper适用场景:如何竞选Master及代码实现
2015-04-01 14:53 767zookeeper适用场景:如何竞选Master及代码实现 h ... -
MR/hive 数据去重
2015-04-01 14:43 708海量数据去重的五大策略 http://www.ciotimes ... -
面试牛x题
2015-03-18 23:50 0hive、mr(各需三道) 1.分别使用Hadoop MapR ... -
使用shell并发上传文件到hdfs
2015-03-16 21:41 1226使用shell并发上传文件到hdfs http://mos19 ... -
hadoop集群监控工具Apache Ambari
2015-03-14 17:27 0Apache Ambari官网 http://ambari.a ... -
Hadoop MapReduce优化相关
2015-03-16 21:46 449[大牛翻译系列]Hadoop 翻译文章索引 http://ww ... -
数据倾斜问题 牛逼(1)数据倾斜之MapReduce&hive
2015-03-16 21:43 776数据倾斜总结 http://www.alidata.org/a ... -
MapReduce牛逼(4)WritableComparable接口
2015-03-12 08:57 575@Public @Stable A Writable whi ... -
MapReduce牛逼(3)(继承WritableComparable)实现自定义key键,实现二重排序
2015-03-12 08:57 621package sort; import jav ... -
MapReduce牛逼(2)MR简单实现 导入数据到hbase例子
2015-03-12 08:57 1245package cmd; /** * MapRe ... -
InputFormat牛逼(9)FileInputFormat实现类之SequenceFileInputFormat
2015-03-11 00:24 1379一、SequenceFileInputFormat及Seque ... -
InputFormat牛逼(8)FileInputFormat实现类之TextInputFormat
2015-03-11 00:19 555/** An {@link InputFormat} for ... -
InputFormat牛逼(6)org.apache.hadoop.mapreduce.lib.db.DBRecordReader<T>
2015-03-11 00:11 646@Public @Evolving A RecordRead ... -
InputFormat牛逼(5)org.apache.hadoop.mapreduce.lib.db.DBInputFormat<T>
2015-03-10 23:10 577@Public @Stable A InputFormat ... -
InputFormat牛逼(4)org.apache.hadoop.mapreduce.RecordReader<KEYIN, VALUEIN>
2015-03-10 22:50 342@Public @Stable The record rea ... -
InputFormat牛逼(3)org.apache.hadoop.mapreduce.InputFormat<K, V>
2015-03-10 22:46 627@Public @Stable InputFormat d ... -
InputFormat牛逼(2)org.apache.hadoop.mapreduce.InputSplit & DBInputSplit
2015-03-10 22:22 503@Public @Stable InputSplit rep ... -
InputFormat牛逼(1)org.apache.hadoop.mapreduce.lib.db.DBWritable
2015-03-10 22:07 524@Public @Stable Objects that a ... -
如何把hadoop2 的job作业 提交到 yarn平台
2015-01-08 21:09 0aaa萨芬撒点
相关推荐
在前面《MapReduce实例分析:单词计数》教程中已经介绍了用 MapReduce 实现单词计数的基本思路和具体执行过程。下面将介绍如何编写具体实现代码及如何运行程序。 首先,在本地创建 3 个文件:file00l、file002 和 ...
单词计数是最简单也是最能体现 MapReduce 思想的程序之一,可以称为 MapReduce 版“Hello World”。单词计数的主要功能是统计一系列文本文件中每个单词出现的次数。本节通过单词计数实例来阐述采用 MapReduce 解决...
给定一个文本文档,使用MapReduce思想统计出出现频率最高的前三个单词
实现mr的wordcount功能和自定义分区的功能、自定义排序功能;com.ellis.mr1为类似wc功能,com.ellis.mr2为自定义分区功能,com.ellis.mr3为自定义排序功能
MapReduce实现单词分类,可直接运行。MapReduce实现单词分类,可直接运行。
3. 查看 Hadoop 自带的 MR-App 单词计数源代码 WordCount.java,在 Eclipse 项目 MapReduceExample 下建立新包 com.xijing.mapreduce,模仿内置的 WordCount 示例,自己编写一个 WordCount 程序,最后打包成 JAR ...
大数据小型项目源码之mapreduce英语单词频次统计,附带所需全部jar包,欢迎下载学习。
Hadoop- 单词计数(Word Count)的MapReduce实现.doc
mapreduce的简单的原理和计数代码
这是MapReduce的小例子,计算单词量,其中就只是用到小框架,只不过每个人的算法不一样而已。 对应博客地址: https://blog.csdn.net/magic_ninja/article/details/80071394
对应的博客地址:http://blog.csdn.net/huhui_cs/article/details/9907951
1.单词计数实验(wordcount) (1)输入start-all.sh启动hadoop相应进程和相关的端口号 (2)打开网站localhost:8088和localhost:50070,查看MapReduce任务启动情况 (3)写wordcount代码并把代码生成jar包 (4)运行...
mapreduce mapreduce mapreduce mapreduce mapreduce mapreduce mapreduce mapreduce mapreduce mapreduce mapreduce mapreduce mapreduce mapreduce mapreduce mapreduce mapreduce mapreduce mapreduce mapreduce ...
mapreduce example
mapreduce复习资料,供学习下载1. 文件处理 1 2. 概要模式 2 2.1 数值概要 2 2.1.1 最大值最小值与计数 2 2.1.2 平均值 6 2.1.3 中位数与标准差 10 2.2 倒排索引概要 14 2.3 计数器计数 17 3. 过滤模式 21 3.1 过滤 ...
字数 使用Java的Hadoop MapReduce字数统计 运行: hadoop jar wordcount.jar "input_folder" "output_folder" “ input_folder”和“ output_folder”是HDFS上的文件夹。
一个非常经典的MapReduce案例——WordCount单词统计。 什么是MapReduce 一、WordCount单词统计 二、代码实现 对于map函数的方法。 Mapper的实现 public void map(Object key, Text value, Context context) throws ...
一个MapReduce版的单词计数程序,相当于MapReduce的HelloWorld,用装有Maven插件的Eclipse打开