update:2016/06/28
Example & homework: https://github.com/Phate334/MapReduceExample
簡報已更新並重新整理
This slide show you how to deploy Hadoop cluster with Cloudera and set up your own development environment to easy to test your MapReduce app.
這份簡報分成三個部分:
1.架設hadoop叢集,今年縮短了這部分的介紹,只放上一些參考的連結。
2.準備一個可以在本機端測試Mapreduce的開發環境,而不需要每次都將程式送到叢集中。
3.三個簡單的例子,用來介紹Mapreduce框架。
6. Some Information
• Cloudera vs Hortonworks vs MapR: Comparing
Hadoop Distributions
• Products that include Apache Hadoop or
derivative works and Commercial Support
• 大数据和Hadoop生态圈,Hadoop发行版和基
于Hadoop的企业级应用
• Hadoop十年解读与发展预测
6
62. Map 的 input 格式
• job.setInputFormatClass(TextInputFormat.clas
s)
– An InputFormat for plain text files. Files are
broken into lines. Either linefeed or carriage-
return are used to signal end of line. Keys are the
position in the file, and values are the line of text.
來源: Input Splits in Hadoop’s MapReduce
揭秘InputFormat:掌控Map Reduce任务执行的利
器
62
1. 如果最後一行被切斷,則向
下一個Block抓完整行資料。
2. 如果讀取的不是第一個block,
則跳過第一個Split。
63. Example 1
Map
Ma
p
R OI
map(KEYIN key, VALUEIN value,
org.apache.hadoop.mapreduce.Mapper.Context context)
Called once for each key/value pair in the input split.
63
67. Example 1
Reduce Reduc
e OI M
•如前一小節所述,所有同樣Key的資料對已經被收在一起,放在
一個java.lang.Iterable物件中。
•接下來用一個for-each把所有的值相加。
•我們的目的是輸出加總的值,所以KEYOUT給他一個NullWritable。
67