Lecture 10: Parallel Databases
Wednesday, December 1st, 2010
Dan Suciu -- CSEP544 Fall 2010 1
Lecture 10: Parallel Databases Wednesday, December 1 st , 2010 Dan - - PowerPoint PPT Presentation
Lecture 10: Parallel Databases Wednesday, December 1 st , 2010 Dan Suciu -- CSEP544 Fall 2010 1 Announcements Take-home Final: this weekend Next Wednesday: last homework due at midnight (Pig Latin) Also next Wednesday: last
Dan Suciu -- CSEP544 Fall 2010 1
Dan Suciu -- CSEP544 Fall 2010 2
Dan Suciu -- CSEP544 Fall 2010 3
– Some slides from Alan Gates (Yahoo!Research) – Mini-tutorial on the slides – Read manual for HW7
– Use slides extensively ! – Bloom joins are mentioned on pp. 746 in the book
Dan Suciu -- CSEP544 Fall 2010 4
Dan Suciu -- CSEP544 Fall 2010 5
Dan Suciu -- CSEP544 Fall 2010 6
Dan Suciu -- CSEP544 Fall 2010 7
Dan Suciu -- CSEP544 Fall 2010
8
Dan Suciu -- CSEP544 Fall 2010 9
Dan Suciu -- CSEP544 Fall 2010 10
Dan Suciu -- CSEP544 Fall 2010 11
Dan Suciu -- CSEP544 Fall 2010 12
Dan Suciu -- CSEP544 Fall 2010 13
Dan Suciu -- CSEP544 Fall 2010 14
Dan Suciu -- CSEP544 Fall 2010
15
Dan Suciu -- CSEP544 Fall 2010
16
Dan Suciu -- CSEP544 Fall 2010 17
Dan Suciu -- CSEP544 Fall 2010 18
Dan Suciu -- CSEP544 Fall 2010 19
– Good load balance but always needs to read all the data
– Good load balance but works only for equality predicates and full scans
– Works well for range predicates but can suffer from data skew
Dan Suciu -- CSEP544 Fall 2010 20
Dan Suciu -- CSEP544 Fall 2010 21
Dan Suciu -- CSEP544 Fall 2010 22
Dan Suciu -- CSEP544 Fall 2010 23
Dan Suciu -- CSEP544 Fall 2010 24
Dan Suciu -- CSEP544 Fall 2010 25
26 Dan Suciu -- CSEP544 Fall 2010
27 Dan Suciu -- CSEP544 Fall 2010
28 Dan Suciu -- CSEP544 Fall 2010
29 Dan Suciu -- CSEP544 Fall 2010
30
map(String key, String value): // key: document name // value: document contents for each word w in value: EmitIntermediate(w, “1”): reduce(String key, Iterator values): // key: a word // values: a list of counts int result = 0; for each v in values: result += ParseInt(v); Emit(AsString(result));
Dan Suciu -- CSEP544 Fall 2010
31
Dan Suciu -- CSEP544 Fall 2010
32
Dan Suciu -- CSEP544 Fall 2010
33 Dan Suciu -- CSEP544 Fall 2010
Local storage `
35 Dan Suciu -- CSEP544 Fall 2010
36 Dan Suciu -- CSEP544 Fall 2010
37 Dan Suciu -- CSEP544 Fall 2010
Dan Suciu -- CSEP544 Fall 2010 38
http://hadoop.apache.org/pig/
– Map: every record handled individually – Shuffle: records collected by key – Reduce: key and iterator of all associated values
– input and output (usually files) – map Java function – key to aggregate on – reduce Java function
aggregations, etc.
map map reduce reduce map map reduce reduce
map map reduce reduce map map reduce reduce Romeo, Romeo, wherefore art thou Romeo? What, art thou hurt?
map map reduce reduce map map reduce reduce Romeo, Romeo, wherefore art thou Romeo? Romeo, 1 Romeo, 1 wherefore, 1 art, 1 thou, 1 Romeo, 1 What, art thou hurt? What, 1 art, 1 thou, 1 hurt, 1
map map reduce reduce map map reduce reduce Romeo, Romeo, wherefore art thou Romeo? Romeo, 1 Romeo, 1 wherefore, 1 art, 1 thou, 1 Romeo, 1 art, (1, 1) hurt (1), thou (1, 1) What, art thou hurt? What, 1 art, 1 thou, 1 hurt, 1 Romeo, (1, 1, 1) wherefore, (1) what, (1)
map map reduce reduce map map reduce reduce Romeo, Romeo, wherefore art thou Romeo? Romeo, 1 Romeo, 1 wherefore, 1 art, 1 thou, 1 Romeo, 1 art, (1, 1) hurt (1), thou (1, 1) art, 2 hurt, 1 thou, 2 What, art thou hurt? What, 1 art, 1 thou, 1 hurt, 1 Romeo, (1, 1, 1) wherefore, (1) what, (1) Romeo, 3 wherefore, 1 what, 1
handles retries
all your data:
– data mining – model tuning
processes; oriented around independent units of work
Load Users Load Pages Filter by age Join on name Group on url Count clicks Order by clicks Take top 5
– Imperative – Provides standard relational transforms (join, sort, etc.) – Schemas are optional, used when available, can be defined at runtime – User Defined Functions are first class citizens – Opportunities for advanced optimizer but optimizations by programmer also possible
Parser
Script
A = load B = filter C = group D = foreach
Logical Plan
Semantic Checks
Logical Plan
Logical Optimizer
Logical Plan
Logical to Physical Translator
Physical Plan
Physical To MR Translator MapReduce Launcher
Jar to hadoop Map-Reduce Plan Logical Plan relational algebra Plan standard
Physical Plan = physical operators to be executed Reduce stages Map-Reduce Plan = physical operators broken into Map, Combine, and Reduce stages
single MR job (0.3)
merge in map phase (0.4)
splitting of key across multiple reducers to handle skew. (0.4)
data (0.4)
easier to write (0.7, branched but not released)
released in 0.8).
Aka “Broakdcast Join”
Users = load ‘users’ as (name, age); Pages = load ‘pages’ as (user, url); Jnd = join Pages by user, Users by name using “replicated”;
Aka “Broakdcast Join”
Users = load ‘users’ as (name, age); Pages = load ‘pages’ as (user, url); Jnd = join Pages by user, Users by name using “replicated”;
Aka “Broakdcast Join”
Users = load ‘users’ as (name, age); Pages = load ‘pages’ as (user, url); Jnd = join Pages by user, Users by name using “replicated”;
Aka “Broakdcast Join”
Users = load ‘users’ as (name, age); Pages = load ‘pages’ as (user, url); Jnd = join Pages by user, Users by name using “replicated”;
Aka “Broakdcast Join”
Users = load ‘users’ as (name, age); Pages = load ‘pages’ as (user, url); Jnd = join Users by name, Pages by user;
Users = load ‘users’ as (name, age); Pages = load ‘pages’ as (user, url); Jnd = join Users by name, Pages by user;
Users = load ‘users’ as (name, age); Pages = load ‘pages’ as (user, url); Jnd = join Users by name, Pages by user;
Users = load ‘users’ as (name, age); Pages = load ‘pages’ as (user, url); Jnd = join Users by name, Pages by user;
(1, user) (2, name)
Users = load ‘users’ as (name, age); Pages = load ‘pages’ as (user, url); Jnd = join Users by name, Pages by user;
(1, user) (2, name) (1, fred) (2, fred) (2, fred) (1, jane) (2, jane) (2, jane)
Users = load ‘users’ as (name, age); Pages = load ‘pages’ as (user, url); Jnd = join Pages by user, Users by name using “skewed”;
Users = load ‘users’ as (name, age); Pages = load ‘pages’ as (user, url); Jnd = join Pages by user, Users by name using “skewed”;
Users = load ‘users’ as (name, age); Pages = load ‘pages’ as (user, url); Jnd = join Pages by user, Users by name using “skewed”;
Users = load ‘users’ as (name, age); Pages = load ‘pages’ as (user, url); Jnd = join Pages by user, Users by name using “skewed”;
Users = load ‘users’ as (name, age); Pages = load ‘pages’ as (user, url); Jnd = join Pages by user, Users by name using “skewed”;
(1, user) (2, name)
Users = load ‘users’ as (name, age); Pages = load ‘pages’ as (user, url); Jnd = join Pages by user, Users by name using “skewed”;
(1, user) (2, name) (1, fred, p1) (1, fred, p2) (2, fred) (1, fred, p3) (1, fred, p4) (2, fred)
aaron . . . . . . . . zach aaron . . . . . . . . zach
aaron . . . . . . . . zach aaron . . . . . . . . zach Users = load ‘users’ as (name, age); Pages = load ‘pages’ as (user, url); Jnd = join Pages by user, Users by name using “merge”;
aaron . . . . . . . . zach aaron . . . . . . . . zach Users = load ‘users’ as (name, age); Pages = load ‘pages’ as (user, url); Jnd = join Pages by user, Users by name using “merge”;
aaron . . . . . . . . zach aaron . . . . . . . . zach Users = load ‘users’ as (name, age); Pages = load ‘pages’ as (user, url); Jnd = join Pages by user, Users by name using “merge”;
aaron… amr aaron … amy… barb amy …
load users load users filter nulls filter nulls group by state group by state group by age, gender group by age, gender apply UDFs apply UDFs apply UDFs apply UDFs store into ‘bystate’ store into ‘bystate’ store into ‘bydemo’ store into ‘bydemo’
map map filter filter local rearrange local rearrange split split local rearrange local rearrange reduce reduce demux demux package package package package foreach foreach foreach foreach
Hadoop distribution
– Search infrastructure – Ad relevance – Model training – User intent analysis – Web log processing – Image processing – Incremental processing of large data sets
written in actual Latin
and Java offers poor control of memory usage, how can Pig be written to use memory well?
Hadoop to best run a particular script?
tools fit into the MR world?
available via Hadoop, but they don’t want to wait hours for their jobs to finish; can Pig find a way to answer analysts question in under 60 seconds?
MR jobs?
– From Yahoo, http://developer.yahoo.com/hadoop/tutorial/ – From Cloudera, http://www.cloudera.com/hadoop-training
chapters on Pig, search at your favorite bookstore
– pig-user@hadoop.apache.org for user questions – pig-dev@hadoop.apache.com for developer issues
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
Dan Suciu -- CSEP544 Fall 2010 110
111 Dan Suciu -- CSEP544 Fall 2010
112
Dan Suciu -- CSEP544 Fall 2010
113 Dan Suciu -- CSEP544 Fall 2010
114
115 Dan Suciu -- CSEP544 Fall 2010
1 1 1 1 1
116
Why don’t we lose any Pages?
1 1 1 1 1
117 Dan Suciu -- CSEP544 Fall 2010
118 Dan Suciu -- CSEP544 Fall 2010
1
119 Dan Suciu -- CSEP544 Fall 2010
1
120 Dan Suciu -- CSEP544 Fall 2010
1 1 1 1 1
121 Dan Suciu -- CSEP544 Fall 2010
1 1 1 1 1
122 Dan Suciu -- CSEP544 Fall 2010
1 1 1 1 1
123 Dan Suciu -- CSEP544 Fall 2010
1 1 1 1 1
Dan Suciu -- CSEP544 Fall 2010 124
1 1 1 1 1
125 Dan Suciu -- CSEP544 Fall 2010
126 Dan Suciu -- CSEP544 Fall 2010
127
128 Dan Suciu -- CSEP544 Fall 2010
129 Dan Suciu -- CSEP544 Fall 2010
1 1 1
130 Dan Suciu -- CSEP544 Fall 2010
1 1 1
131 Dan Suciu -- CSEP544 Fall 2010
1 1 1 1 1
132 Dan Suciu -- CSEP544 Fall 2010
1 1 1 1 1
133 Dan Suciu -- CSEP544 Fall 2010
134
135
136
Dan Suciu -- CSEP544 Fall 2010 137
Dan Suciu -- CSEP544 Fall 2010 138
139 Dan Suciu -- CSEP544 Fall 2010
140 Dan Suciu -- CSEP544 Fall 2010
141 Dan Suciu -- CSEP544 Fall 2010
142 Dan Suciu -- CSEP544 Fall 2010