Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
RubyとApache Arrow
Search
hatappi
December 08, 2018
Technology
0
2.1k
RubyとApache Arrow
Apache Arrow東京ミートアップ2018
https://speee.connpass.com/event/103514/
#ArrowTokyo
hatappi
December 08, 2018
Tweet
Share
More Decks by hatappi
See All by hatappi
RubyではじめるGraphQL
hatappi
0
740
RubyでChainerつくってます!!
hatappi
2
1.3k
TDDな個人開発
hatappi
0
250
できるだけ楽して楽しくRails開発しよう
hatappi
2
290
EKSにRailsをのせた
hatappi
1
1.1k
Red Chainerを なぜ作って今後どうするのか
hatappi
2
2.1k
Fargateで夢は見られるのか
hatappi
1
2k
個人サービスをFargateに移行したよ
hatappi
1
610
Rails + TypeScript + React + Hypernovaで始めるSSRライフ
hatappi
1
1.9k
Other Decks in Technology
See All in Technology
開発生産性を始める前に開発チームができること / optim-improve-development-productivity.pdf
optim
0
110
とあるOSSを継続可能にするための取り組みについて / OSS Refactoring Process
bun913
1
210
リアルお遍路+SORACOM IoT
ozk009
1
140
開発者の定量・定性データを組み合わせて開発者体験を把握するための取り組み
ham0215
1
130
「自動テストのプラクティスを効果的に学ぶためのカードゲーム」 ( #sqip2024 )
teyamagu
PRO
2
180
QAに対する超個人的な解釈 / Personal Take on QA
toma_sm
1
100
可視化により内部品質をあげるAIドキュメントリバース/20240910 Hiromitsu Akiba
shift_evolve
0
220
なにもしてないのにNew Relicのデータ転送量が増えていたときに確認したこと
tk3fftk
2
230
Road to Single Activity
yurihondo
1
240
社内の学びの場・コミュニティ形成とエンジニア同士のリレーションシップ構築/devreljapan2024
nishiuma
3
290
App Router を実プロダクトで採用して見えてきた勘所をちょっとだけ紹介
marokanatani
1
930
Agile in Automotive Industry, puzzles and lights.
hiranabe
3
1.4k
Featured
See All Featured
Fashionably flexible responsive web design (full day workshop)
malarkey
401
65k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
45
4.8k
Ruby is Unlike a Banana
tanoku
96
11k
Typedesign – Prime Four
hannesfritz
39
2.3k
A designer walks into a library…
pauljervisheath
201
24k
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.4k
Unsuck your backbone
ammeep
667
57k
Raft: Consensus for Rubyists
vanstee
135
6.5k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
38
9.2k
Imperfection Machines: The Place of Print at Facebook
scottboms
263
13k
Gamification - CAS2011
davidbonilla
79
5k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.3k
Transcript
RubyとApache Arrow Yusaku Hatanaka (@hatappi) Apache Arrow 東京ミートアップ2018
⾃⼰紹介 • Yusaku Hatanaka (@hatappi) • Red Data Tools のメンバー
• Ruby, Go, TypeScript C, C++ • 煎り⼤⾖が好き
この話のゴール • RubyでApache Arrowを使った取り組みの話や今後どうな ると嬉しいかの話を聞いて「へぇ〜」となる • RubyでApache Arrowを使う開発やApache Arrow本体の 開発に参加したくなる
Apache Arrow • 各種⾔語で使⽤できるインメモリのデータ処理プラット フォーム • ⾼速なデータフォーマット、交換処理ロジックによって効 率的なデータ交換処理ロジックなどを提供する
Red Data Tools • Ruby⽤のデータ処理ツールを提供するプロジェクト • 基本はGitter上でやりとりをしている • https://gitter.im/red-data-tools/ja •
毎⽉1回ミートアップしてる • 次回は12⽉11⽇ 来週⽕曜⽇ https://speee.connpass.com/event/105238/
現状どんなことが できるのか?
Red Arrow red-data-tools/red-arrow
Red Arrow • Apache ArrowのRuby binding • もともとはred-data-toolsのリポジトリで管理されていた が今はApache Arrow本体にある
• GObject Introspectionを使⽤してbindingを実現している • Arrow側の関数情報が更新されていけばRed Arrowもそ の最新の機能を使うことができる
データの変換コスト
“推測するな。計測せよ”
ཁૉ ࣮ߦ࣌ؒ T
JSONの読み書き
ཁૉ ࣮ߦ࣌ؒ T
Apache Arrowの読み書き
࣮ߦ࣌ؒ (s) 0 1.5 3 4.5 6 ཁૉ 10000 100000
1000000 10000000 JSON Apache Arrow
RubyでCSVをパース
CSV ߦ ࣮ߦ࣌ؒ T
Ccsv ߦ ࣮ߦ࣌ؒ T
Apache ArrowͷCSV Parser • Arrow 0.11.0で⼊った新機能 • データの永続化としてよく使われるCSVを⾼速に読み込ん でApache Arrowのデータとして処理できるようになる
Apache Arrow ߦ ࣮ߦ࣌ؒ T
࣮ߦ࣌ؒ T ߦ
DTW $DTW "QBDIF"SSPX
Arrow Arrowすごい Ccsvもすごい
データの相互交換
ߦ ࣮ߦ࣌ؒ T
CSV -> Arrow -> Parquet
今後どうなると嬉しいか
RubyでもGPU上で データフレームを使いたい
cuDF • GPU上でデータフレームを操作するためのライブラリ • RAPIDSというE2Eのデータ分析をGPUで実現するための プロジェクト • Rubyでbindingつくれるとよさそう
MySQLの実⾏結果を Apache Arrowのフォーマット で返せると良さそう!
CSVJSON ࠓ ͜͏ͳΔͱخ͍͠ ૣ͍
mysql2-arrow • mysql2はlibmysqlのRuby binding • ActiveRecordでMySQLを選択した時のアダプターとし ても使⽤される • mysql2を早くできればActiveRecordも早くなって嬉し いかもしれない
• mysql2で実⾏した際のMYSQL_RESを取り出すことができ ればArrow形式に変換できそう
select * from users; MYSQL_RES Mysql2::Result MYSQL_RESからいくつかのレコードを arrow::RecordBatchにまとめて返す Arrow::RecordBatch として受け取る!
3VCZͷੈք $ $ ͷੈք イメージ
実⾏イメージ
DEMO
• ActiveRecord: 6.849s • pluck: 2.450s • Apache Arrow: 0.520s
ActiveRecordで使うと
ここまでのまとめ • Apache Arrowの開発が進めばRubyだけでなく他の⾔語も 嬉しい! • Ruyb bindingつくるもよし! Apache Arrow本体の開発するもよし!
• やりたいことはたくさんある! • red-data-tools/want-to-do