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
When Windows Meets Kubernetes…
pichuang
0
300
Kotlin Multiplatformのポテンシャル
recruitengineers
PRO
2
150
東京Ruby会議12 Ruby と Rust と私 / Tokyo RubyKaigi 12 Ruby, Rust and me
eagletmt
3
870
KMP with Crashlytics
sansantech
PRO
0
240
Unsafe.BitCast のすゝめ。
nenonaninu
0
200
Oracle Exadata Database Service(Dedicated Infrastructure):サービス概要のご紹介
oracle4engineer
PRO
0
12k
AWS re:Invent 2024 recap in 20min / JAWSUG 千葉 2025.1.14
shimy
1
100
メンバーがオーナーシップを発揮しやすいチームづくり
ham0215
1
100
AWSの生成AIサービス Amazon Bedrock入門!(2025年1月版)
minorun365
PRO
7
470
AWSサービスアップデート 2024/12 Part3
nrinetcom
PRO
0
140
JuliaTokaiとJuliaLangJaの紹介 for NGK2025S
antimon2
1
110
深層学習と3Dキャプチャ・3Dモデル生成(土木学会応用力学委員会 応用数理・AIセミナー)
pfn
PRO
0
460
Featured
See All Featured
Designing for Performance
lara
604
68k
Done Done
chrislema
182
16k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.9k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
44
9.4k
Product Roadmaps are Hard
iamctodd
PRO
50
11k
Building Better People: How to give real-time feedback that sticks.
wjessup
366
19k
KATA
mclloyd
29
14k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
28
4.5k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
26
1.9k
4 Signs Your Business is Dying
shpigford
182
22k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
49k
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͍ͬͯͳ͍