6. Local Aggregation
ローカル集約
•HadoopではMap→Reduce間の受け渡しの際に中
間データをディスクに書き込む
•オーバーヘッドが大きい
•中間データの削減を行う事で処理効率がアップす
る
Data Intensive Text Processing with MapReduce #3 6
7. Local Aggregation
ローカル集約
•問題設定:さだまさしの歌詞から頻出単語を抽
出。
•データ元:http://www.cai-insect.jp/sada/
Data Intensive Text Processing with MapReduce #3 7
8. Local Aggregation
ローカル集約
•標準的なMapReduce処理
ドキュメント中に語が出現するごとにEmit
• https://gist.github.com/3475182
https://gist.github.com/3475195
Data Intensive Text Processing with MapReduce #3 8
9. Local Aggregation
ローカル集約
•連想配列を用いてドキュメントごとに語のカウン
トを集計してEmit(in-mapper combining)
• https://gist.github.com/3475211
Data Intensive Text Processing with MapReduce #3 9
10. Local Aggregation
ローカル集約
•連想配列をクラス内で保持し、すべてのドキュメ
ント中の語のカウントを集計した後にEmit
• https://gist.github.com/3475214
Data Intensive Text Processing with MapReduce #3 10
11. Local Aggregation
ローカル集約
•in-mapper combining のメリット
•Map→Reduceの受け渡し回数を減らすことで
パフォーマンスの向上が期待できる。
•デメリット
•Mapタスクのメモリ枯渇に注意
•データ出現パターンによってはあまり有効でな
いケースもある。
Data Intensive Text Processing with MapReduce #3 11
12. Local Aggregation
ローカル集約
•in-mapper combiningのnaiveな改善(メモリ関連)
•https://gist.github.com/3475348
•定期的にMapの内容をフラッシュ
Data Intensive Text Processing with MapReduce #3 12
14. pairs and stripes
pairsとstripes
•複合型のキーの集約テクニック
•一例:文章の中から語の共起頻度を算出する
•共起:ある単語がある文章中に出たとき、その
文章中に別の限られた単語が頻繁に出現するこ
と。(wikipedia)
•「私はさだまさしが好きです。」
→「私:さだまさし」「私:好き」...
Data Intensive Text Processing with MapReduce #3 14
16. pairs and stripes
pairsとstripes
•問題設定:さだまさしの歌詞から頻出する共起語
を抽出。
•データ元:http://www.cai-insect.jp/sada/
Data Intensive Text Processing with MapReduce #3 16
17. pairs and stripes
pairsとstripes
•pairs:ワードwの共起語uを抽出し複合キーとし、
複合キー+出現頻度をEmit
• https://gist.github.com/3475607
https://gist.github.com/3475609
Data Intensive Text Processing with MapReduce #3 17
18. pairs and stripes
pairsとstripes
•stripes:ウインドウの最初の語wをキー。共起語u
のそれぞれの頻度をHashで保持しEmit
• https://gist.github.com/3475629
https://gist.github.com/3475644
Data Intensive Text Processing with MapReduce #3 18
19. pairs and stripes
pairsとstripes
•「私はさだまさしが好きです」
•pairs
• {私 は:1}, {私 さだまさし:1} ,{私 が:1}, {私 好き:1}, {私 です:1},
{は さだまさし:1}, {は が:1}.....
•stripes
• {私: {さだまさし:1} {が:1} {好き:1} {です:1}},
{は: {さだまさし:1} {が:1}.....}
•Map→Reduceのemitの数は paris > stripes
Data Intensive Text Processing with MapReduce #3 19
20. pairs and stripes
pairsとstripes
•共起語の出現頻度
Data Intensive Text Processing with MapReduce #3 20
30. Relational Join
リレーショナルな結合
•手法だけ紹介
•Reduce Side Join
→Reduce側でJoinする
•Map Side Join
→Map側でJoinする
•Memory-Backed Join
→Mapperもしくは外部メモリ(memcachedな
ど)でデータをまとめて保持し、Joinする
Data Intensive Text Processing with MapReduce #3 30
31. Relational Join
リレーショナルな結合
•Reduce Side Join
•参考:
http://code.google.com/p/try-hadoop-mapreduce-java/source/browse/trunk/try-mapreduce/
src/main/java/jp/gr/java_conf/n3104/try_mapreduce/
JoinWithDeptNameUsingReduceSideJoin.java
•Map Side Join
•参考:
http://code.google.com/p/try-hadoop-mapreduce-java/source/browse/trunk/try-mapreduce/
src/main/java/jp/gr/java_conf/n3104/try_mapreduce/
JoinWithDeptNameUsingReduceSideJoin.java
Data Intensive Text Processing with MapReduce #3 31
32. Relational Join
リレーショナルな結合
•Memory-Backed Join
•参考:
http://d.hatena.ne.jp/wyukawa/20110818/1313670105
Data Intensive Text Processing with MapReduce #3 32
33. Bibliography
参考文献(書籍以外)
•http://www.slideshare.net/nokuno/
hadoopreading05-data-intensive3
•http://d.hatena.ne.jp/wyukawa/
20111002/1317550750
Data Intensive Text Processing with MapReduce #3 33
34. ご清聴
ありがとうございました
Data Intensive Text Processing with MapReduce #3 34