SlideShare a Scribd company logo
1 of 34
Download to read offline
Data Intensive Text
Processing with MapReduce
- #3 MapReduce Algorithm Design -


          @just_do_neet
Data Intensive...(snip
         書籍




Data Intensive Text Processing with MapReduce #3   2
#3 MapReduce Algorithm Design
         第三章:MapReduce アルゴリズムの設計


             •MapReduceはシンプルでスケーラブル
              (Mapper / Reducer)

             •シンプルなため制約が大きく、限定的な手法しか
              用いることができない。

             •その中で、MapReduceにおけるデザインパターン
              的なものや、問題解決のテクニックを紹介。




Data Intensive Text Processing with MapReduce #3   3
#3 MapReduce Algorithm Design
         第三章:MapReduce アルゴリズムの設計


             •ローカル集約

             •pairsとstripes

             •相対頻度の計算

             •セカンダリソート

             •リレーショナルな結合




Data Intensive Text Processing with MapReduce #3   4
ローカル集約




Data Intensive Text Processing with MapReduce #3   5
Local Aggregation
         ローカル集約


             •HadoopではMap→Reduce間の受け渡しの際に中
              間データをディスクに書き込む

                 •オーバーヘッドが大きい

             •中間データの削減を行う事で処理効率がアップす
              る




Data Intensive Text Processing with MapReduce #3   6
Local Aggregation
         ローカル集約


             •問題設定:さだまさしの歌詞から頻出単語を抽
              出。

                      •データ元:http://www.cai-insect.jp/sada/




Data Intensive Text Processing with MapReduce #3             7
Local Aggregation
         ローカル集約


             •標準的なMapReduce処理
              ドキュメント中に語が出現するごとにEmit




             • https://gist.github.com/3475182
               https://gist.github.com/3475195


Data Intensive Text Processing with MapReduce #3   8
Local Aggregation
         ローカル集約


             •連想配列を用いてドキュメントごとに語のカウン
              トを集計してEmit(in-mapper combining)




             • https://gist.github.com/3475211



Data Intensive Text Processing with MapReduce #3   9
Local Aggregation
         ローカル集約


             •連想配列をクラス内で保持し、すべてのドキュメ
              ント中の語のカウントを集計した後にEmit




             • https://gist.github.com/3475214



Data Intensive Text Processing with MapReduce #3   10
Local Aggregation
         ローカル集約


             •in-mapper combining のメリット

                 •Map→Reduceの受け渡し回数を減らすことで
                   パフォーマンスの向上が期待できる。

             •デメリット

                 •Mapタスクのメモリ枯渇に注意

                 •データ出現パターンによってはあまり有効でな
                   いケースもある。
Data Intensive Text Processing with MapReduce #3   11
Local Aggregation
         ローカル集約


             •in-mapper combiningのnaiveな改善(メモリ関連)

                 •https://gist.github.com/3475348

                 •定期的にMapの内容をフラッシュ




Data Intensive Text Processing with MapReduce #3    12
pairsとstripes




Data Intensive Text Processing with MapReduce #3    13
pairs and stripes
         pairsとstripes


             •複合型のキーの集約テクニック

             •一例:文章の中から語の共起頻度を算出する

                 •共起:ある単語がある文章中に出たとき、その
                   文章中に別の限られた単語が頻繁に出現するこ
                   と。(wikipedia)

                 •「私はさだまさしが好きです。」
                   →「私:さだまさし」「私:好き」...

Data Intensive Text Processing with MapReduce #3   14
pairs and stripes
         pairsとstripes


             •共起語抽出の情報量→基本的にO(n^2)

                 •「私はさだまさしが好きです。」
                   →「私:は」「私:さだまさし」「私:が」...
                    「好き:です」

         私                                は        さだまさし      が     好き    です
         は               (私)                       さだまさし      が     好き    です
    さだまさし                (私)            (は)                   が     好き    です
         が               (私)            (は)        (さだまさし)          好き    です
        好き               (私)            (は)        (さだまさし)   (が)          です
        です               (私)            (は)        (さだまさし)   (が)   (好き)

Data Intensive Text Processing with MapReduce #3                               15
pairs and stripes
         pairsとstripes


             •問題設定:さだまさしの歌詞から頻出する共起語
              を抽出。

                      •データ元:http://www.cai-insect.jp/sada/




Data Intensive Text Processing with MapReduce #3             16
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
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
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
pairs and stripes
         pairsとstripes


             •共起語の出現頻度




Data Intensive Text Processing with MapReduce #3   20
相対頻度




Data Intensive Text Processing with MapReduce #3   21
Computing Relative Freq.
         相対頻度


             •ある語wと共起するuの出現頻度だけでなく、相
              対頻度(条件付き確率?)が取得したい場合があ
              る。

             •そのためには語wの出現頻度(式右下部)を算出
              する必要がある。




Data Intensive Text Processing with MapReduce #3   22
Computing Relative Freq.
         相対頻度


             •stripes: https://gist.github.com/3475934

                 •語wについて、すべての共起語uとその出現頻
                   度がReducerに渡されるので、出現頻度を合算
                   して計算すれば良い。

             •pairs: https://gist.github.com/3475992

                 •そのままでは不可。Partitionerを改修して、語
                   wが先頭のkeyをすべて同じReducerに振り分
                   けるようにする必要がある。

Data Intensive Text Processing with MapReduce #3         23
セカンダリソート




Data Intensive Text Processing with MapReduce #3   24
Secondary Sort
         セカンダリソート


             •Keyだけでなく、Valueでもソートをしたい

                 1.Reduceの中でソート

                 2.Map→Reduceの際に、ソートしたいValueを
                   Keyに含めてしまう。
                   (value-to-key conversion)




Data Intensive Text Processing with MapReduce #3   25
Secondary Sort
         セカンダリソート


             •問題設定:さだまさしのコンサート会場のリスト
              を解析

                      •Sort1:コンサート会場
                        Sort2:コンサート実施年




Data Intensive Text Processing with MapReduce #3   26
Secondary Sort
         セカンダリソート


             •Reduceの中でソート

                 • https://gist.github.com/3486552
                   https://gist.github.com/3486554



                 • Map→Reduce
                   {“東京厚生年金会館” : “2000t1”} {“東京厚生年金会館” : “2000t1”} {“東
                   京厚生年金会館” : “2001t1”}
                   Reduce→Result
                   {“東京厚生年金会館” : “2000t2”}
                   {“東京厚生年金会館” : “2001t1”} ←Reduce内で年で並び替え




Data Intensive Text Processing with MapReduce #3                           27
Secondary Sort
         セカンダリソート


             •value-to-key conversion
                 • https://gist.github.com/3486573



                 • Map→Reduce
                   {“東京厚生年金会館t2000” : 1} {“東京厚生年金会館t2000” : 1} {“東京
                   厚生年金会館t2001” : 1} ←Keyの中に年を含める
                   Reduce→Result
                   {“東京厚生年金会館t2000” : 2}
                   {“東京厚生年金会館t2001” : 1}




Data Intensive Text Processing with MapReduce #3                        28
リレーショナルな結合




Data Intensive Text Processing with MapReduce #3   29
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
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
Relational Join
         リレーショナルな結合


             •Memory-Backed Join

                 •参考:
                   http://d.hatena.ne.jp/wyukawa/20110818/1313670105




Data Intensive Text Processing with MapReduce #3                       32
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
ご清聴
                  ありがとうございました



Data Intensive Text Processing with MapReduce #3     34

More Related Content

Viewers also liked

中国最新ニュースアプリ事情
中国最新ニュースアプリ事情中国最新ニュースアプリ事情
中国最新ニュースアプリ事情moai kids
 
ANTLR-ANother Tool for Language Recognition
ANTLR-ANother Tool for Language RecognitionANTLR-ANother Tool for Language Recognition
ANTLR-ANother Tool for Language Recognitionelliando dias
 
Hadoop World 2011: Replacing RDB/DW with Hadoop and Hive for Telco Big Data -...
Hadoop World 2011: Replacing RDB/DW with Hadoop and Hive for Telco Big Data -...Hadoop World 2011: Replacing RDB/DW with Hadoop and Hive for Telco Big Data -...
Hadoop World 2011: Replacing RDB/DW with Hadoop and Hive for Telco Big Data -...Cloudera, Inc.
 
Hadoopソースコードリーディング8/MapRを使ってみた
Hadoopソースコードリーディング8/MapRを使ってみたHadoopソースコードリーディング8/MapRを使ってみた
Hadoopソースコードリーディング8/MapRを使ってみたRecruit Technologies
 
Hive Object Model
Hive Object ModelHive Object Model
Hive Object ModelZheng Shao
 
Hive on Spark の設計指針を読んでみた
Hive on Spark の設計指針を読んでみたHive on Spark の設計指針を読んでみた
Hive on Spark の設計指針を読んでみたRecruit Technologies
 
Tez on EMRを試してみた
Tez on EMRを試してみたTez on EMRを試してみた
Tez on EMRを試してみたSatoshi Noto
 
Node.jsエンジニア Erlangに入門するの巻
Node.jsエンジニア Erlangに入門するの巻Node.jsエンジニア Erlangに入門するの巻
Node.jsエンジニア Erlangに入門するの巻Recruit Technologies
 
Hive Anatomy
Hive AnatomyHive Anatomy
Hive Anatomynzhang
 
Apache Tez: Accelerating Hadoop Query Processing
Apache Tez: Accelerating Hadoop Query ProcessingApache Tez: Accelerating Hadoop Query Processing
Apache Tez: Accelerating Hadoop Query ProcessingHortonworks
 
How to understand and analyze Apache Hive query execution plan for performanc...
How to understand and analyze Apache Hive query execution plan for performanc...How to understand and analyze Apache Hive query execution plan for performanc...
How to understand and analyze Apache Hive query execution plan for performanc...DataWorks Summit/Hadoop Summit
 
何となく勉強した気分になれるパーサ入門
何となく勉強した気分になれるパーサ入門何となく勉強した気分になれるパーサ入門
何となく勉強した気分になれるパーサ入門masayoshi takahashi
 
リクルートにおけるデータのインフラ化への取組
リクルートにおけるデータのインフラ化への取組リクルートにおけるデータのインフラ化への取組
リクルートにおけるデータのインフラ化への取組Recruit Technologies
 

Viewers also liked (14)

中国最新ニュースアプリ事情
中国最新ニュースアプリ事情中国最新ニュースアプリ事情
中国最新ニュースアプリ事情
 
ANTLR-ANother Tool for Language Recognition
ANTLR-ANother Tool for Language RecognitionANTLR-ANother Tool for Language Recognition
ANTLR-ANother Tool for Language Recognition
 
Hadoop World 2011: Replacing RDB/DW with Hadoop and Hive for Telco Big Data -...
Hadoop World 2011: Replacing RDB/DW with Hadoop and Hive for Telco Big Data -...Hadoop World 2011: Replacing RDB/DW with Hadoop and Hive for Telco Big Data -...
Hadoop World 2011: Replacing RDB/DW with Hadoop and Hive for Telco Big Data -...
 
Hadoopソースコードリーディング8/MapRを使ってみた
Hadoopソースコードリーディング8/MapRを使ってみたHadoopソースコードリーディング8/MapRを使ってみた
Hadoopソースコードリーディング8/MapRを使ってみた
 
Hive Object Model
Hive Object ModelHive Object Model
Hive Object Model
 
Hive on Spark の設計指針を読んでみた
Hive on Spark の設計指針を読んでみたHive on Spark の設計指針を読んでみた
Hive on Spark の設計指針を読んでみた
 
Tez on EMRを試してみた
Tez on EMRを試してみたTez on EMRを試してみた
Tez on EMRを試してみた
 
Internal Hive
Internal HiveInternal Hive
Internal Hive
 
Node.jsエンジニア Erlangに入門するの巻
Node.jsエンジニア Erlangに入門するの巻Node.jsエンジニア Erlangに入門するの巻
Node.jsエンジニア Erlangに入門するの巻
 
Hive Anatomy
Hive AnatomyHive Anatomy
Hive Anatomy
 
Apache Tez: Accelerating Hadoop Query Processing
Apache Tez: Accelerating Hadoop Query ProcessingApache Tez: Accelerating Hadoop Query Processing
Apache Tez: Accelerating Hadoop Query Processing
 
How to understand and analyze Apache Hive query execution plan for performanc...
How to understand and analyze Apache Hive query execution plan for performanc...How to understand and analyze Apache Hive query execution plan for performanc...
How to understand and analyze Apache Hive query execution plan for performanc...
 
何となく勉強した気分になれるパーサ入門
何となく勉強した気分になれるパーサ入門何となく勉強した気分になれるパーサ入門
何となく勉強した気分になれるパーサ入門
 
リクルートにおけるデータのインフラ化への取組
リクルートにおけるデータのインフラ化への取組リクルートにおけるデータのインフラ化への取組
リクルートにおけるデータのインフラ化への取組
 

More from moai kids

FluentdとRedshiftの素敵な関係
FluentdとRedshiftの素敵な関係FluentdとRedshiftの素敵な関係
FluentdとRedshiftの素敵な関係moai kids
 
Twitterのsnowflakeについて
TwitterのsnowflakeについてTwitterのsnowflakeについて
Twitterのsnowflakeについてmoai kids
 
Casual Compression on MongoDB
Casual Compression on MongoDBCasual Compression on MongoDB
Casual Compression on MongoDBmoai kids
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDBmoai kids
 
Hadoop Conference Japan 2011 Fallに行ってきました
Hadoop Conference Japan 2011 Fallに行ってきましたHadoop Conference Japan 2011 Fallに行ってきました
Hadoop Conference Japan 2011 Fallに行ってきましたmoai kids
 
HBase本輪読会資料(11章)
HBase本輪読会資料(11章)HBase本輪読会資料(11章)
HBase本輪読会資料(11章)moai kids
 
snappyについて
snappyについてsnappyについて
snappyについてmoai kids
 
第四回月次セミナー(公開版)
第四回月次セミナー(公開版)第四回月次セミナー(公開版)
第四回月次セミナー(公開版)moai kids
 
第三回月次セミナー(公開版)
第三回月次セミナー(公開版)第三回月次セミナー(公開版)
第三回月次セミナー(公開版)moai kids
 
Pythonで自然言語処理
Pythonで自然言語処理Pythonで自然言語処理
Pythonで自然言語処理moai kids
 
HandlerSocket plugin Client for Javaとそれを用いたベンチマーク
HandlerSocket plugin Client for Javaとそれを用いたベンチマークHandlerSocket plugin Client for Javaとそれを用いたベンチマーク
HandlerSocket plugin Client for Javaとそれを用いたベンチマークmoai kids
 
Yammer試用レポート(公開版)
Yammer試用レポート(公開版)Yammer試用レポート(公開版)
Yammer試用レポート(公開版)moai kids
 
掲示板時間軸コーパスを用いたワードトレンド解析(公開版)
掲示板時間軸コーパスを用いたワードトレンド解析(公開版)掲示板時間軸コーパスを用いたワードトレンド解析(公開版)
掲示板時間軸コーパスを用いたワードトレンド解析(公開版)moai kids
 
中国と私(仮題)
中国と私(仮題)中国と私(仮題)
中国と私(仮題)moai kids
 
不自然言語処理コンテストLT資料
不自然言語処理コンテストLT資料不自然言語処理コンテストLT資料
不自然言語処理コンテストLT資料moai kids
 
n-gramコーパスを用いた類義語自動獲得手法について
n-gramコーパスを用いた類義語自動獲得手法についてn-gramコーパスを用いた類義語自動獲得手法について
n-gramコーパスを用いた類義語自動獲得手法についてmoai kids
 
Analysis of ‘lang-8’
Analysis of ‘lang-8’Analysis of ‘lang-8’
Analysis of ‘lang-8’moai kids
 
Androidの音声認識とテキスト読み上げ機能について
Androidの音声認識とテキスト読み上げ機能についてAndroidの音声認識とテキスト読み上げ機能について
Androidの音声認識とテキスト読み上げ機能についてmoai kids
 
Amebaサーチ使用傾向
Amebaサーチ使用傾向Amebaサーチ使用傾向
Amebaサーチ使用傾向moai kids
 
Amebaサーチのデータを用いた応用
Amebaサーチのデータを用いた応用Amebaサーチのデータを用いた応用
Amebaサーチのデータを用いた応用moai kids
 

More from moai kids (20)

FluentdとRedshiftの素敵な関係
FluentdとRedshiftの素敵な関係FluentdとRedshiftの素敵な関係
FluentdとRedshiftの素敵な関係
 
Twitterのsnowflakeについて
TwitterのsnowflakeについてTwitterのsnowflakeについて
Twitterのsnowflakeについて
 
Casual Compression on MongoDB
Casual Compression on MongoDBCasual Compression on MongoDB
Casual Compression on MongoDB
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
Hadoop Conference Japan 2011 Fallに行ってきました
Hadoop Conference Japan 2011 Fallに行ってきましたHadoop Conference Japan 2011 Fallに行ってきました
Hadoop Conference Japan 2011 Fallに行ってきました
 
HBase本輪読会資料(11章)
HBase本輪読会資料(11章)HBase本輪読会資料(11章)
HBase本輪読会資料(11章)
 
snappyについて
snappyについてsnappyについて
snappyについて
 
第四回月次セミナー(公開版)
第四回月次セミナー(公開版)第四回月次セミナー(公開版)
第四回月次セミナー(公開版)
 
第三回月次セミナー(公開版)
第三回月次セミナー(公開版)第三回月次セミナー(公開版)
第三回月次セミナー(公開版)
 
Pythonで自然言語処理
Pythonで自然言語処理Pythonで自然言語処理
Pythonで自然言語処理
 
HandlerSocket plugin Client for Javaとそれを用いたベンチマーク
HandlerSocket plugin Client for Javaとそれを用いたベンチマークHandlerSocket plugin Client for Javaとそれを用いたベンチマーク
HandlerSocket plugin Client for Javaとそれを用いたベンチマーク
 
Yammer試用レポート(公開版)
Yammer試用レポート(公開版)Yammer試用レポート(公開版)
Yammer試用レポート(公開版)
 
掲示板時間軸コーパスを用いたワードトレンド解析(公開版)
掲示板時間軸コーパスを用いたワードトレンド解析(公開版)掲示板時間軸コーパスを用いたワードトレンド解析(公開版)
掲示板時間軸コーパスを用いたワードトレンド解析(公開版)
 
中国と私(仮題)
中国と私(仮題)中国と私(仮題)
中国と私(仮題)
 
不自然言語処理コンテストLT資料
不自然言語処理コンテストLT資料不自然言語処理コンテストLT資料
不自然言語処理コンテストLT資料
 
n-gramコーパスを用いた類義語自動獲得手法について
n-gramコーパスを用いた類義語自動獲得手法についてn-gramコーパスを用いた類義語自動獲得手法について
n-gramコーパスを用いた類義語自動獲得手法について
 
Analysis of ‘lang-8’
Analysis of ‘lang-8’Analysis of ‘lang-8’
Analysis of ‘lang-8’
 
Androidの音声認識とテキスト読み上げ機能について
Androidの音声認識とテキスト読み上げ機能についてAndroidの音声認識とテキスト読み上げ機能について
Androidの音声認識とテキスト読み上げ機能について
 
Amebaサーチ使用傾向
Amebaサーチ使用傾向Amebaサーチ使用傾向
Amebaサーチ使用傾向
 
Amebaサーチのデータを用いた応用
Amebaサーチのデータを用いた応用Amebaサーチのデータを用いた応用
Amebaサーチのデータを用いた応用
 

Recently uploaded

AWS の OpenShift サービス (ROSA) を使った OpenShift Virtualizationの始め方.pdf
AWS の OpenShift サービス (ROSA) を使った OpenShift Virtualizationの始め方.pdfAWS の OpenShift サービス (ROSA) を使った OpenShift Virtualizationの始め方.pdf
AWS の OpenShift サービス (ROSA) を使った OpenShift Virtualizationの始め方.pdfFumieNakayama
 
モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察 ~Text-to-MusicとText-To-ImageかつImage-to-Music...
モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察  ~Text-to-MusicとText-To-ImageかつImage-to-Music...モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察  ~Text-to-MusicとText-To-ImageかつImage-to-Music...
モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察 ~Text-to-MusicとText-To-ImageかつImage-to-Music...博三 太田
 
クラウドネイティブなサーバー仮想化基盤 - OpenShift Virtualization.pdf
クラウドネイティブなサーバー仮想化基盤 - OpenShift Virtualization.pdfクラウドネイティブなサーバー仮想化基盤 - OpenShift Virtualization.pdf
クラウドネイティブなサーバー仮想化基盤 - OpenShift Virtualization.pdfFumieNakayama
 
CTO, VPoE, テックリードなどリーダーポジションに登用したくなるのはどんな人材か?
CTO, VPoE, テックリードなどリーダーポジションに登用したくなるのはどんな人材か?CTO, VPoE, テックリードなどリーダーポジションに登用したくなるのはどんな人材か?
CTO, VPoE, テックリードなどリーダーポジションに登用したくなるのはどんな人材か?akihisamiyanaga1
 
デジタル・フォレンジックの最新動向(2024年4月27日情洛会総会特別講演スライド)
デジタル・フォレンジックの最新動向(2024年4月27日情洛会総会特別講演スライド)デジタル・フォレンジックの最新動向(2024年4月27日情洛会総会特別講演スライド)
デジタル・フォレンジックの最新動向(2024年4月27日情洛会総会特別講演スライド)UEHARA, Tetsutaro
 
TataPixel: 畳の異方性を利用した切り替え可能なディスプレイの提案
TataPixel: 畳の異方性を利用した切り替え可能なディスプレイの提案TataPixel: 畳の異方性を利用した切り替え可能なディスプレイの提案
TataPixel: 畳の異方性を利用した切り替え可能なディスプレイの提案sugiuralab
 
業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)
業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)
業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)Hiroshi Tomioka
 
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)NTT DATA Technology & Innovation
 
