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
170
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
継続的にRailsアプリを開発する上で早めにやっておきたいこと
morihirok
9
2.7k
1日5分!子育て中もインプットを続ける工夫
morihirok
4
1k
rarray_value.pdf
morihirok
0
1.5k
失敗しても大丈夫!ひとりWebサービスのすゝめ
morihirok
2
450
introduce_pattern_matching_with_mongo-clarify
morihirok
0
85
サーバレスアーキテクチャ入門
morihirok
0
220
エンジニアの勉強法
morihirok
0
370
Other Decks in Technology
See All in Technology
初心者向けAWS Securityの勉強会mini Security-JAWSを9ヶ月ぐらい実施してきての近況
cmusudakeisuke
0
130
AI前提のサービス運用ってなんだろう?
ryuichi1208
8
1.4k
The Rise of LLMOps
asei
7
1.7k
Engineer Career Talk
lycorp_recruit_jp
0
190
障害対応指揮の意思決定と情報共有における価値観 / Waroom Meetup #2
arthur1
5
480
Python(PYNQ)がテーマのAMD主催のFPGAコンテストに参加してきた
iotengineer22
0
500
TypeScriptの次なる大進化なるか!? 条件型を返り値とする関数の型推論
uhyo
2
1.7k
Why App Signing Matters for Your Android Apps - Android Bangkok Conference 2024
akexorcist
0
130
IBC 2024 動画技術関連レポート / IBC 2024 Report
cyberagentdevelopers
PRO
1
110
Incident Response Practices: Waroom's Features and Future Challenges
rrreeeyyy
0
160
Lambda10周年!Lambdaは何をもたらしたか
smt7174
2
110
10XにおけるData Contractの導入について: Data Contract事例共有会
10xinc
6
660
Featured
See All Featured
Rails Girls Zürich Keynote
gr2m
94
13k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
A better future with KSS
kneath
238
17k
Being A Developer After 40
akosma
87
590k
Why Our Code Smells
bkeepers
PRO
334
57k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
27
4.3k
Unsuck your backbone
ammeep
668
57k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
28
2k
A Philosophy of Restraint
colly
203
16k
Designing the Hi-DPI Web
ddemaree
280
34k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Statistics for Hackers
jakevdp
796
220k
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͍ͬͯͳ͍