Google Dremel

108
Google Dremel maruyama097 丸丸丸丸丸

description

 

Transcript of Google Dremel

Page 1: Google Dremel

Google Dremel

maruyama097

丸山不二夫

Page 2: Google Dremel

Dremel が利用されている領域 クロールされた Web ドキュメントの解析 Android マーケットで、インスロールされたアプリ

の追跡 Google 製品のクラッシュ報告 Google Books の OCR の結果 . スパムの解析 Google Map の map タイルのデバッグ Bigtable インスタンスの Tablet マイグレーション

の管理 Google の分散ビルドシステム上での実行テスト結果 数十万のディスクの Disk I/O 統計 Google データセンターで実行されているジョブの、

リソース・モニタリング Google のコードベースの、シンボルと従属性

Page 3: Google Dremel

Dremel のアイデア 第一。分散検索エンジンで利用されている、木構造

のアーキテクチャー。 Web 検索と同様に、検索は、木構造をたどって行われ、それを書き換える。検索結果は、下位の木構造から得られる答えを集約することで行われる。

第二。 Dremel は、 SQL-like な検索言語をサポートする。それは、 Hive や Pig とはことなり、 Map-Reduce には変換されずに、ネーティブに検索を実行する。

第三。 Dremel は、カラム単位で分割されたデータ構造を利用する。カラム型のストレージは、読み込むデータを少なくして、圧縮が簡単に出来るので、CPU のコストを削減する。カラム型のデータ・ストアは、リレーショナルなデータの解析には採用されてきたが、我々の知る限り、ネストしたデータ構造へのその拡張は、行われてこなかった。

Page 4: Google Dremel

Google Dremel

Page 5: Google Dremel

この論文が明らかにすること ネストしたデータの為の、カラム型ストレージの

フォーマット。ネストしたデータのカラム型への変換、逆に、カラム型からもとのデータの復元のアルゴリズムを与える。

Dremel の検索言語とその実行の概要。カラム型のネスト・データ上で効率的に実行され、ネストされたデータの再構成を必要としない。

Web 検索システムの実行木が、データベース処理にも利用出来ることを示す。集約検索が効率的に行われることを示して、そのメリットを明らかにする。

1000~4000 ノードで稼働する、一兆個のレコード、数テラバイトのデータセット上での実験の報告。

Page 6: Google Dremel

Dremel の背景 インタラクティブな検索処理が、広い範囲のデータ管理システ

ム環境に、適合することを、まず示そう。 シナリオ

Map Reduce ->billions of records Dremel   SQL  