自分史上一番早い2024振り返り〜コロナ後、仕事は通常ペースに戻ったか〜 by IoT fullstack engineer
自分史上一番早い2024振り返り〜コロナ後、仕事は通常ペースに戻ったか〜 by IoT fullstack engineer自分史上一番早い2024振り返り〜コロナ後、仕事は通常ペースに戻ったか〜 by IoT fullstack engineer
自分史上一番早い2024振り返り〜コロナ後、仕事は通常ペースに戻ったか〜 by IoT fullstack engineerYuki Kikuchi
 

Recently uploaded (9)

AWS の OpenShift サービス (ROSA) を使った OpenShift Virtualizationの始め方.pdf
AWS の OpenShift サービス (ROSA) を使った OpenShift Virtualizationの始め方.pdfAWS の OpenShift サービス (ROSA) を使った OpenShift Virtualizationの始め方.pdf
AWS の OpenShift サービス (ROSA) を使った OpenShift Virtualizationの始め方.pdf
 
モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察 ~Text-to-MusicとText-To-ImageかつImage-to-Music...
モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察  ~Text-to-MusicとText-To-ImageかつImage-to-Music...モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察  ~Text-to-MusicとText-To-ImageかつImage-to-Music...
モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察 ~Text-to-MusicとText-To-ImageかつImage-to-Music...
 
