Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
RubyとApache Arrow
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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
Transcript
33 slides
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
More Decks by hatappi
See All by hatappi
メルカリのグローバルアプリで挑んだ AlloyDB 運用と課題解決の実践記
hatappi
0
360
AlloyDB 奮闘記
hatappi
0
550
Cloudflare を活用して変わったメルカリの開発体験 / How Cloudflare Changed Mercari's Development Experience
hatappi
1
970
RubyではじめるGraphQL
hatappi
0
1k
RubyでChainerつくってます!!
hatappi
2
1.6k
TDDな個人開発
hatappi
0
400
できるだけ楽して楽しくRails開発しよう
hatappi
2
400
EKSにRailsをのせた
hatappi
1
1.3k
Red Chainerを なぜ作って今後どうするのか
hatappi
2
2.6k
Other Decks in Technology
See All in Technology
E2E Test というハーネス — AI時代の自動テスト民主化
daishukojima
1
670
Biohub - Cell Tracking During Development 5th place solution
rist
0
150
SREのためのFinOps入門
muziyoshiz
3
1.5k
田んぼの見回りをIoTで減らしたい!水位監視から電池駆動カメラまでの試行錯誤
itosoft
1
190
田んぼから始まる挑戦 〜新米農家の1年目〜
miu_crescent
PRO
0
360
速くなるほど、深く考える AI時代のQAに学ぶ
kobayashiyorimitsu
0
210
bpf_arenaとstruct_opsを使うのが難しかった話
masu_mi
0
240
属人化したISMS運用をGitHubとAIで仕組み化した1年間の記録
sioncojp
4
2.6k
JAWSコミュニティに 参加して1年経った結果
ssakita
0
150
高品質と高スピードを支える品質のシフトレフトのアプローチ
goyoki
4
1.1k
Go初心者のクラウドエンジニアが、デプロイを通して旨味を知っていく話
ryudai
1
210
業務でAWSをあまり使っていない私が、AWSへのモチベを保つ方法
smt7174
0
200
Featured
See All Featured
Believing is Seeing
oripsolob
1
280
How Software Deployment tools have changed in the past 20 years
geshan
3
35k
Accessibility Awareness
sabderemane
1
300
How to Ace a Technical Interview
jacobian
280
24k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Docker and Python
trallard
47
4.3k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
400
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
The Language of Interfaces
destraynor
162
27k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
350
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
480
Test your architecture with Archunit
thirion
2
2.5k