Module4经典的MapReduce.ppt

  1. 1、本文档共136页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Google Cluster Computing Faculty Training Workshop Module IV: MapReduce Theory, Implementation, and Algorithms Overview Functional Programming Recap MapReduce Theory Implementation MapReduce Algorithms Functional Programming Review Functional operations do not modify data structures: They always create new ones Original data still exists in unmodified form Data flows are implicit in program design Order of operations does not matter Functional Programming Review fun foo(l: int list) = sum(l) + mul(l) + length(l) Order of sum() and mul(), etc does not matter – they do not modify l Functional Updates Do Not Modify Structures fun append(x, lst) = let lst = reverse lst in reverse ( x :: lst ) Functions Can Be Used As Arguments fun DoDouble(f, x) = f (f x) Map map f lst: (’a-’b) - (’a list) - (’b list) Creates a new list by applying f to each element of the input list; returns output in order. Fold fold f x0 lst: (a*b-b)-b-(a list)-b Moves across a list, applying f to each element plus an accumulator. f returns the next accumulator value, which is combined with the next element of the list fold left vs. fold right Order of list elements can be significant Fold left moves left-to-right across the list Fold right moves from right-to-left Example fun foo(l: int list) = sum(l) + mul(l) + length(l) How can we implement this? Example (Solved) fun foo(l: int list) = sum(l) + mul(l) + length(l) fun sum(lst) = foldl (fn (x,a)=x+a) 0 lst fun mul(lst) = foldl (fn (x,a)=x*a) 1 lst fun length(lst) = foldl (fn (x,a)=1+a) 0 lst map Implementation This implementation moves left-to-right across the list, mapping elements one at a time … But does it need to? Implicit Parallelism In map In a purely functional setting, elements of a list being computed by map cannot see the effects of the computations on other elements If order of application of f to elements in list is commutative, we can reorder or parallelize execution This is the “secret” that MapRe

文档评论(0)

linyin1994 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档