クラウドネイティブなサーバー仮想化基盤 - OpenShift Virtualization.pdf
クラウドネイティブなサーバー仮想化基盤 - OpenShift Virtualization.pdfクラウドネイティブなサーバー仮想化基盤 - OpenShift Virtualization.pdf
クラウドネイティブなサーバー仮想化基盤 - OpenShift Virtualization.pdf
 
CTO, VPoE, テックリードなどリーダーポジションに登用したくなるのはどんな人材か?
CTO, VPoE, テックリードなどリーダーポジションに登用したくなるのはどんな人材か?CTO, VPoE, テックリードなどリーダーポジションに登用したくなるのはどんな人材か?
CTO, VPoE, テックリードなどリーダーポジションに登用したくなるのはどんな人材か?
 
デジタル・フォレンジックの最新動向(2024年4月27日情洛会総会特別講演スライド)
デジタル・フォレンジックの最新動向(2024年4月27日情洛会総会特別講演スライド)デジタル・フォレンジックの最新動向(2024年4月27日情洛会総会特別講演スライド)
デジタル・フォレンジックの最新動向(2024年4月27日情洛会総会特別講演スライド)
 
TataPixel: 畳の異方性を利用した切り替え可能なディスプレイの提案
TataPixel: 畳の異方性を利用した切り替え可能なディスプレイの提案TataPixel: 畳の異方性を利用した切り替え可能なディスプレイの提案
TataPixel: 畳の異方性を利用した切り替え可能なディスプレイの提案
 
