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
iOS/Androidで同じUI体験をネ イティブで作成する際に気をつ けたい落とし穴
fumiyasac0921
1
110
SSMRunbook作成の勘所_20241120
koichiotomo
2
130
OCI Vault 概要
oracle4engineer
PRO
0
9.7k
第1回 国土交通省 データコンペ参加者向け勉強会③- Snowflake x estie編 -
estie
0
130
Why App Signing Matters for Your Android Apps - Android Bangkok Conference 2024
akexorcist
0
130
マルチモーダル / AI Agent / LLMOps 3つの技術トレンドで理解するLLMの今後の展望
hirosatogamo
37
12k
SREが投資するAIOps ~ペアーズにおけるLLM for Developerへの取り組み~
takumiogawa
1
210
複雑なState管理からの脱却
sansantech
PRO
1
140
適材適所の技術選定 〜GraphQL・REST API・tRPC〜 / Optimal Technology Selection
kakehashi
1
400
Introduction to Works of ML Engineer in LY Corporation
lycorp_recruit_jp
0
120
OCI 運用監視サービス 概要
oracle4engineer
PRO
0
4.8k
Terraform未経験の御様に対してどの ように導⼊を進めていったか
tkikuchi
2
430
Featured
See All Featured
Making Projects Easy
brettharned
115
5.9k
For a Future-Friendly Web
brad_frost
175
9.4k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
42
9.2k
Unsuck your backbone
ammeep
668
57k
Rails Girls Zürich Keynote
gr2m
94
13k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
The Art of Programming - Codeland 2020
erikaheidi
52
13k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
The Power of CSS Pseudo Elements
geoffreycrofte
73
5.3k
What's in a price? How to price your products and services
michaelherold
243
12k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
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͍ͬͯͳ͍