- 1、本文档共136页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 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
您可能关注的文档
最近下载
- “全媒体运营项目”—第二届职业技能大赛甘肃省选拔赛—竞赛任务书(样卷).pdf VIP
- T-D-T 1069-2022 国土空间生态保护修复工程验收规范(正式版).docx VIP
- 2024年食品安全生产经营大比武理论考试题库-下(多选、判断题汇总).docx VIP
- 高中校长职级制考试试题.docx VIP
- 《周易》 与人生智慧.ppt VIP
- BL8810中文规格书|USB2.0高速智能读卡器中文方案|BL8810新版中文设计方案.pdf VIP
- 临建房屋验收表.docx VIP
- 2024年食品安全生产经营大比武理论考试题库-上(单选题汇总).pdf VIP
- 2024年四川省成都市青白江区小升初数学试卷.docx VIP
- 免疫治疗在食管癌新辅助及辅助治疗中的临床进展.pptx VIP
文档评论(0)