業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)
業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)
業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)
 
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
 
自分史上一番早い2024振り返り〜コロナ後、仕事は通常ペースに戻ったか〜 by IoT fullstack engineer
自分史上一番早い2024振り返り〜コロナ後、仕事は通常ペースに戻ったか〜 by IoT fullstack engineer自分史上一番早い2024振り返り〜コロナ後、仕事は通常ペースに戻ったか〜 by IoT fullstack engineer
自分史上一番早い2024振り返り〜コロナ後、仕事は通常ペースに戻ったか〜 by IoT fullstack engineer
 

Data Intensive Text Processing with MapReduce - #3 MapReduce Algorithm Design -

  • 1. Data Intensive Text Processing with MapReduce - #3 MapReduce Algorithm Design - @just_do_neet
  • 2. Data Intensive...(snip 書籍 Data Intensive Text Processing with MapReduce #3 2
  • 3. #3 MapReduce Algorithm Design 第三章:MapReduce アルゴリズムの設計 •MapReduceはシンプルでスケーラブル (Mapper / Reducer) •シンプルなため制約が大きく、限定的な手法しか 用いることができない。 •その中で、MapReduceにおけるデザインパターン 的なものや、問題解決のテクニックを紹介。 Data Intensive Text Processing with MapReduce #3 3
  • 4. #3 MapReduce Algorithm Design 第三章:MapReduce アルゴリズムの設計 •ローカル集約 •pairsとstripes •相対頻度の計算 •セカンダリソート •リレーショナルな結合 Data Intensive Text Processing with MapReduce #3 4
  • 5. ローカル集約 Data Intensive Text Processing with MapReduce #3 5
  • 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
  • 13. pairsとstripes Data Intensive Text Processing with MapReduce #3 13
  • 14. pairs and stripes pairsとstripes •複合型のキーの集約テクニック •一例:文章の中から語の共起頻度を算出する •共起:ある単語がある文章中に出たとき、その 文章中に別の限られた単語が頻繁に出現するこ と。(wikipedia) •「私はさだまさしが好きです。」 →「私:さだまさし」「私:好き」... Data Intensive Text Processing with MapReduce #3 14
  • 15. pairs and stripes pairsとstripes •共起語抽出の情報量→基本的にO(n^2) •「私はさだまさしが好きです。」 →「私:は」「私:さだまさし」「私:が」...  「好き:です」 私 は さだまさし が 好き です は (私) さだまさし が 好き です さだまさし (私) (は) が 好き です が (私) (は) (さだまさし) 好き です 好き (私) (は) (さだまさし) (が) です です (私) (は) (さだまさし) (が) (好き) Data Intensive Text Processing with MapReduce #3 15
  • 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
  • 21. 相対頻度 Data Intensive Text Processing with MapReduce #3 21
  • 22. Computing Relative Freq. 相対頻度 •ある語wと共起するuの出現頻度だけでなく、相 対頻度(条件付き確率?)が取得したい場合があ る。 •そのためには語wの出現頻度(式右下部)を算出 する必要がある。 Data Intensive Text Processing with MapReduce #3 22
  • 23. Computing Relative Freq. 相対頻度 •stripes: https://gist.github.com/3475934 •語wについて、すべての共起語uとその出現頻 度がReducerに渡されるので、出現頻度を合算 して計算すれば良い。 •pairs: https://gist.github.com/3475992 •そのままでは不可。Partitionerを改修して、語 wが先頭のkeyをすべて同じReducerに振り分 けるようにする必要がある。 Data Intensive Text Processing with MapReduce #3 23
  • 24. セカンダリソート Data Intensive Text Processing with MapReduce #3 24
  • 25. Secondary Sort セカンダリソート •Keyだけでなく、Valueでもソートをしたい 1.Reduceの中でソート 2.Map→Reduceの際に、ソートしたいValueを Keyに含めてしまう。 (value-to-key conversion) Data Intensive Text Processing with MapReduce #3 25
  • 26. Secondary Sort セカンダリソート •問題設定:さだまさしのコンサート会場のリスト を解析 •Sort1:コンサート会場 Sort2:コンサート実施年 Data Intensive Text Processing with MapReduce #3 26
  • 27. Secondary Sort セカンダリソート •Reduceの中でソート • https://gist.github.com/3486552 https://gist.github.com/3486554 • Map→Reduce {“東京厚生年金会館” : “2000t1”} {“東京厚生年金会館” : “2000t1”} {“東 京厚生年金会館” : “2001t1”} Reduce→Result {“東京厚生年金会館” : “2000t2”} {“東京厚生年金会館” : “2001t1”} ←Reduce内で年で並び替え Data Intensive Text Processing with MapReduce #3 27
  • 28. Secondary Sort セカンダリソート •value-to-key conversion • https://gist.github.com/3486573 • Map→Reduce {“東京厚生年金会館t2000” : 1} {“東京厚生年金会館t2000” : 1} {“東京 厚生年金会館t2001” : 1} ←Keyの中に年を含める Reduce→Result {“東京厚生年金会館t2000” : 2} {“東京厚生年金会館t2001” : 1} Data Intensive Text Processing with MapReduce #3 28
  • 29. リレーショナルな結合 Data Intensive Text Processing with MapReduce #3 29
  • 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