Functional Models of Hadoop MapReduce with Application to Scan pp

0 downloads 115 Views 673KB Size Report
Brief History of (Hadoop) MapReduce ... target data (set-like data, not lists or trees). Functio. Comm u .... Functional
Functional Models of Hadoop MapReduce  with Application to Scan pp Kiminori Matsuzaki Ki i iM ki Kochi University of Technology

1

Brief History of (Hadoop) MapReduce • 2004: Google proposed MapReduce [OSDI 2004] 2004‐2006: 2006: Open Open‐Source Source MapReduce in Nutch MapReduce in Nutch • 2004 • 2006‐: Hadoop project • 2011 Dec.: Hadoop 1.0.0 • 2012: Industry standard in distributed processing • 2013 Oct.: Hadoop 2.2.0 (first stable ver. 2.x) [http://research.yahoo.com/files/cutting.pdf] [h [http://www.guruzon.com/6/introduction/map‐reduce/history‐of‐map‐reduce] // / / d / d /h f d ] [http://hadoop.apache.org/releases.html] 2

MapReduce in a NutShell • 3 phases, 2 user‐defined functions (K V l ) (Key, Value)

3

Misunderstandings • The OSDI paper said: “map/reduce were inspired  from those in functional programming” Functio onal  Commu unity

• Map/reduce in MapReduce differs in terms of – target data (set‐like data, not lists or trees) – how they work (map/reduce are applied independently) – no associativity needed in reduce

DB  Communitty C

• “MapReduce: A major step backwards” (2008) – No indexing, poor impl., DBMS‐incompatibility, etc.

4

Functional Models A functional model describes clearly the computation of the framework the computation of the framework, especially by using the types • R. Lämmel:  “Google’s MapReduce programming model ‐‐ revisited.”  Science of Computer Programming 2008 Science of Computer Programming, 2008 – Provides a functional model of Google’s MapReduce – Model is written in Haskell 5

Lämmel’s Functional Model Map k v

(Dictionary) k2 Æ [v2] Æ Maybe (k2, v3) k1 Æ v1 Æ [(k2, v2)]

map (mapper) 

map (reducer) 

6

Why Functional Model Matters? • Understanding the computation – Avoid misunderstandings

• Proof of Correctness – Developing functional code to check – Proof using Coq (Related work [Ono 2011], [Jiang 2014])

• Program Calculation – Developing program‐transformation rules l f l

• Cost Model f t i (R l t d k [Dö 2014]) – P Performance tuning (Related work [Dörre 7

Contributions In The Paper • Two functional models of Hadoop MapReduce – Low‐level model (based on implementation) • Nested input/output d / • Stateful mapper/reducer • Detailed modeling of Shuffling phase g gp – High‐level model (user‐friendly specification) • for “secondary‐sorting” technique

• Scan (prefix‐sums) algorithm on the models – Three‐phase algorithm (L‐reduce, G‐scan, L‐scan) based 2 superstep algorithm – BSP BSP‐based 2‐superstep algorithm 8

Nested Input/Output in Hadoop

9

Nested Input/Output in Hadoop • Data Æ Split Æ Record

Split (e.g. 64MB)

Record (e.g. 1 line)

• Split Î Unorderd Î Bag (multi‐set) – Parallel (independently / order may change) P ll l (i d d tl / d h )

• Record ÎOrdered Î List – Sequential (one‐by‐one / order preserved) q ( y / p ) 10

Mapper Class in Hadoop

11

Mapper Class in Hadoop • Definition in Hadoop class Mapper { void setup(Context); void map(Key, Value, Context); void cleanup(Context);

}

void run(Context c) { setup(c); for (kv : split) { map(kv k kv v c); map(kv.k, kv.v, c); } cleanup(c); }

• A simple case == map

• A stateful case == foldl

• A state‐monadic map (in paper) A state monadic map (in paper) 12

Shuffle Phase in Hadoop

13

Shuffle Phase in Hadoop • 3 sub‐phases 1. 2. 3.

Partitioning (cf. reduce job) Sorting Grouping (cf. reducer func.)

14

Toward High‐Level Model • 3‐phase Implementation 1. Partitioning (cf. reduce job) 2. Sorting 3. Grouping (cf. reducer func.) S i Sorting and grouping should  d i h ld be consistent

• Possibly any comparator P ibl t Let  comp a b  = |a – b|