mongous 0.2.1 → 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +73 -0
- data/README.adoc +176 -26
- data/README.ja.adoc +176 -26
- data/Rakefile +8 -8
- data/_Gemfile.lock +38 -0
- data/lib/mongous/base.rb +52 -8
- data/lib/mongous/document.rb +21 -10
- data/lib/mongous/extention.rb +45 -35
- data/lib/mongous/filter.rb +316 -230
- data/lib/mongous/version.rb +1 -1
- data/mongous.gemspec +4 -4
- data/sample/connect_auto_0.rb +9 -0
- data/sample/declare_compact_1.rb +5 -8
- data/sample/declare_compact_2.rb +38 -0
- data/sample/declare_label_1.rb +7 -7
- data/sample/declare_ndex_1.rb +6 -6
- data/sample/declare_ndex_2.rb +7 -7
- data/sample/declare_strict_1.rb +2 -4
- data/sample/declare_strict_2.rb +2 -4
- data/sample/multi_collection_1.rb +0 -2
- data/sample/multi_collection_2.rb +0 -2
- data/sample/multi_collection_3.rb +24 -0
- data/sample/query_basic_1.rb +10 -4
- data/sample/query_basic_2.rb +10 -4
- data/sample/query_basic_3.rb +0 -2
- data/sample/query_basic_4.rb +0 -2
- data/sample/query_basic_5.rb +0 -2
- data/sample/query_basic_6.rb +56 -0
- data/sample/query_detail_1.rb +2 -3
- data/sample/query_detail_2.rb +2 -3
- data/sample/query_detail_3.rb +0 -2
- data/sample/query_filter_1.rb +0 -2
- data/sample/query_filter_2.rb +0 -2
- data/sample/query_find_1.rb +14 -13
- data/sample/query_select_1.rb +54 -0
- data/sample/query_skip_limit_1.rb +17 -16
- data/sample/query_skip_limit_2.rb +19 -10
- data/sample/query_sort_1.rb +43 -0
- data/sample/save_basic_1.rb +1 -5
- data/sample/save_basic_2.rb +1 -5
- data/sample/save_basic_3.rb +1 -5
- data/sample/save_detail_1.rb +0 -2
- data/sample/save_detail_2.rb +0 -2
- data/sample/save_detail_3.rb +5 -7
- data/sample/save_verify_1.rb +2 -4
- data/sample/save_verify_2.rb +0 -2
- data/sample/save_verify_3.rb +0 -2
- data/sample/save_verify_4.rb +0 -2
- data/sample/save_verify_5.rb +0 -2
- data/sample/save_verify_6.rb +0 -2
- data/sample/save_verify_7.rb +0 -2
- data/sample/update_basic_1.rb +1 -5
- data/sample/zap_basic_1.rb +1 -5
- data/sample/zap_basic_2.rb +2 -6
- data/sample/zap_basic_3.rb +7 -0
- data/sample/zbenchmark_search_1.rb +114 -0
- data/sample/zbenchmark_search_2.rb +114 -0
- data/sample/zbenchmark_search_3.rb +88 -0
- metadata +31 -22
- data/.travis.yml +0 -6
- data/sample/query_projection_1.rb +0 -41
- data/sample/query_sort_order_1.rb +0 -46
data/sample/save_verify_2.rb
CHANGED
data/sample/save_verify_3.rb
CHANGED
data/sample/save_verify_4.rb
CHANGED
data/sample/save_verify_5.rb
CHANGED
data/sample/save_verify_6.rb
CHANGED
data/sample/save_verify_7.rb
CHANGED
data/sample/update_basic_1.rb
CHANGED
data/sample/zap_basic_1.rb
CHANGED
data/sample/zap_basic_2.rb
CHANGED
@@ -0,0 +1,114 @@
|
|
1
|
+
|
2
|
+
require "mongous"
|
3
|
+
|
4
|
+
class Card
|
5
|
+
include Mongous::Document
|
6
|
+
field :i1, Integer
|
7
|
+
field :i2, Integer
|
8
|
+
field :f1, Float
|
9
|
+
field :f2, Float
|
10
|
+
field :s1, String
|
11
|
+
field :s2, String
|
12
|
+
field :d1, Date
|
13
|
+
field :d2, Date
|
14
|
+
field :t1, Time
|
15
|
+
field :t2, Time
|
16
|
+
field :r1, Float
|
17
|
+
field :r2, Float
|
18
|
+
|
19
|
+
index :i2, unique: true
|
20
|
+
index :f2, unique: true
|
21
|
+
index :s2, unique: true
|
22
|
+
index :d2, unique: true
|
23
|
+
index :t2, unique: true
|
24
|
+
index :r2
|
25
|
+
end
|
26
|
+
|
27
|
+
require "benchmark"
|
28
|
+
require "date"
|
29
|
+
|
30
|
+
COUNT = 1000
|
31
|
+
|
32
|
+
D0 = Date.parse( "2020-01-01" )
|
33
|
+
T0 = D0.to_time
|
34
|
+
|
35
|
+
Benchmark.bm 32 do |bm|
|
36
|
+
if COUNT != Card.count
|
37
|
+
Card.delete
|
38
|
+
bm.report "create #{COUNT}" do
|
39
|
+
(0...COUNT).each do |i|
|
40
|
+
f = i.to_f
|
41
|
+
s = i.to_s
|
42
|
+
d = D0 + i
|
43
|
+
t = T0 + i
|
44
|
+
r = rand
|
45
|
+
card = Card.create(
|
46
|
+
i1: i,
|
47
|
+
i2: i,
|
48
|
+
f1: f,
|
49
|
+
f2: f,
|
50
|
+
s1: s,
|
51
|
+
s2: s,
|
52
|
+
d1: d,
|
53
|
+
d2: d,
|
54
|
+
t1: t,
|
55
|
+
t2: t,
|
56
|
+
r1: r,
|
57
|
+
r2: r,
|
58
|
+
)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
bm.report "find a integer without index" do
|
64
|
+
(0...COUNT).each do |i|
|
65
|
+
Card.where( i1: i ).first
|
66
|
+
end
|
67
|
+
end
|
68
|
+
bm.report "find a integer with index" do
|
69
|
+
(0...COUNT).each do |i|
|
70
|
+
Card.where( i2: i ).first
|
71
|
+
end
|
72
|
+
end
|
73
|
+
bm.report "find a float without index" do
|
74
|
+
(0...COUNT).each do |i|
|
75
|
+
Card.where( f1: i.to_f ).first
|
76
|
+
end
|
77
|
+
end
|
78
|
+
bm.report "find a float with index" do
|
79
|
+
(0...COUNT).each do |i|
|
80
|
+
Card.where( f2: i.to_f ).first
|
81
|
+
end
|
82
|
+
end
|
83
|
+
bm.report "find a string without index" do
|
84
|
+
(0...COUNT).each do |i|
|
85
|
+
Card.where( s1: i.to_s ).first
|
86
|
+
end
|
87
|
+
end
|
88
|
+
bm.report "find a string with index" do
|
89
|
+
(0...COUNT).each do |i|
|
90
|
+
Card.where( s2: i.to_s ).first
|
91
|
+
end
|
92
|
+
end
|
93
|
+
bm.report "find a date without index" do
|
94
|
+
(0...COUNT).each do |i|
|
95
|
+
Card.where( d1: D0 + i ).first
|
96
|
+
end
|
97
|
+
end
|
98
|
+
bm.report "find a date with index" do
|
99
|
+
(0...COUNT).each do |i|
|
100
|
+
Card.where( d2: D0 + i ).first
|
101
|
+
end
|
102
|
+
end
|
103
|
+
bm.report "find a time without index" do
|
104
|
+
(0...COUNT).each do |i|
|
105
|
+
Card.where( t1: T0 + i ).first
|
106
|
+
end
|
107
|
+
end
|
108
|
+
bm.report "find a time with index" do
|
109
|
+
(0...COUNT).each do |i|
|
110
|
+
Card.where( t2: T0 + i ).first
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
@@ -0,0 +1,114 @@
|
|
1
|
+
|
2
|
+
require "mongous"
|
3
|
+
|
4
|
+
class Card
|
5
|
+
include Mongous::Document
|
6
|
+
field :i1, Integer
|
7
|
+
field :i2, Integer
|
8
|
+
field :f1, Float
|
9
|
+
field :f2, Float
|
10
|
+
field :s1, String
|
11
|
+
field :s2, String
|
12
|
+
field :d1, Date
|
13
|
+
field :d2, Date
|
14
|
+
field :t1, Time
|
15
|
+
field :t2, Time
|
16
|
+
field :r1, Float
|
17
|
+
field :r2, Float
|
18
|
+
|
19
|
+
index :i2, unique: true
|
20
|
+
index :f2, unique: true
|
21
|
+
index :s2, unique: true
|
22
|
+
index :d2, unique: true
|
23
|
+
index :t2, unique: true
|
24
|
+
index :r2
|
25
|
+
end
|
26
|
+
|
27
|
+
require "benchmark"
|
28
|
+
require "date"
|
29
|
+
|
30
|
+
COUNT = 1000
|
31
|
+
|
32
|
+
D0 = Date.parse( "2020-01-01" )
|
33
|
+
T0 = D0.to_time
|
34
|
+
|
35
|
+
Benchmark.bm 32 do |bm|
|
36
|
+
if COUNT != Card.count
|
37
|
+
Card.delete
|
38
|
+
bm.report "create #{COUNT}" do
|
39
|
+
(0...COUNT).each do |i|
|
40
|
+
f = i.to_f
|
41
|
+
s = i.to_s
|
42
|
+
d = D0 + i
|
43
|
+
t = T0 + i
|
44
|
+
r = rand
|
45
|
+
card = Card.create(
|
46
|
+
i1: i,
|
47
|
+
i2: i,
|
48
|
+
f1: f,
|
49
|
+
f2: f,
|
50
|
+
s1: s,
|
51
|
+
s2: s,
|
52
|
+
d1: d,
|
53
|
+
d2: d,
|
54
|
+
t1: t,
|
55
|
+
t2: t,
|
56
|
+
r1: r,
|
57
|
+
r2: r,
|
58
|
+
)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
bm.report "find range integer without index" do
|
64
|
+
(0...COUNT).each do |i|
|
65
|
+
Card.where( i1: ( i ... (i+10) ) ).all
|
66
|
+
end
|
67
|
+
end
|
68
|
+
bm.report "find range integer with index" do
|
69
|
+
(0...COUNT).each do |i|
|
70
|
+
Card.where( i2: ( i ... (i+10) ) ).all
|
71
|
+
end
|
72
|
+
end
|
73
|
+
bm.report "find range float without index" do
|
74
|
+
(0...COUNT).each do |i|
|
75
|
+
Card.where( f1: ( i.to_f ... (i+10).to_f ) ).all
|
76
|
+
end
|
77
|
+
end
|
78
|
+
bm.report "find range float with index" do
|
79
|
+
(0...COUNT).each do |i|
|
80
|
+
Card.where( f2: ( i.to_f ... (i+10).to_f ) ).all
|
81
|
+
end
|
82
|
+
end
|
83
|
+
bm.report "find range string without index" do
|
84
|
+
(0...COUNT).each do |i|
|
85
|
+
Card.where( s1: ( i.to_s ... (i+10).to_s ) ).all
|
86
|
+
end
|
87
|
+
end
|
88
|
+
bm.report "find range string with index" do
|
89
|
+
(0...COUNT).each do |i|
|
90
|
+
Card.where( s2: ( i.to_s ... (i+10).to_s ) ).all
|
91
|
+
end
|
92
|
+
end
|
93
|
+
bm.report "find range date without index" do
|
94
|
+
(0...COUNT).each do |i|
|
95
|
+
Card.where( d1: ( (D0 + i) ... (D0 + i + 10) ) ).all
|
96
|
+
end
|
97
|
+
end
|
98
|
+
bm.report "find range date with index" do
|
99
|
+
(0...COUNT).each do |i|
|
100
|
+
Card.where( d2: ( (D0 + i) ... (D0 + i + 10) ) ).all
|
101
|
+
end
|
102
|
+
end
|
103
|
+
bm.report "find range time without index" do
|
104
|
+
(0...COUNT).each do |i|
|
105
|
+
Card.where( t1: ( (T0 + i) ... (T0 + i + 10) ) ).all
|
106
|
+
end
|
107
|
+
end
|
108
|
+
bm.report "find range time with index" do
|
109
|
+
(0...COUNT).each do |i|
|
110
|
+
Card.where( t2: ( (T0 + i) ... (T0 + i + 10) ) ).all
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
@@ -0,0 +1,88 @@
|
|
1
|
+
|
2
|
+
require "mongous"
|
3
|
+
|
4
|
+
class Plate
|
5
|
+
include Mongous::Document
|
6
|
+
field :i1, Integer
|
7
|
+
field :i2, Integer
|
8
|
+
field :f1, Float
|
9
|
+
field :f2, Float
|
10
|
+
field :s1, String
|
11
|
+
field :s2, String
|
12
|
+
field :d1, Date
|
13
|
+
field :d2, Date
|
14
|
+
field :t1, Time
|
15
|
+
field :t2, Time
|
16
|
+
field :r1, Float
|
17
|
+
field :r2, Float
|
18
|
+
|
19
|
+
index :i2, unique: true
|
20
|
+
index :f2, unique: true
|
21
|
+
index :s2, unique: true
|
22
|
+
index :d2, unique: true
|
23
|
+
index :t2, unique: true
|
24
|
+
index :r2
|
25
|
+
end
|
26
|
+
|
27
|
+
require "benchmark"
|
28
|
+
require "date"
|
29
|
+
|
30
|
+
COUNT = 100000
|
31
|
+
|
32
|
+
D0 = Date.parse( "2020-01-01" )
|
33
|
+
T0 = D0.to_time
|
34
|
+
|
35
|
+
Benchmark.bm 40 do |bm|
|
36
|
+
if COUNT != Plate.count
|
37
|
+
Plate.delete
|
38
|
+
bm.report "create #{COUNT}" do
|
39
|
+
(0...COUNT).each do |i|
|
40
|
+
f = i.to_f
|
41
|
+
s = i.to_s
|
42
|
+
d = D0 + i
|
43
|
+
t = T0 + i
|
44
|
+
r = rand
|
45
|
+
card = Plate.create(
|
46
|
+
i1: i,
|
47
|
+
i2: i,
|
48
|
+
f1: f,
|
49
|
+
f2: f,
|
50
|
+
s1: s,
|
51
|
+
s2: s,
|
52
|
+
d1: d,
|
53
|
+
d2: d,
|
54
|
+
t1: t,
|
55
|
+
t2: t,
|
56
|
+
r1: r,
|
57
|
+
r2: r,
|
58
|
+
)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
bm.report "first, order by asc without index" do
|
64
|
+
Plate.sort( r1: 1 ).first
|
65
|
+
end
|
66
|
+
bm.report "first, order by desc without index" do
|
67
|
+
Plate.sort( r1: -1 ).first
|
68
|
+
end
|
69
|
+
bm.report "top 10, order by asc without index" do
|
70
|
+
Plate.sort( r1: 1 )[0,10].all
|
71
|
+
end
|
72
|
+
bm.report "top 10, order by desc without index" do
|
73
|
+
Plate.sort( r1: -1 )[0,10].all
|
74
|
+
end
|
75
|
+
bm.report "first, order by asc with index" do
|
76
|
+
Plate.sort( r2: 1 ).first
|
77
|
+
end
|
78
|
+
bm.report "first, order by desc with index" do
|
79
|
+
Plate.sort( r2: -1 ).first
|
80
|
+
end
|
81
|
+
bm.report "top 10, order by asc with index" do
|
82
|
+
Plate.sort( r2: 1 )[0,10].all
|
83
|
+
end
|
84
|
+
bm.report "top 10, order by desc with index" do
|
85
|
+
Plate.sort( r2: -1 )[0,10].all
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
metadata
CHANGED
@@ -1,58 +1,58 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongous
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- arimay
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mongo
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
55
|
-
description: " Yet another
|
54
|
+
version: '0'
|
55
|
+
description: " Yet another mongo wrapper library. "
|
56
56
|
email:
|
57
57
|
- arima.yasuhiro@gmail.com
|
58
58
|
executables: []
|
@@ -61,11 +61,12 @@ extra_rdoc_files: []
|
|
61
61
|
files:
|
62
62
|
- ".gitignore"
|
63
63
|
- ".rspec"
|
64
|
-
- ".
|
64
|
+
- ".rubocop.yml"
|
65
65
|
- Gemfile
|
66
66
|
- README.adoc
|
67
67
|
- README.ja.adoc
|
68
68
|
- Rakefile
|
69
|
+
- _Gemfile.lock
|
69
70
|
- bin/console
|
70
71
|
- bin/setup
|
71
72
|
- lib/mongous.rb
|
@@ -75,6 +76,7 @@ files:
|
|
75
76
|
- lib/mongous/filter.rb
|
76
77
|
- lib/mongous/version.rb
|
77
78
|
- mongous.gemspec
|
79
|
+
- sample/connect_auto_0.rb
|
78
80
|
- sample/connect_auto_1.rb
|
79
81
|
- sample/connect_auto_2.rb
|
80
82
|
- sample/connect_default_1.rb
|
@@ -85,6 +87,7 @@ files:
|
|
85
87
|
- sample/connect_loadfile_2.rb
|
86
88
|
- sample/connect_mongo.yml
|
87
89
|
- sample/declare_compact_1.rb
|
90
|
+
- sample/declare_compact_2.rb
|
88
91
|
- sample/declare_label_1.rb
|
89
92
|
- sample/declare_ndex_1.rb
|
90
93
|
- sample/declare_ndex_2.rb
|
@@ -92,21 +95,23 @@ files:
|
|
92
95
|
- sample/declare_strict_2.rb
|
93
96
|
- sample/multi_collection_1.rb
|
94
97
|
- sample/multi_collection_2.rb
|
98
|
+
- sample/multi_collection_3.rb
|
95
99
|
- sample/query_basic_1.rb
|
96
100
|
- sample/query_basic_2.rb
|
97
101
|
- sample/query_basic_3.rb
|
98
102
|
- sample/query_basic_4.rb
|
99
103
|
- sample/query_basic_5.rb
|
104
|
+
- sample/query_basic_6.rb
|
100
105
|
- sample/query_detail_1.rb
|
101
106
|
- sample/query_detail_2.rb
|
102
107
|
- sample/query_detail_3.rb
|
103
108
|
- sample/query_filter_1.rb
|
104
109
|
- sample/query_filter_2.rb
|
105
110
|
- sample/query_find_1.rb
|
106
|
-
- sample/
|
111
|
+
- sample/query_select_1.rb
|
107
112
|
- sample/query_skip_limit_1.rb
|
108
113
|
- sample/query_skip_limit_2.rb
|
109
|
-
- sample/
|
114
|
+
- sample/query_sort_1.rb
|
110
115
|
- sample/save_basic_1.rb
|
111
116
|
- sample/save_basic_2.rb
|
112
117
|
- sample/save_basic_3.rb
|
@@ -123,11 +128,15 @@ files:
|
|
123
128
|
- sample/update_basic_1.rb
|
124
129
|
- sample/zap_basic_1.rb
|
125
130
|
- sample/zap_basic_2.rb
|
131
|
+
- sample/zap_basic_3.rb
|
132
|
+
- sample/zbenchmark_search_1.rb
|
133
|
+
- sample/zbenchmark_search_2.rb
|
134
|
+
- sample/zbenchmark_search_3.rb
|
126
135
|
homepage: https://github.com/arimay/mongous
|
127
136
|
licenses:
|
128
137
|
- MIT
|
129
138
|
metadata: {}
|
130
|
-
post_install_message:
|
139
|
+
post_install_message:
|
131
140
|
rdoc_options: []
|
132
141
|
require_paths:
|
133
142
|
- lib
|
@@ -142,8 +151,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
142
151
|
- !ruby/object:Gem::Version
|
143
152
|
version: '0'
|
144
153
|
requirements: []
|
145
|
-
rubygems_version: 3.
|
146
|
-
signing_key:
|
154
|
+
rubygems_version: 3.2.3
|
155
|
+
signing_key:
|
147
156
|
specification_version: 4
|
148
157
|
summary: Mongo wrapper library.
|
149
158
|
test_files: []
|