DEFINE TABLE t AS /path/to/data/*SELECT TOP(signal1, 100), COUNT(*) FROM t

Dashboard 、 Catalog

検索処理とデータ管理ツールの相互運用性 共通ストレージ層  GFS 高パフォーマンスストレージ層 共有データフォーマット

Page 7: Google Dremel

message Document { required int64 DocId; optional group Links { repeated int64 Backward;    repeated int64 Forward; } repeated group Name { repeated group Language { required string Code;     optional string Country; } optional string Url; }}

Document

DocID Links? Name*

Backward* Forward* Language* Url?

Code Country?サンプルのスキーマ

Protocol Buffer

Page 8: Google Dremel

Code

DocID Links? Names*

Backward* Forward* Language* Url?

Country?

Document

Page 9: Google Dremel

Code

DocID

Document

Links? Names* 1

Backward* 1 Forward* 1 Language* 2 Url?

Country?

Repetition Level

Page 10: Google Dremel

Code

DocID

Document

Links? 1 Names* 1

Backward* 2 Forward* 2 Language* 2 Url? 2

Country? 3

Definition Level

2

Page 11: Google Dremel

Code

DocID

Document

Links? 1 Names* 1 1

Backward* 1

2Forward* 1

2Language* 2

2Url? 2

Country? 3

Repetetion Level

Definition Level

2

Page 12: Google Dremel

DocId: 10           Links Forward: 20 Forward: 40 Forward: 60Name Language Code: 'en-us‘ Country: 'us' Language Code: 'en' Url: 'http://A'Name Url: 'http://B'Name Language Code: 'en-gb' Country: 'gb'

DocId: 20Links Backward: 10 Backward: 30 Forward: 80Name Url: 'http://C‘

Page 13: Google Dremel

DocId: 10     0,0      Links Forward: 20 Forward: 40 Forward: 60Name Language Code: 'en-us‘ Country: 'us' Language Code: 'en' Url: 'http://A'Name Url: 'http://B'Name Language Code: 'en-gb' Country: 'gb'

DocId: 20Links Backward: 10 Backward: 30 Forward: 80Name Url: 'http://C‘

Page 14: Google Dremel

DocId: 10     0,0      Links Forward: 20 Forward: 40 Forward: 60Name Language Code: 'en-us‘ Country: 'us' Language Code: 'en' Url: 'http://A'Name Url: 'http://B'Name Language Code: 'en-gb' Country: 'gb'

DocId: 20Links Backward: 10 Backward: 30 Forward: 80Name Url: 'http://C‘

Page 15: Google Dremel

DocId: 10       0 ,0     Links Backward:NULL 0,1 Forward: 20 Forward: 40 Forward: 60Name Language Code: 'en-us‘ Country: 'us' Language Code: 'en' Url: 'http://A'Name Url: 'http://B'Name Language Code: 'en-gb' Country: 'gb'

DocId: 20Links Backward: 10 Backward: 30 Forward: 80Name Url: 'http://C‘

Page 16: Google Dremel

DocId: 10       0 ,0     Links Backward:NULL 0,1 Forward: 20 0,2 Forward: 40 Forward: 60Name Language Code: 'en-us‘ Country: 'us' Language Code: 'en' Url: 'http://A'Name Url: 'http://B'Name Language Code: 'en-gb' Country: 'gb'

DocId: 20Links Backward: 10 Backward: 30 Forward: 80Name Url: 'http://C‘

Page 17: Google Dremel

DocId: 10       0 ,0     Links Backward:NULL 0,1 Forward: 20 0,2 Forward: 40 1,2 Forward: 60Name Language Code: 'en-us‘ Country: 'us' Language Code: 'en' Url: 'http://A'Name Url: 'http://B'Name Language Code: 'en-gb' Country: 'gb'

DocId: 20Links Backward: 10 Backward: 30 Forward: 80Name Url: 'http://C‘

Page 18: Google Dremel

DocId: 10       0 ,0     Links Backward:NULL 0,1 Forward: 20 0,2 Forward: 40 1,2 Forward: 60 1,2Name Language Code: 'en-us‘ Country: 'us' Language Code: 'en' Url: 'http://A'Name Url: 'http://B'Name Language Code: 'en-gb' Country: 'gb'

DocId: 20Links Backward: 10 Backward: 30 Forward: 80Name Url: 'http://C‘

Page 19: Google Dremel

DocId: 10       0 ,0     Links Backward:NULL 0,1 Forward: 20 0,2 Forward: 40 1,2 Forward: 60 1,2Name Language Code: 'en-us‘ Country: 'us' Language Code: 'en' Url: 'http://A'Name Url: 'http://B'Name Language Code: 'en-gb' Country: 'gb'

DocId: 20Links Backward: 10 Backward: 30 Forward: 80Name Url: 'http://C‘

Page 20: Google Dremel

DocId: 10       0 ,0     Links Backward:NULL 0,1 Forward: 20 0,2 Forward: 40 1,2 Forward: 60 1,2Name Language Code: 'en-us‘ Country: 'us' Language Code: 'en' Url: 'http://A'Name Url: 'http://B'Name Language Code: 'en-gb' Country: 'gb'

DocId: 20Links Backward: 10 Backward: 30 Forward: 80Name Url: 'http://C‘

Page 21: Google Dremel

DocId: 10       0 ,0     Links Backward:NULL 0,1 Forward: 20 0,2 Forward: 40 1,2 Forward: 60 1,2Name Language Code: 'en-us‘ 0,2 Country: 'us' Language Code: 'en' Url: 'http://A'Name Url: 'http://B'Name Language Code: 'en-gb' Country: 'gb'

DocId: 20Links Backward: 10 Backward: 30 Forward: 80Name Url: 'http://C‘

Page 22: Google Dremel

DocId: 10       0 ,0     Links Backward:NULL 0,1 Forward: 20 0,2 Forward: 40 1,2 Forward: 60 1,2Name Language Code: 'en-us‘ 0,2 Country: 'us’ 0,3 Language Code: 'en' Url: 'http://A'Name Url: 'http://B'Name Language Code: 'en-gb' Country: 'gb'

DocId: 20Links Backward: 10 Backward: 30 Forward: 80Name Url: 'http://C‘

Page 23: Google Dremel

DocId: 10       0 ,0     Links Backward:NULL 0,1 Forward: 20 0,2 Forward: 40 1,2 Forward: 60 1,2Name Language Code: 'en-us‘ 0,2 Country: 'us’ 0,3 Language Code: 'en' Url: 'http://A'Name Url: 'http://B'Name Language Code: 'en-gb' Country: 'gb'

DocId: 20Links Backward: 10 Backward: 30 Forward: 80Name Url: 'http://C‘

Page 24: Google Dremel

DocId: 10       0 ,0     Links Backward:NULL 0,1 Forward: 20 0,2 Forward: 40 1,2 Forward: 60 1,2Name Language Code: 'en-us‘ 0,2 Country: 'us’ 0,3 Language Code: 'en’ 2,2 Url: 'http://A'Name Url: 'http://B'Name Language Code: 'en-gb' Country: 'gb'

DocId: 20Links Backward: 10 Backward: 30 Forward: 80Name Url: 'http://C‘

Page 25: Google Dremel

DocId: 10       0 ,0     Links Backward:NULL 0,1 Forward: 20 0,2 Forward: 40 1,2 Forward: 60 1,2Name Language Code: 'en-us‘ 0,2 Country: 'us’ 0,3 Language Code: 'en’ 2,2 Country:NULL 2,2 Url: 'http://A'Name Url: 'http://B'Name Language Code: 'en-gb' Country: 'gb'

DocId: 20Links Backward: 10 Backward: 30 Forward: 80Name Url: 'http://C‘

Page 26: Google Dremel

DocId: 10       0 ,0     Links Backward:NULL 0,1 Forward: 20 0,2 Forward: 40 1,2 Forward: 60 1,2Name Language Code: 'en-us‘ 0,2 Country: 'us’ 0,3 Language Code: 'en’ 2,2 Country:NULL 2,2 Url: 'http://A’ 0,2Name Url: 'http://B'Name Language Code: 'en-gb' Country: 'gb'

DocId: 20Links Backward: 10 Backward: 30 Forward: 80Name Url: 'http://C‘

Page 27: Google Dremel

DocId: 10       0 ,0     Links Backward:NULL 0,1 Forward: 20 0,2 Forward: 40 1,2 Forward: 60 1,2Name Language Code: 'en-us‘ 0,2 Country: 'us’ 0,3 Language Code: 'en’ 2,2 Country:NULL 2,2 Url: 'http://A’ 0,2Name Url: 'http://B'Name Language Code: 'en-gb' Country: 'gb'

DocId: 20Links Backward: 10 Backward: 30 Forward: 80Name Url: 'http://C‘

Page 28: Google Dremel

DocId: 10       0 ,0     Links Backward:NULL 0,1 Forward: 20 0,2 Forward: 40 1,2 Forward: 60 1,2Name Language Code: 'en-us‘ 0,2 Country: 'us’ 0,3 Language Code: 'en’ 2,2 Country:NULL 2,2 Url: 'http://A’ 0,2Name Language Url: 'http://B'

Name Language Code: 'en-gb' Country: 'gb’

DocId: 20Links Backward: 10 Backward: 30 Forward: 80Name Url: 'http://C‘

Page 29: Google Dremel

DocId: 10       0 ,0     Links Backward:NULL 0,1 Forward: 20 0,2 Forward: 40 1,2 Forward: 60 1,2Name Language Code: 'en-us‘ 0,2 Country: 'us’ 0,3 Language Code: 'en’ 2,2 Country:NULL 2,2 Url: 'http://A’ 0,2Name Language Code: NULL 1,1 Url: 'http://B'

Name Language Code: 'en-gb' Country: 'gb’

DocId: 20Links Backward: 10 Backward: 30 Forward: 80Name Url: 'http://C‘

Page 30: Google Dremel

DocId: 10       0 ,0     Links Backward:NULL 0,1 Forward: 20 0,2 Forward: 40 1,2 Forward: 60 1,2Name Language Code: 'en-us‘ 0,2 Country: 'us’ 0,3 Language Code: 'en’ 2,2 Country:NULL 2,2 Url: 'http://A’ 0,2Name Language Code: NULL 1,1 Country:NULL 1,1 Url: 'http://B'

Name Language Code: 'en-gb' Country: 'gb’

DocId: 20Links Backward: 10 Backward: 30 Forward: 80Name Url: 'http://C‘

Page 31: Google Dremel

DocId: 10       0 ,0     Links Backward:NULL 0,1 Forward: 20 0,2 Forward: 40 1,2 Forward: 60 1,2Name Language Code: 'en-us‘ 0,2 Country: 'us’ 0,3 Language Code: 'en’ 2,2 Country:NULL 2,2 Url: 'http://A’ 0,2Name Language Code: NULL 1,1 Country:NULL 1,1 Url: 'http://B’ 1,2

Name Language Code: 'en-gb' Country: 'gb’

DocId: 20Links Backward: 10 Backward: 30 Forward: 80Name Url: 'http://C‘

Page 32: Google Dremel

DocId: 10       0 ,0     Links Backward:NULL 0,1 Forward: 20 0,2 Forward: 40 1,2 Forward: 60 1,2Name Language Code: 'en-us‘ 0,2 Country: 'us’ 0,3 Language Code: 'en’ 2,2 Country:NULL 2,2 Url: 'http://A’ 0,2Name Language Code: NULL 1,1 Country:NULL 1,1 Url: 'http://B’ 1,2

Name Language Code: 'en-gb’ 1,2 Country: 'gb’

DocId: 20Links Backward: 10 Backward: 30 Forward: 80Name Url: 'http://C‘

Page 33: Google Dremel

DocId: 10       0 ,0     Links Backward:NULL 0,1 Forward: 20 0,2 Forward: 40 1,2 Forward: 60 1,2Name Language Code: 'en-us‘ 0,2 Country: 'us’ 0,3 Language Code: 'en’ 2,2 Country:NULL 2,2 Url: 'http://A’ 0,2Name Language Code: NULL 1,1 Country:NULL 1,1 Url: 'http://B’ 1,2

Name Language Code: 'en-gb’ Country: 'gb’

DocId: 20Links Backward: 10 Backward: 30 Forward: 80Name Url: 'http://C‘

Page 34: Google Dremel

DocId: 10       0 ,0     Links Backward:NULL 0,1 Forward: 20 0,2 Forward: 40 1,2 Forward: 60 1,2Name Language Code: 'en-us‘ 0,2 Country: 'us’ 0,3 Language Code: 'en’ 2,2 Country:NULL 2,2 Url: 'http://A’ 0,2Name Language Code: NULL 1,1 Country:NULL 1,1 Url: 'http://B’ 1,2

Name Language Code: 'en-gb’ 1,2 Country: 'gb’

DocId: 20Links Backward: 10 Backward: 30 Forward: 80Name Url: 'http://C‘

Page 35: Google Dremel

DocId: 10       0 ,0     Links Backward:NULL 0,1 Forward: 20 0,2 Forward: 40 1,2 Forward: 60 1,2Name Language Code: 'en-us‘ 0,2 Country: 'us’ 0,3 Language Code: 'en’ 2,2 Country:NULL 2,2 Url: 'http://A’ 0,2Name Language Code: NULL 1,1 Country:NULL 1,1 Url: 'http://B’ 1,2

Name Language Code: 'en-gb’ 1,2 Country: 'gb’ 1,3

DocId: 20Links Backward: 10 Backward: 30 Forward: 80Name Url: 'http://C‘

Page 36: Google Dremel

DocId: 10       0 ,0     Links Backward:NULL 0,1 Forward: 20 0,2 Forward: 40 1,2 Forward: 60 1,2Name Language Code: 'en-us‘ 0,2 Country: 'us’ 0,3 Language Code: 'en’ 2,2 Country:NULL 2,2 Url: 'http://A’ 0,2Name Language Code: NULL 1,1 Country:NULL 1,1 Url: 'http://B’ 1,2

Name Language Code: 'en-gb’ 1,2 Country: 'gb’ 1,3 URI:NULL 1,1

DocId: 20Links Backward: 10 Backward: 30 Forward: 80Name Url: 'http://C‘

Page 37: Google Dremel

DocId: 10       0 ,0     Links Backward:NULL 0,1 Forward: 20 0,2 Forward: 40 1,2 Forward: 60 1,2Name Language Code: 'en-us‘ 0,2 Country: 'us’ 0,3 Language Code: 'en’ 2,2 Country:NULL 2,2 Url: 'http://A’ 0,2Name Language Code: NULL 1,1 Country:NULL 1,1 Url: 'http://B’ 1,2

Name Language Code: 'en-gb’ 1,2 Country: 'gb’ 1,3 URI:NULL 1,1

DocId: 20 0,0Links Backward: 10 Backward: 30 Forward: 80Name Url: 'http://C‘

Page 38: Google Dremel

Name Language Code: 'en-gb’ 1,2 Country: 'gb’ 1,3 URI:NULL 1,1

DocId: 20 0,0Links Backward: 10 Backward: 30 Forward: 80Name Url: 'http://C‘

Page 39: Google Dremel

Name Language Code: 'en-gb’ 1,2 Country: 'gb’ 1,3 URI:NULL 1,1

DocId: 20 0,0Links Backward: 10 Backward: 30 Forward: 80Name Url: 'http://C‘

Page 40: Google Dremel

Name Language Code: 'en-gb’ 1,2 Country: 'gb’ 1,3 URI:NULL 1,1

DocId: 20 0,0Links Backward: 10 0,2 Backward: 30 Forward: 80Name Url: 'http://C‘

Page 41: Google Dremel

Name Language Code: 'en-gb’ 1,2 Country: 'gb’ 1,3 URI:NULL 1,1

DocId: 20 0,0Links Backward: 10 0,2 Backward: 30 1,2 Forward: 80Name Url: 'http://C‘

Page 42: Google Dremel

Name Language Code: 'en-gb’ 1,2 Country: 'gb’ 1,3 URI:NULL 1,1

DocId: 20 0,0Links Backward: 10 0,2 Backward: 30 1,2 Forward: 80 0,2Name Url: 'http://C‘

Page 43: Google Dremel

Name Language Code: 'en-gb’ 1,2 Country: 'gb’ 1,3 URI:NULL 1,1

DocId: 20 0,0Links Backward: 10 0,2 Backward: 30 1,2 Forward: 80 0,2Name Url: 'http://C‘

Page 44: Google Dremel

Name Language Code: 'en-gb’ 1,2 Country: 'gb’ 1,3 URI:NULL 1,1

DocId: 20 0,0Links Backward: 10 0,2 Backward: 30 1,2 Forward: 80 0,2Name Language Url: 'http://C‘

Page 45: Google Dremel

Name Language Code: 'en-gb’ 1,2 Country: 'gb’ 1,3 URI:NULL 1,1

DocId: 20 0,0Links Backward: 10 0,2 Backward: 30 1,2 Forward: 80 0,2Name Language Code: NULL 0,1 Url: 'http://C‘

Page 46: Google Dremel

Name Language Code: 'en-gb’ 1,2 Country: 'gb’ 1,3 URI:NULL 1,1

DocId: 20 0,0Links Backward: 10 0,2 Backward: 30 1,2 Forward: 80 0,2Name Language Code: NULL 0,1 Country: NULL 0,1 Url: 'http://C‘

Page 47: Google Dremel

Name Language Code: 'en-gb’ 1,2 Country: 'gb’ 1,3 URI:NULL 1,1

DocId: 20 0,0Links Backward: 10 0,2 Backward: 30 1,2 Forward: 80 0,2Name Language Code: NULL 0,1 Country: NULL 0,1 Url: 'http://C‘ 0,2

Page 48: Google Dremel

DocId: 10Links Forward: 20 Forward: 40 Forward: 60Name Language Code: 'en-us‘ Country: 'us' Language Code: 'en' Url: 'http://A'Name Url: 'http://B'Name Language Code: 'en-gb' Country: 'gb'

DocId: 20Links Backward: 10 Backward: 30 Forward: 80Name Url: 'http://C‘

Page 49: Google Dremel

DocId: 10Links Forward: 20 Forward: 40 Forward: 60Name Language Code: 'en-us‘ Country: 'us' Language Code: 'en' Url: 'http://A'Name Url: 'http://B'Name Language Code: 'en-gb' Country: 'gb'

DocId: 20Links Backward: 10 Backward: 30 Forward: 80Name Url: 'http://C‘

Page 50: Google Dremel

DocId: 10Links Forward: 20 Forward: 40 Forward: 60Name Language Code: 'en-us‘ Country: 'us' Language Code: 'en' Url: 'http://A'Name Url: 'http://B'Name Language Code: 'en-gb' Country: 'gb'

DocId: 20Links Backward: 10 Backward: 30 Forward: 80Name Url: 'http://C‘

Page 51: Google Dremel

Code

DocID

Document

Links? Names*

Backward* Forward* Language* Url?

Country?

Level 0

Page 52: Google Dremel

Code

DocID

Document

Links? Names* 1

Backward* 1 Forward* 1 Language* Url?

Country?

Level 1

Page 53: Google Dremel

Code

DocID

Document

Links? Names* 1

Backward* 1 Forward* 1 Language* Url?

Country?

Level 1

Page 54: Google Dremel

Code

DocID

Document

Links? Names* 1

Backward* 1 Forward* 1 Language* Url?

Country?

Level 0 Level 1

Page 55: Google Dremel

Code

DocID

Document

Links? Names*

Backward* Forward* Language* 2 Url?

Country?

Level 2

Page 56: Google Dremel

Code

DocID

Document

Links? Names*

Backward* Forward* Language* 2 Url?

Country?

Level 2

Page 57: Google Dremel

Code

DocID

Document

Links? Names* 1

Backward* 1 Forward* 1 Language* 2 Url?

Country?

Level 0 Level 1 Level 2

Page 58: Google Dremel
Page 59: Google Dremel

Code

DocID

Document

Links? Names*

Backward* Forward* Language* Url?

Country?

Page 60: Google Dremel

Code

DocID

Document

Links? Names*

Backward* Forward* Language* Url?

Country?

Page 61: Google Dremel

Code

DocID

Document

Links? Names*

Backward* Forward* Language* Url?

Country?

Level 0

Page 62: Google Dremel

Code

DocID

Document

Links? Names*

Backward* Forward* Language* Url?

Country?

Level 0Level 1Level 2

Page 63: Google Dremel

Code

DocID

Document

Links? Names*

Backward* Forward* Language* Url?

Country?

Level 0Level 1Level 2

Page 64: Google Dremel
Page 65: Google Dremel

Finite State Machine CONSTRUCTION ALGORITHM

Page 66: Google Dremel

Finite State Machine CONSTRUCTION ALGORITHM このアルゴリズムは、入力として、スキーマ中に現

れる順番でレコード中に展開されているフィールドをとる。

このアルゴリズムは、「共通繰り返しレベル」というコンセプトを用いている。それは、共通のもっとも近い先祖の繰り返しレベルのことである。例えば、Links.Backward と Links.Forward の「共通繰り返しレベル」は、1になる。

第二のコンセプトは、「バリア」である。それは、現在のフィールドの、順番では次のフィールドのことである。

直感的には、バリアにあたって、以前にみたフィールドにジャンプが必要となるまで、それぞれのフィールドを一つづつ処理するということである。

Page 67: Google Dremel

1. procedure ConstructFSM(Field[] fields):2. フィールズ上のそれぞれのフィールドに対

して3.   maxLevel を、フィールドの最大繰り返

し レベルに設定する。

4.   barrier を、フィールドの次のフィールドか、 そうでなければ、 FSM の最終状態に設定す る。

5.   barrierLevel を、フィールドと barrierの 共通繰り返しレベルとする。

Page 68: Google Dremel

ステップ1 (Lines 6-10) では、「共通繰り返しレベル」を後ろ向きに走査する。これらは、増大しないことが保証されている。我々が出会う、それぞれの繰り返しレベルで、列のもっとも左のフィールドを選ぶ。 FieldReader で繰り返しレベルが返された時、我々が遷移すべきなのは、このフィールドである。

Page 69: Google Dremel

6. フィールドの前の全ての preField について、次の処理を繰り返す。ここで、

7. preField の繰り返しレベルは、 barrierLevelより大きいものを選ぶ。

8.   backLevel を、 preField とフィールドの 共通繰り返しレベルとする

9.  次のように遷移を設定する。 (field, backLevel) -> preField

10.繰り返し終わり。

Page 70: Google Dremel

ステップ 2 では、ギャップを埋める (Lines 11-14) 。このギャップは、全ての繰り返しレベルが、Line8 で計算された共通繰り返しレベルに現れていないことから生まれる。

Page 71: Google Dremel

11. [barrierLevel+1..maxLevel] の全てのレベルの

12.フィールドからの遷移を欠いているものについて、次の処理を繰り返す。

13.   level-1 の遷移の終端をコピーする14.繰り返し、終わり。

Page 72: Google Dremel

ステップ 3(Lines 15-17) では、 barrierLevel 以下の全てのレベルについて、 barrier フィールドへのジャンプをセットする。もしも、 FieldReader が、このようなレベルを生み出すなら、ネストされたレコードの構成を続ける必要がある。 barrier に、戻る必要はない。

Page 73: Google Dremel

15.[0..barrierLevel] の全てのレベルについて

16.  遷移を次のようにセットする   (field, level) -> barrier

17.繰り返し終わり

Page 74: Google Dremel

COLUMN   STRIPINGALGORITHM

Page 75: Google Dremel

プロシージャ DissectRecord は、 RecordDecoderのインスタンスに渡される。 RecordDecoder は、バイナリーにエンコードされたレコードの解析に利用される。

FieldWriters は、入力スキーマの階層構造と同形の木階層構造を構成している。

ルートの FieldWriter は、それぞれの新しいレコード毎に、繰り返しレベルを0にセットして、 このアルゴリズムに渡される。

DissectRecord プロシージャの最初の仕事は、現在の繰り返しレベルを維持することである。

Page 76: Google Dremel

現在の定義レベルは、現在の writer のツリー上の位置によって、フィールド・パスのオプショナルとリピート・フィールドの数の和として、一意に決定される。

このアルゴリズムの While ループ (Line 5) は、与えられたレコードに含まれる、全てのアトミックとレコード値を持つフィールド上を繰り返し処理する。

Page 77: Google Dremel

seenFields の集合は、レコード中で、そのフィールドが処理されたか否かを追跡する。それは、どのフィールドが、もっとも最近繰り返されたかを決定するのに利用される。

子供の繰り返しレベル chRepetitionLevel は、もっとも最近繰り返されたレベルか、あるいは、その親のレベルのデフォールト値がセットされる (Lines 9-13) 。

このプロシージャは、ネストしたレコードに対して、リカーシブに呼び出される (Line 18) 。

Page 78: Google Dremel

Section 4.2 で、 FieldWriters がどのようにレベルを蓄積して、低レベルの writer に、必要に応じてそれらを伝播していくのかを見てきた。これらは、次のように行われる。

それぞれの non-leaf writer は、 ( 繰り返しレベル、定義レベル ) の列を保持している。それぞれのwriter は、それに関連した「バージョン」数を持っている。単純にいえば、 writer のバージョンはレベルが加えられる時には必ず一つづつ増加される。 子供にとっては、最後に同期した親のバージョンを知っていれば十分である。

もし子供の writer が( non-null)の値を獲得していれば、それは新しいレベルを取得して親と状態を同期する。そして、その時だけ新しいデータを追加する。

Page 79: Google Dremel

入力データは、数千のフィールド、数百万のレコードを持つことがあり得るので、全てのレベルをメモリーに置くというのはありそうもない。いくつかのレベルは、ディスク上のファイルに置かれるだろう。

空の(サブ)レコードの損失のないエンコードの為に、 (図 2 の Name.Language のような )non-atomic フィールドは、自分自身のカラム・ストライプを持つ必要があるかもしれない。それは、レベルを持つだけで、 non-NULL な値を持つことはない。

Page 80: Google Dremel

1. procedure DissectRecord(  RecordDecoder decoder,  FieldWriter writer, int 繰り返しレベル ):

2. 現在の繰り返しレベルと定義レベルを writerに追加する。

3. seenFields = {} // 整数の空集合4. decoder がフィールドの値を持つ間、繰り返

す5.   FieldWriter chWriter =

   decoder によって読まれるフィールドの  子writer

Page 81: Google Dremel

6.   int 子の繰り返しレベル = 繰り返しレベル

7.   if seenFields が子writer の ID を含んで   いれば、  子の繰り返しレベル = 子writer の深さ

8.   else9.   子writer の ID を seenFields に追加す

る10.  end if

Page 82: Google Dremel

11.  if 子Writer が atomic field に対応すれば12.  子の繰り返しレベルの子writer を使っ

て、  現在のフィールドの値を書き出す

13.  else14.   DissectRecord( ネストしたレコードの

為の   新しい RecordDecoder,   子writer, 子の繰り返しレベル)

15.  end if16.end while17.end procedure

Page 83: Google Dremel

RECORD ASSEMBLY ALGORITHM

Page 84: Google Dremel

In their on-the-wire representation, records are laid out as pairs of a field identifier followed by a field value. Nested records can be thought of as having an ‘opening tag’ and a ‘closing tag’, similar to XML (actual binary encoding may differ, see [21] for details).

In the following, writing opening tags is referred to as ‘starting’ the record, and writing closing tags is called ’ending’ it.

Page 85: Google Dremel

AssembleRecord procedure takes as input a set of FieldReaders and (implicitly) the FSM with state transitions between the readers.

Variable reader holds the current FieldReader in the main routine (Line 4). Variable lastReader holds the last reader whose value we appended to the record and is available to all three procedures shown in Figure 17. The main while-loop is at Line 5.

Page 86: Google Dremel

We fetch the next value from the current reader. If the value is not NULL, which is determined by looking at its definition level, we synchronize the record being assembled to the record structure of the current reader in the method MoveToLevel, and append the field value to the record.

Otherwise, we merely adjust the record structure without appending any value—which needs to be done if empty records are present.

Page 87: Google Dremel

On Line 12, we use a ‘full definition level’. Recall that the definition level factors out required fields (only repeated and optional fields are counted). Full definition level takes all fields into account.

Page 88: Google Dremel

Procedure MoveToLevel transitions the record from the state of the lastReader to that of the nextReader (see Line 22).

For example, suppose the lastReader corresponds to Links.Backward in Figure 2 and nextReader is Name.Language.Code. The method ends the nested record Links and starts new records Name and Language, in that order. Procedure ReturnsToLevel (Line 30) is a counterpart of MoveToLevel that only ends current records without starting any new ones.

Page 89: Google Dremel

SELECT PROJECT AGGREGATEEVALUATION ALGORITHM

Page 90: Google Dremel

The algorithm addresses a general case when a query may reference repeated fields; a simpler optimized version is used for flat-relational queries, i.e., those referencing only required and optional fields. The algorithm has two implicit inputs: a set of FieldReaders, one for each field appearing in the query, and a set of scalar expressions, including aggregate expressions, present in the query. The repetition level of a scalar expression (used in Line 8) is determined as the maximum repetition level of the fields used in that expression.

Page 91: Google Dremel

In essence, the algorithm advances the readers in lockstep to the next set of values, and, if the selection conditions are met, emits the projected values. Selection and projection are controlled by two variables, fetchLevel and selectLevel. During execution, only readers whose next repetition level is no less than fetchLevel are advanced (see Fetch method at Line 19). In a similar vein, only expressions whose current repetition level is no less than selectLevel are emitted (Lines 7-10).

Page 92: Google Dremel

The algorithm ensures that expressions at a higher-level of nesting, i.e., those having a smaller repetition   level, get evaluated and emitted only once for each deeper nested  expression.

Page 93: Google Dremel

Google Dremel

Page 94: Google Dremel

Document

DocID Links? Name*

Backward* Forward* Language* Url?

Code Country?

10 0 020 0 0

http://A 0 2http://B 1 2NULL 1 1http://C 0 2

20 0 240 1 260 1 280 0 2

NULL 0 110 0 230 1 2

en-us 0 2en 2 2NULL 1 1en-gb 1 2NULL 0 1

us 0 3NULL 2 2NULL 1 1gb 1 3NULL 0 1

サンプルの格納状態

Page 95: Google Dremel

Dremel の検索言語

SELECT DocId AS Id, COUNT(Name.Language.Code) WITHIN Name AS Cnt, Name.Url + ',' + Name.Language.Code AS StrFROM tWHERE REGEXP(Name.Url, '^http') AND DocId < 20;

Id: 10Name Cnt: 2 Language Str: 'http://A,en-us' Str: 'http://A,en'Name Cnt: 0

message QueryResult { required int64 Id; repeated group Name { optional uint64 Cnt; repeated group Language { optional string Str; }}}

出力結果 出力のスキーマ

Page 96: Google Dremel

検索の木構造

SELECT A, COUNT(B) FROM T GROUP BY A

SELECT A, SUM(c) FROM (R11 UNION ALL ...R1n) GROUP BY A

R1i = SELECT A, COUNT(B) AS c FROM T1i GROUP BY A

T1i は、レベル 1 のサーバー i で処理される、テーブルT のTablet の分割

Page 97: Google Dremel
Page 98: Google Dremel

実験で使われたデータセット

Page 99: Google Dremel

カラム型とレコード型のパフォーマンスの比較

フィールドの数

Page 100: Google Dremel

MapReduce と Dremel

3000 nodes, 85 billion records

numRecs: table sum of int;numWords: table sum of int;emit numRecs <- 1;emit numWords <- CountWords(input.txtField);

Q1: SELECT SUM(CountWords(txtField))      / COUNT(*) FROM T1

Page 101: Google Dremel

木構造の深さとパフォーマンス

テーブル T2 24billion レコード 13TB 530 フィールドでの検索

Q2: SELECT country, SUM(item.amount) FROM T2GROUP BY country Q3: SELECT domain, SUM(item.amount) FROM T2

WHERE domain CONTAINS ’.net’GROUP BY domain

Page 102: Google Dremel

システムのノード数とスケーリング

リーフサーバーの数Q5: SELECT TOP(aid, 20), COUNT(*) FROM T4WHERE bid = {value1} AND cid = {value2}

T4 の一兆個のレコード

Page 103: Google Dremel

毎月の処理の処理時間の分布

Page 104: Google Dremel

結論 スキャンベースの検索は、一兆個以上のディスク上

のデータセットに対して、インタラクティブなスピードで実行出来る。

数千ノードを含むシステムで、カラムとサーバーの数に関して、ほとんどリニアーなスケーラビリティーを達成出来る。

DBMS とまったく同様に、 MapReduce は、カラム型のストレージの恩恵を受ける。

レコードの収集とパージングは、コストがかかる。ソフトウェアの層は(検索実行の層を超えて)、直接カラム指向のデータを利用出来るようになる必要がある。

Page 105: Google Dremel

結論 MapReduce と検索処理は、一方の層の出力が、他方の層の入力を与えるというように、相互補完的なやり方で、利用出来る。

マルチ・ユーザーの環境では、大規模システムは、より良いユーザー・エキスペアレンスの質を提供しながら、規模の経済のメリットを享受出来る。

もしも、正確さよりも、スピードの方が受け入れやすいなら、検索は、もっと早くすませることが出来るし、それにもかかわらず、もっと多くのデータを見ることが出来る。

Web スケールの大量のデータセットは、高速にスキャン出来る。厳しい時間の制限の中で、最後の数パーセントのデータを得るのは難しい。

Page 106: Google Dremel

COLUMN STRIPINGAlgorithm

The algorithm for decomposing a record into columns

Page 107: Google Dremel

DissectRecord1. procedure DissectRecord(

RecordDecoder decoder, FieldWriter writer, int repetitionLevel):

RecordDecoder, which is used to traverse binary-encoded records.

FieldWriters form a tree hierarchy isomorphic to that of the input schema.

Page 108: Google Dremel

Primary Job The root FieldWriter is passed to the algorithm

for each new record, with repetitionLevel set to 0.

The primary job of the DissectRecord procedure is to maintain the current repetitionLevel.

The current definitionLevel is uniquely determined by the tree position of the current writer, as the sum of the number of optional and repeated fields in the field’s path.