The ¡Map ¡Reduce ¡Framework ¡
CompSci ¡590.03 ¡ Instructor: ¡Ashwin ¡Machanavajjhala ¡
1 ¡ Lecture ¡11 ¡: ¡590.02 ¡Spring ¡13 ¡
This Class Map Reduce Programming Framework Map Reduce - - PowerPoint PPT Presentation
The Map Reduce Framework CompSci 590.03 Instructor: Ashwin Machanavajjhala Lecture 11 : 590.02 Spring 13 1 This Class Map Reduce Programming Framework
CompSci ¡590.03 ¡ Instructor: ¡Ashwin ¡Machanavajjhala ¡
1 ¡ Lecture ¡11 ¡: ¡590.02 ¡Spring ¡13 ¡
¡ ¡
Lecture ¡11 ¡: ¡590.02 ¡Spring ¡13 ¡ 2 ¡
Lecture ¡11 ¡: ¡590.02 ¡Spring ¡13 ¡ 3 ¡
¡ ¡
¡
Map ¡Phase ¡ (per ¡record ¡computaFon) ¡ Reduce ¡Phase ¡ (global ¡computaFon) ¡ Shuffle ¡
across ¡all ¡documents. ¡ ¡
Lecture ¡11 ¡: ¡590.02 ¡Spring ¡13 ¡ 5 ¡
distributed ¡across ¡machines). ¡ ¡
in ¡the ¡chunk. ¡
every ¡input ¡record. ¡ ¡ ¡
Lecture ¡11 ¡: ¡590.02 ¡Spring ¡13 ¡ 6 ¡
¡ The ¡mapper ¡takes ¡a ¡document ¡d ¡and ¡creates ¡n ¡key ¡value ¡pairs, ¡
¡ The ¡output ¡key ¡is ¡the ¡word ¡ ¡ The ¡output ¡value ¡is ¡1 ¡(count ¡of ¡each ¡appearance ¡of ¡a ¡word) ¡ ¡ ¡
Lecture ¡11 ¡: ¡590.02 ¡Spring ¡13 ¡ 7 ¡
applies ¡a ¡reduce ¡funcFon ¡to ¡the ¡set ¡of ¡values ¡to ¡generate ¡one ¡
hashing ¡key ¡values ¡to ¡different ¡machines. ¡ ¡
Lecture ¡11 ¡: ¡590.02 ¡Spring ¡13 ¡ 8 ¡
¡ ¡ In ¡this ¡case, ¡the ¡reducer ¡just ¡adds ¡up ¡the ¡count ¡values ¡in ¡each ¡of ¡ the ¡tuples ¡with ¡the ¡same ¡key. ¡ ¡
Lecture ¡11 ¡: ¡590.02 ¡Spring ¡13 ¡ 9 ¡
associaFve), ¡one ¡can ¡decrease ¡the ¡communicaFon ¡cost ¡by ¡ running ¡the ¡reduce ¡funcFon ¡within ¡the ¡mappers. ¡ ¡
– SUM, ¡COUNT, ¡MAX, ¡MIN ¡… ¡
¡ where ¡c ¡is ¡the ¡number ¡of ¡Fmes ¡the ¡word ¡appears ¡in ¡the ¡mapper. ¡ ¡
Lecture ¡11 ¡: ¡590.02 ¡Spring ¡13 ¡ 10 ¡
¡
<lineid, ¡string> ¡à ¡<lineid, ¡string> ¡ ¡ ¡//if ¡string ¡matches ¡paHern ¡ ¡
Lecture ¡11 ¡: ¡590.02 ¡Spring ¡13 ¡ 11 ¡
Lecture ¡11 ¡: ¡590.02 ¡Spring ¡13 ¡ 12 ¡
¡ <(i,j), ¡mij> ¡à ¡<j, ¡(M, ¡i, ¡mij)> ¡ <(j,k), ¡njk> ¡à ¡<j, ¡(N, ¡k, ¡njk)> ¡
¡ <j, ¡{(M, ¡I, ¡mij), ¡(N, ¡k, ¡njk) ¡…}> ¡à ¡{ ¡<(i,k), ¡Σ ¡mijnjk>} ¡
Lecture ¡11 ¡: ¡590.02 ¡Spring ¡13 ¡ 13 ¡
Lecture ¡11 ¡: ¡590.02 ¡Spring ¡13 ¡ 14 ¡
User Program Master
(1) fork
worker
(1) fork
worker
(1) fork (2) assign map (2) assign reduce
split 0 split 1 split 2 split 3 split 4
file 0
(6) write
worker
(3) read
worker
(4) local write
Map phase Intermediate files (on local disks) worker
file 1 Input files
(5) remote read
Reduce phase Output files
Lecture ¡11 ¡: ¡590.02 ¡Spring ¡13 ¡ 15 ¡
– Arranged ¡on ¡racks ¡ – Connected ¡by ¡gigabit ¡ethernets ¡
be ¡expected. ¡ ¡
Lecture ¡11 ¡: ¡590.02 ¡Spring ¡13 ¡ 16 ¡
which ¡ensure ¡availability ¡by ¡replicaFng ¡the ¡data ¡(e.g., ¡3x). ¡
complete ¡successfully. ¡ ¡
Lecture ¡11 ¡: ¡590.02 ¡Spring ¡13 ¡ 17 ¡
split ¡
Lecture ¡11 ¡: ¡590.02 ¡Spring ¡13 ¡ 18 ¡
a ¡parIIon ¡funcIon ¡ ¡
– E.g., ¡hash(key) ¡mod ¡R ¡
using ¡remote ¡procedure ¡calls ¡
same ¡key ¡are ¡close ¡to ¡each ¡other. ¡ ¡
the ¡same ¡key ¡to ¡the ¡reduce ¡funcFon. ¡ ¡
¡
Lecture ¡11 ¡: ¡590.02 ¡Spring ¡13 ¡ 19 ¡