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
2.7k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
RubyとApache Arrow
Apache Arrow東京ミートアップ2018
https://speee.connpass.com/event/103514/
#ArrowTokyo
hatappi
December 08, 2018
More Decks by hatappi
See All by hatappi
メルカリのグローバルアプリで挑んだ AlloyDB 運用と課題解決の実践記
hatappi
0
260
AlloyDB 奮闘記
hatappi
0
470
Cloudflare を活用して変わったメルカリの開発体験 / How Cloudflare Changed Mercari's Development Experience
hatappi
1
900
RubyではじめるGraphQL
hatappi
0
970
RubyでChainerつくってます!!
hatappi
2
1.5k
TDDな個人開発
hatappi
0
380
できるだけ楽して楽しくRails開発しよう
hatappi
2
380
EKSにRailsをのせた
hatappi
1
1.3k
Red Chainerを なぜ作って今後どうするのか
hatappi
2
2.5k
Other Decks in Technology
See All in Technology
生成 AI の基礎 〜 サンプル実装で学ぶ基本原理
enakai00
7
4.5k
平文パスワードはログに“残り” ── 肝心の侵入は“痕跡すら残らない”
kuroneko13
0
110
Go 1.27 の標準パッケージに uuid が入った!のでいろいろ喋る / go_127_std_go_uuid
convto
3
560
RapidCopy2 Matrix I/Oエンジンによるファイルコピーソフトウェアの設計と実装
kengosawa2
1
140
Eight Engineering Unit 紹介資料
sansan33
PRO
3
8.2k
トークンマネジメントでAIにとって働きやすい環境を実現する
hikaruegashira
0
130
Flutter × BLE Centralを自前Pluginで実装する設計パターン - MethodChannel / EventChannelで作る双方向ブリッジの実践 / Building Custom Flutter BLE Central Plugins: Bidirectional Bridging with Method & Event Channels
bitkey
PRO
0
200
【書籍出版記念】 10周回って、エージェント開発は RAGがすべてだった。〜RAGの歴史と開発現場で見えた実践知〜
akiratameto
3
500
Sansan Engineering Unit 紹介資料
sansan33
PRO
1
5k
AI for Science時代を切り開く、政府の次世代HPC戦略の展望
gpuunite_official
0
130
MIXIで活躍できるエンジニアを 若手社員目線で考えてみる
mixi_engineers
PRO
0
110
AIに狂うスタートアップが、あえて「人との協働」に全振りした新卒エンジニア研修 / New Graduate Engineer Training at a Startup Accelerating AI Adoption
ohnoeight
0
170
Featured
See All Featured
The Cult of Friendly URLs
andyhume
79
7k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
GraphQLとの向き合い方2022年版
quramy
50
15k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
250
How Software Deployment tools have changed in the past 20 years
geshan
1
34k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.9k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
260
Ethics towards AI in product and experience design
skipperchong
2
350
Mobile First: as difficult as doing things right
swwweet
225
10k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.6k
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
420
The Mindset for Success: Future Career Progression
greggifford
PRO
0
460
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