mongo_clarify 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -2
- data/.travis.yml +4 -2
- data/Gemfile.lock +2 -2
- data/exe/mongo_clarify +1 -0
- data/lib/mongo_clarify/investigate.rb +5 -37
- data/lib/mongo_clarify/{investigate_ruby2_7.rb → investigate_with_pattern_matching.rb} +3 -2
- data/lib/mongo_clarify/investigate_without_pattern_matching.rb +41 -0
- data/lib/mongo_clarify/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5eaf57ef80937dc7775a997adfaf20fcf38cf8b3c86a4168762277208c59a09
|
4
|
+
data.tar.gz: 83c783004ec9759ca32dc75402d400572828af989c9c446aaf1ba43af3b944f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ab45003e8f4d9316b106e38aeb3c7da813c35b3602b1d68c0e030e420e1ab98ba5a9384a518e3cde610448b703b8a4a28e26c3e40c6c164acb83749e2b96a8c
|
7
|
+
data.tar.gz: 4267879d0f6d076bd93f613414a92a75e695ef28aee46abe8dd5e164043cd370612854526ffa36fed5c9cde627f0aaaa30fdbd1df04b9f6a7a1607a4e577f632
|
data/.rubocop.yml
CHANGED
@@ -4,7 +4,7 @@ AllCops:
|
|
4
4
|
Exclude:
|
5
5
|
- "vendor/**/*"
|
6
6
|
- "spec/spec_helper.rb"
|
7
|
-
- "lib/mongo_clarify/
|
7
|
+
- "lib/mongo_clarify/investigate_with_pattern_matching.rb"
|
8
8
|
|
9
9
|
Style/Documentation:
|
10
10
|
Enabled: false
|
@@ -17,4 +17,4 @@ Metrics/LineLength:
|
|
17
17
|
|
18
18
|
Style/LambdaCall:
|
19
19
|
Exclude:
|
20
|
-
- "lib/mongo_clarify/
|
20
|
+
- "lib/mongo_clarify/investigate_without_pattern_matching.rb"
|
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
data/exe/mongo_clarify
CHANGED
@@ -1,41 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
def initialize(explain)
|
10
|
-
@explain = explain
|
11
|
-
end
|
3
|
+
if Gem::Version.create(RUBY_VERSION) >= Gem::Version.create('2.7')
|
4
|
+
require_relative 'investigate_with_pattern_matching'
|
5
|
+
else
|
6
|
+
require_relative 'investigate_without_pattern_matching'
|
7
|
+
end
|
12
8
|
|
13
|
-
def operation_method
|
14
|
-
match(@explain) do
|
15
|
-
with(Hash.(queryPlanner: Hash.(winningPlan: Hash.(stage: 'COLLSCAN')))) do
|
16
|
-
'Collection Scan'
|
17
|
-
end
|
18
|
-
with(Hash.(queryPlanner: Hash.(winningPlan: Hash.(stage: 'FETCH', inputStage: Hash.(stage: 'IXSCAN', indexName: index_name))))) do
|
19
|
-
"Index Scan (Index Name: #{index_name})"
|
20
|
-
end
|
21
|
-
end
|
22
|
-
rescue PatternMatch::NoMatchingPatternError
|
23
|
-
nil
|
24
|
-
end
|
25
9
|
|
26
|
-
def execution_stats
|
27
|
-
match(@explain) do
|
28
|
-
with(Hash.(executionStats: Hash.(nReturned: n, executionTimeMillis: msec, totalKeysExamined: keys, totalDocsExamined: docs))) do
|
29
|
-
{
|
30
|
-
n_returned: n,
|
31
|
-
execution_time_millis: msec,
|
32
|
-
total_keys_examined: keys,
|
33
|
-
total_docs_examined: docs
|
34
|
-
}
|
35
|
-
end
|
36
|
-
end
|
37
|
-
rescue PatternMatch::NoMatchingPatternError
|
38
|
-
nil
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module MongoClarify
|
4
|
-
class
|
4
|
+
class Investigate
|
5
5
|
def initialize(explain)
|
6
6
|
@explain = explain
|
7
7
|
end
|
@@ -13,7 +13,7 @@ module MongoClarify
|
|
13
13
|
in { queryPlanner: { winningPlan: { stage: 'FETCH', inputStage: { stage: 'IXSCAN', indexName: index_name } } } }
|
14
14
|
"Index Scan (Index Name: #{index_name})"
|
15
15
|
else
|
16
|
-
|
16
|
+
nil
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -21,6 +21,7 @@ module MongoClarify
|
|
21
21
|
case @explain
|
22
22
|
in { executionStats: { nReturned: n, executionTimeMillis: msec, totalKeysExamined: keys, totalDocsExamined: docs } }
|
23
23
|
else
|
24
|
+
return
|
24
25
|
end
|
25
26
|
{ n_returned: n, execution_time_millis: msec, total_keys_examined: keys, total_docs_examined: docs }
|
26
27
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'pattern-match/experimental'
|
4
|
+
|
5
|
+
module MongoClarify
|
6
|
+
class Investigate
|
7
|
+
using PatternMatch
|
8
|
+
|
9
|
+
def initialize(explain)
|
10
|
+
@explain = explain
|
11
|
+
end
|
12
|
+
|
13
|
+
def operation_method
|
14
|
+
match(@explain) do
|
15
|
+
with(Hash.(queryPlanner: Hash.(winningPlan: Hash.(stage: 'COLLSCAN')))) do
|
16
|
+
'Collection Scan'
|
17
|
+
end
|
18
|
+
with(Hash.(queryPlanner: Hash.(winningPlan: Hash.(stage: 'FETCH', inputStage: Hash.(stage: 'IXSCAN', indexName: index_name))))) do
|
19
|
+
"Index Scan (Index Name: #{index_name})"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
rescue PatternMatch::NoMatchingPatternError
|
23
|
+
nil
|
24
|
+
end
|
25
|
+
|
26
|
+
def execution_stats
|
27
|
+
match(@explain) do
|
28
|
+
with(Hash.(executionStats: Hash.(nReturned: n, executionTimeMillis: msec, totalKeysExamined: keys, totalDocsExamined: docs))) do
|
29
|
+
{
|
30
|
+
n_returned: n,
|
31
|
+
execution_time_millis: msec,
|
32
|
+
total_keys_examined: keys,
|
33
|
+
total_docs_examined: docs
|
34
|
+
}
|
35
|
+
end
|
36
|
+
end
|
37
|
+
rescue PatternMatch::NoMatchingPatternError
|
38
|
+
nil
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongo_clarify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- morihirok
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pattern-match
|
@@ -90,7 +90,8 @@ files:
|
|
90
90
|
- exe/mongo_clarify
|
91
91
|
- lib/mongo_clarify.rb
|
92
92
|
- lib/mongo_clarify/investigate.rb
|
93
|
-
- lib/mongo_clarify/
|
93
|
+
- lib/mongo_clarify/investigate_with_pattern_matching.rb
|
94
|
+
- lib/mongo_clarify/investigate_without_pattern_matching.rb
|
94
95
|
- lib/mongo_clarify/output.rb
|
95
96
|
- lib/mongo_clarify/version.rb
|
96
97
|
- mongo_clarify.gemspec
|
@@ -113,8 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
113
114
|
- !ruby/object:Gem::Version
|
114
115
|
version: '0'
|
115
116
|
requirements: []
|
116
|
-
|
117
|
-
rubygems_version: 2.7.6
|
117
|
+
rubygems_version: 3.0.3
|
118
118
|
signing_key:
|
119
119
|
specification_version: 4
|
120
120
|
summary: Make MongoDB's explain results more understandable.
|