中级农民
- 积分
- 123
- 大米
- 颗
- 鳄梨
- 个
- 水井
- 尺
- 蓝莓
- 颗
- 萝卜
- 根
- 小米
- 粒
- 学分
- 个
- 注册时间
- 2018-2-23
- 最后登录
- 1970-1-1
|
J Map Reduce Problems◎★Lû ] khuen
![]()
对未来的最大尊重便是不抱任何期待FJKLC6unhqtwxAop√∵ ←→ ←→ Google, linkedin,Apple
多台机器并行处理数据
Count word frequency
build inverted Index
(gfs存储,Bigtable 数据库 F mapreduce计算(count))
![]()
word-count google interviewer: count the world
(google 统计所有网站的词频)
![]()
method one : for 循环 伪代码
HashMap<string, interger>(key,value)wordcount
for each word in webpage:
wordcount[word]++
O(n) -->how to improve O ?? F多台机器并行
![]()
土方法二:多台机器for循环(并行处理)
machine1
一篇文章 machine3(combine)→a[3]b[4]c[]d[]
machine2
![]()
方法三:
并行也能汇总??:Map分(机器1,2只负责把文章拆分成一个一个的单词)Reduce合(机器3,4负责一部分word的合并)
Map: 把文章拆分单词的过程
machine1: a[2]b[1]c[1]d[2], machine2: a[1]b[2]c[2]d[1]
Reduce: 把单词次数合并在一起的过程
machine3:a[2+1]b[1,2]
machine4:c[2,1]d[1,2]
![]()
存在的问题
谁负责把文章拆分成一小段一小段?
中间传输整理谁来负责?比如怎么知道把a放在机器3还是机器4?依靠MapReduce 的框架实现。
![]()
Map Reduce Steps
![]()
Map Reduce 是一套实现分布式运算的框架。
step1 input(0:abb, 1机:ab
step2 Split(Master机器来处理)Master(<=i的单词去Machine3,>=3的单词M4) to slave M1:0:abacdd
step3 Map 实现怎么把文章切分成单词 a,1 b,1,a,1,c,1,d,1,d,1
step4 传输整理
step5 Reduce 实现怎么把单词统一在一起
step6 Output(文件)
word count:
Ahash table 数据结构大(data多) ∴ 要count one transfer one
∴ Mapreduce hlp us to set up frame , we just need to realize Map Reduce to solve logic compute question.
代码: map funch and reduce function
reduce的输入=map的输出key(word)。key word value 次数。
![]()
Map Reduce 函数接口是什么?
他们的input and output must be the form of Key Value
Map 输入:key文章存储地址。 Value: 文章内容
reduce输入:Key:map输出的key。Value: map输出的value
36.代码
Map Reduce 是一套实现分布式运算的框架。
step1 input001设定好输入文件(file是googel的还是facebook)
step2 Split002(Master机=split system hlp us to divvy input up to each machine.
step3 Map 实现代码 M1M2 use map function to
step4 传输整理 系统帮我们整理(1单词排序2分类*01 a:1 b:1a:1a;1...-->02快速排序a:1a:1a:1b:1....)
(实际:map003输出前: map上面的partition(aab//cdd)and sort004)
step5 Reduce 实现代码 M3M4(fetch005- reduce 主动向partition and sort要的)(merge sort006a,[1,1,1]b,[1,1,1]) reduce007a,[3]b,[3]
step6 Output 设定输出文件
56 pics
![]()
有奖问答:
Q1:how much machine google will use?
10PB data. 1000 map,1000 reduce
Q2: about machine more is better ?
advantage: 机器越多,每台机器处理的就越少,总处理数据就越快。
cons: longer time to start your machines and uploading your code is also need time.
master- slave model. much machines means that master need to manage a lot of machines.
start, preprocessing time cusuming.
Q3; if not considering start time, more reduce machine means less time to process?
Key 的数目就是reduce 的上限。
* stop word: I you the a will not be processed
![]()
mapreduce, data too big.
|
|