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
try_to_making_a_gem_with_pattern_matching.pdf
Search
morihirok
October 16, 2019
Technology
0
180
try_to_making_a_gem_with_pattern_matching.pdf
Ebisu.rb #25
morihirok
October 16, 2019
Tweet
Share
More Decks by morihirok
See All by morihirok
混沌とした例外処理とエラー監視に秩序をもたらす
morihirok
13
2.2k
継続的にRailsアプリを開発する上で早めにやっておきたいこと
morihirok
9
2.8k
1日5分!子育て中もインプットを続ける工夫
morihirok
4
1.1k
rarray_value.pdf
morihirok
0
1.6k
失敗しても大丈夫!ひとりWebサービスのすゝめ
morihirok
2
470
introduce_pattern_matching_with_mongo-clarify
morihirok
0
93
サーバレスアーキテクチャ入門
morihirok
0
220
エンジニアの勉強法
morihirok
0
380
Other Decks in Technology
See All in Technology
Formal Development of Operating Systems in Rust
riru
1
420
AWSの生成AIサービス Amazon Bedrock入門!(2025年1月版)
minorun365
PRO
7
470
深層学習と3Dキャプチャ・3Dモデル生成(土木学会応用力学委員会 応用数理・AIセミナー)
pfn
PRO
0
460
Goで実践するBFP
hiroyaterui
1
120
EMConf JP の楽しみ方 / How to enjoy EMConf JP
pauli
2
150
コロプラのオンボーディングを採用から語りたい
colopl
5
1.2k
Docker Desktop で Docker を始めよう
zembutsu
PRO
0
160
The future we create with our own MVV
matsukurou
0
2k
.NET AspireでAzure Functionsやクラウドリソースを統合する
tsubakimoto_s
0
190
Amazon Q Developerで.NET Frameworkプロジェクトをモダナイズしてみた
kenichirokimura
1
200
2024年活動報告会(人材育成推進WG・ビジネスサブWG) / 20250114-OIDF-J-EduWG-BizSWG
oidfj
0
220
実践! ソフトウェアエンジニアリングの価値の計測 ── Effort、Output、Outcome、Impact
nomuson
0
2.1k
Featured
See All Featured
VelocityConf: Rendering Performance Case Studies
addyosmani
327
24k
A Modern Web Designer's Workflow
chriscoyier
693
190k
Music & Morning Musume
bryan
46
6.3k
Testing 201, or: Great Expectations
jmmastey
41
7.2k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.9k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
132
33k
YesSQL, Process and Tooling at Scale
rocio
170
14k
Side Projects
sachag
452
42k
Typedesign – Prime Four
hannesfritz
40
2.5k
BBQ
matthewcrist
85
9.4k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
Building Your Own Lightsaber
phodgson
104
6.2k
Transcript
Ruby2.7Ͱಋೖ͞ΕΔ Pattern matchingͰ GemΛ࡞ͬͯΈͨ Ebisu.rb #25 @_morihirok
About me • Github: morihirok • Twitter: @_morihirok • STORES.jp
inc,
Ruby 2.7ΑΓ Pattern matching ͱ͍͏ػೳ͕ೖΓ·͢
3VCZ,BJHJ1BUUFSONBUDIJOH/FXGFBUVSFJO3VCZΑΓҾ༻ IUUQTTQFBLFSEFDLDPNL@UTKQBUUFSONBUDIJOHOFXGFBUVSFJOSVCZEPU
3VCZ,BJHJ1BUUFSONBUDIJOH/FXGFBUVSFJO3VCZΑΓҾ༻ IUUQTTQFBLFSEFDLDPNL@UTKQBUUFSONBUDIJOHOFXGFBUVSFJOSVCZEPU
ͬͯΈ͍ͨͷͰ Կ͔࡞Ζ͏
STORES.jpϝΠϯDB͕ MongoDB • ओཁͳσʔλશͯMongoDBʹೖ͍ͬͯΔ • ओཁͳΫΤϦશͯMongoDBʹ͔͍ͬͯΔ • વ࣮ߦܭըMongoDBͷͷΛ֬ೝ͢Δ • MongoDBͷexplainಡΈͮΒ͍
MongoDBͷexplain݁Ռͷ αϯϓϧ > db.items.find({price: 119}).explain("executionStats") { "queryPlanner" : { "plannerVersion"
: 1, "namespace" : "sample_db.items", "indexFilterSet" : false, "parsedQuery" : { "price" : { "$eq" : 119 } }, "winningPlan" : { "stage" : "COLLSCAN", "filter" : { "price" : { "$eq" : 119 } શͯ+40/Ͱදݱ͞ΕΔ
Pattern matchingΛ͑ JSONͷѻ͍͕ ָʹͳΔͷͰʁ
ͱ͍͏͜ͱͰ࡞ͬͨͷ͕͜Ε FYQMBJOͷ+40/Λ ͍͍۩߹ʹ.BSLEPXOͷ ςʔϒϧʹม͢Δ
ΠϯσοΫε͕ޮ͍ͯͳ͍ͱ͖ͷ explain݁Ռ ͕͜͜z$0--4$"/zʹͳΔ
͜͏ॻ͚Δ ͕͜͜z$0--4$"/zʹͳΔ
ΠϯσοΫε͕ޮ͍͍ͯΔͱ͖ͷ explain݁Ռ ͕͜͜z'&5$)zʹมΘΔ ͕͜͜z*94$"/zʹͳΔ ͜͜ʹΠϯσοΫε໊͕ೖΔ
͜͏ॻ͚Δ ͕͜͜z'&5$)zʹมΘΔ ͕͜͜z*94$"/zʹͳΔ ͜͜ʹΠϯσοΫε໊͕ೖΔ
͜͏ॻ͚Δ มΛόΠϯυͰ͖Δ ͜͜ʹΠϯσοΫε໊͕ೖΔ
࠷ऴతʹ͜͏ͳΔ
STORES.jpͰ ͍͍ײ͡ʹ͑ͦ͏
͓લຊ൪ͷRubyΛ 2.7ʹ্͛ΔͭΓͳͷ͔ʁ
Pattern matchingແ͠Ͱ ॻ͖͑Δͱ
Pattern matchingແ͠Ͱ ॻ͖͑Δͱ όʔδϣϯ͝ͱͷ ίʔυͷဃ͕ܹ͘͠ͳΔ
͜Μͳํ๏͋Γ·͢
pattern-matchΛར༻͢Δͱ 1SPDDBMM ͷγϯλοΫεγϡΨʔ͕ Ͱ͋Δ͜ͱΛར༻͍ͯ͠Δ
pattern-matchΛར༻͢Δͱ ͋ΔఔࣅͨίʔυΛ อͭ͜ͱ͕Ͱ͖Δ
Ruby2.7Ҏ্Ͱ Pattern matchingΛ͍͍ͨ Ruby2.6ҎԼͰ gem͍͍ͨ
RubyͷόʔδϣϯʹΑͬͯ require͢ΔϑΝΠϧΛม͑Δ • mongo_clarify.rb 3VCZͷόʔδϣϯʹΑͬͯ ϑΝΠϧΛม͍͑ͨϞδϡʔϧ
RubyͷόʔδϣϯʹΑͬͯ require͢ΔϑΝΠϧΛม͑Δ • investigate.rb 3VCZҎ্ͳΒ 1BUUFSO.BUDIJOH൛Λ͏
• ىಈதͷRubyͷόʔδϣϯจࣈྻΛอ࣋͢Δ ఆ Gem::Version • όʔδϣϯจࣈྻΛൺֱՄೳʹ͢ΔΫϥε RUBY_VERSION
ςετRubyͷόʔδϣϯʹΑͬͯ require͢ΔϑΝΠϧΛม͑Δ • mongo_clarify_spec.rb 3VCZͷόʔδϣϯʹΑͬͯ ϑΝΠϧΛม͍͑ͨϞδϡʔϧ
ςετRubyͷόʔδϣϯʹΑͬͯ require͢ΔϑΝΠϧΛม͑Δ • .travis.yml $*ʹෳόʔδϣϯͰ ςετͯ͠Β͏
RubyGemsʹస͕͍ͬͯ·͢ • https://rubygems.org/gems/mongo_clarify
༨ஊ Gemͷ࡞աఔͰ MongoDBͷexplainʹ׳Ε ͜ͷGem͍ͬͯͳ͍