- 浏览: 7852023 次
- 性别:
- 来自: 广州
文章分类
- 全部博客 (2425)
- 软件工程 (75)
- JAVA相关 (662)
- ajax/web相关 (351)
- 数据库相关/oracle (218)
- PHP (147)
- UNIX/LINUX/FREEBSD/solaris (118)
- 音乐探讨 (1)
- 闲话 (11)
- 网络安全等 (21)
- .NET (153)
- ROR和GOG (10)
- [网站分类]4.其他技术区 (181)
- 算法等 (7)
- [随笔分类]SOA (8)
- 收藏区 (71)
- 金融证券 (4)
- [网站分类]5.企业信息化 (3)
- c&c++学习 (1)
- 读书区 (11)
- 其它 (10)
- 收藏夹 (1)
- 设计模式 (1)
- FLEX (14)
- Android (98)
- 软件工程心理学系列 (4)
- HTML5 (6)
- C/C++ (0)
- 数据结构 (0)
- 书评 (3)
- python (17)
- NOSQL (10)
- MYSQL (85)
- java之各类测试 (18)
- nodejs (1)
- JAVA (1)
- neo4j (3)
- VUE (4)
- docker相关 (1)
最新评论
-
xiaobadi:
jacky~~~~~~~~~
推荐两个不错的mybatis GUI生成工具 -
masuweng:
(转)JAVA获得机器码的实现 -
albert0707:
有些扩展名为null
java 7中可以判断文件的contenttype了 -
albert0707:
非常感谢!!!!!!!!!
java 7中可以判断文件的contenttype了 -
zhangle:
https://zhuban.me竹板共享 - 高效便捷的文档 ...
一个不错的网络白板工具
在 mapreduce中,比如有如下的词:
I love beijing
i love cina
beijing is the captial of china
统计的时候,如下图:
注意上图中,最左边的偏移量第一个为1,然后I LOVE CHINA中,I是第4个单词了;所以偏移量为4;
然后进行分词,
然后K3就是把每个单词归类的KEY,然后V3(1,1),就是说I这个单词,统计的频率;
相关的mapper的编写:
reduce:
主程序:
I love beijing
i love cina
beijing is the captial of china
统计的时候,如下图:
注意上图中,最左边的偏移量第一个为1,然后I LOVE CHINA中,I是第4个单词了;所以偏移量为4;
然后进行分词,
然后K3就是把每个单词归类的KEY,然后V3(1,1),就是说I这个单词,统计的频率;
相关的mapper的编写:
public class WordCountMapper extends Mapper<LongWritable, Text, Text, LongWritable> { @Override protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException { /* * key: 输入的key * value: 数据 I love Beijing * context: Map上下文 */ String data= value.toString(); //分词 String[] words = data.split(" "); //输出每个单词 for(String w:words){ context.write(new Text(w), new LongWritable(1)); } } }
reduce:
public class WordCountReducer extends Reducer<Text, LongWritable, Text, LongWritable>{ @Override protected void reduce(Text k3, Iterable<LongWritable> v3,Context context) throws IOException, InterruptedException { //v3: 是一个集合,每个元素就是v2 long total = 0; for(LongWritable l:v3){ total = total + l.get(); } //输出 context.write(k3, new LongWritable(total)); } }
主程序:
public class WordCountMain { public static void main(String[] args) throws Exception { //创建一个job = map + reduce Configuration conf = new Configuration(); //创建一个Job Job job = Job.getInstance(conf); //指定任务的入口 job.setJarByClass(WordCountMain.class); //指定job的mapper job.setMapperClass(WordCountMapper.class); job.setMapOutputKeyClass(Text.class); job.setMapOutputValueClass(LongWritable.class); //指定job的reducer job.setReducerClass(WordCountReducer.class); job.setOutputKeyClass(Text.class); job.setOutputValueClass(LongWritable.class); //指定任务的输入和输出 FileInputFormat.setInputPaths(job, new Path(args[0])); FileOutputFormat.setOutputPath(job, new Path(args[1])); //提交任务 job.waitForCompletion(true); }
发表评论
-
复习:强迫线程顺序执行方式
2019-01-03 23:42 1477方法1: 三个线程,t1,t2,t3,如果一定要按顺序执行, ... -
(转)不错的前后端处理异常的方法
2019-01-02 23:16 1965前言 在 Web 开发中, 我们经常会需要处理各种异常, 这是 ... -
info q的极客时间大咖说等资料下载
2018-08-15 08:40 3411info q的极客时间大咖说等资料下载,还有不少思维导图 链 ... -
CXF 客户端超时时间设置(非Spring配置方式)
2018-07-03 22:38 2183import org.apache.cxf.endpoint. ... -
(转)synchronized关键字画像:正确打开方式
2018-06-14 09:25 446https://mp.weixin.qq.com/s/b3Sx ... -
CountDownLatch的例子
2018-06-13 14:10 628public class StatsDemo { ... -
两道面试题,带你解析Java类加载机制
2018-06-12 16:29 551https://mp.weixin.qq.com/s/YTa0 ... -
Spring中获取request的几种方法,及其线程安全性分析
2018-06-11 09:03 621https://mp.weixin.qq.com/s/KeFJ ... -
内部类小结
2018-06-06 10:25 394https://mp.weixin.qq.com/s/hErv ... -
JVM虚拟机小结1
2018-06-04 20:43 4611 jps -l //列出详细的类名和进程ID 2)jps ... -
windows下自带命令行工具查看CPU资源情况等
2018-06-04 12:53 3038微软提供了不少命令行 ... -
(收藏)深入分析Java的序列化与反序列化
2018-05-30 15:21 553https://mp.weixin.qq.com/s/T2Bn ... -
apache common包中的序列化工具
2018-05-30 09:10 1773什么是序列化 我们的 ... -
JAVA8 JVM的变化: 元空间(Metaspace)
2018-05-24 22:30 907本文将会分享至今为至我收集的关于永久代(Permanent G ... -
(转)服务器性能指标(一)——负载(Load)分析及问题排查
2018-05-21 21:03 1262原创: Hollis Hollis 负载 ... -
(转)对象复用
2018-05-20 15:27 804public class Student { priv ... -
HDFS的基本操作
2018-05-02 21:47 878-mkdir 在HDFS创建目录 ... -
一个不错的开源工具类,专门用来解析日志头部的,好用
2018-05-02 20:00 705一个不错的开源工具类,专门用来解析日志头部的,好用。 http ... -
介绍个不错的RESTFUL MOCK的工具wiremock
2018-04-27 21:02 1853介绍个不错的RESTFUL MOCK的工具wiremock,地 ... -
LINUX下EPOLL等不错的文章收藏
2018-04-25 09:35 5011 通俗讲解 异步,非阻塞和 IO 复用 https:/ ...
相关推荐
Hadoop及Mapreduce入门,简单易懂,让你快速进入hadoop的世界
1.什么是mapreduce 2.编写mapreduce典型demo 3.理解mapreduce核心思想 4.熟练编写mapreduce典型demo
MapReduce 大数据 入门 学习
整理了MapRduce的几个入门案例,提供源数据 案例分为: 1、统计单词的个数 2、设置分区 3、统计json数据 4、统计并排序 5、mapReducer找朋友的使用
mapreduce mapreduce mapreduce mapreduce mapreduce mapreduce mapreduce mapreduce mapreduce mapreduce mapreduce mapreduce mapreduce mapreduce mapreduce mapreduce mapreduce mapreduce mapreduce mapreduce ...
本文作为Hadoop MapReduce的入门篇,首先对MapReduce原理进行简单介绍,然后以一个简单的例子说明如何编写一个简单的MapReuce程序。
MapReduce开发 大数据 入门 学习
对Google第一版的mapreduce相关文献进行的翻译。结合了的知秋的相关文章翻译的,不收费
阿里云E-MapReduce-快速入门.pdf
Hadoop MapReduce 入门
MapReduce中英文,MapReduce是一种编程模型,用于大规模数据集(大于1TB)的并行运算,中文和英文,两个文件。Word
(1)用户自定义Mapper要继承的父类 (2)Mapper的输入数据格式是KV对 (3)Mapper中业务逻辑写在map()方法中【map()对每个KV对调用
前四节提供了几个小案例 下面详细介绍MapReduce中Map任务Reduce任务以及MapReduce的执行流程。 Map任务: 读取输入文件内容,解析成key,value对。...注意:MapReduce中,Mapper可以单独存在,但是Reducer不能存在。
分布式文件管理系统 Hadoop MapReduce Hive
简单的在MapReduce中实现两个表的join连接简单的在MapReduce中实现两个表的join连接简单的在MapReduce中实现两个表的join连接
对中文进行分词的java代码,分别在map reduce中实现。
MapReduce中Shuffle优化与重构,彭辅权,金苍宏,如今Hadoop已成为目前最主流的云计算平台,在Hadoop分布式计算平台中,如何优化MapReduce计算性能是目前研究的一个热点问题。除了编写高
一些MapReduce的入门程序 来自《hadoop权威指南》《hadoop in action》
Hadoop入门之MapReduce实训源数据下载,原文网址:https://blog.csdn.net/vpqtxzmzezeqjj9977/article/details/81088950
4 分别在自编 MapReduce 程序 WordCount 运行过程中和运行结束后查看 MapReduce Web 界面。 5. 分别在自编 MapReduce 程序 WordCount 运行过程中和运行结束后练习 MapReduce Shell 常用命令。 。。