mongous 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.adoc +6 -3
- data/README.ja.adoc +6 -3
- data/lib/mongous/base.rb +12 -2
- data/lib/mongous/extention.rb +4 -0
- data/lib/mongous/filter.rb +57 -14
- data/lib/mongous/version.rb +1 -1
- data/sample/connect_auto_0.rb +1 -1
- data/sample/declare_compact_1.rb +0 -2
- data/sample/declare_compact_2.rb +38 -0
- data/sample/declare_label_1.rb +0 -2
- data/sample/declare_ndex_1.rb +0 -2
- data/sample/declare_ndex_2.rb +0 -2
- data/sample/declare_strict_1.rb +0 -2
- data/sample/declare_strict_2.rb +0 -2
- data/sample/multi_collection_1.rb +0 -2
- data/sample/multi_collection_2.rb +0 -2
- data/sample/multi_collection_3.rb +6 -8
- data/sample/query_basic_1.rb +8 -2
- data/sample/query_basic_2.rb +8 -2
- 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 +0 -2
- data/sample/query_detail_2.rb +0 -2
- 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 +6 -5
- data/sample/query_select_1.rb +8 -5
- 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 +0 -2
- data/sample/save_verify_1.rb +0 -2
- 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 +1 -5
- data/sample/zbenchmark_search_1.rb +19 -15
- data/sample/zbenchmark_search_2.rb +19 -15
- data/sample/zbenchmark_search_3.rb +25 -27
- metadata +5 -3
- data/sample/query_sort_order_1.rb +0 -46
data/sample/save_basic_2.rb
CHANGED
data/sample/save_basic_3.rb
CHANGED
data/sample/save_detail_1.rb
CHANGED
data/sample/save_detail_2.rb
CHANGED
data/sample/save_detail_3.rb
CHANGED
data/sample/save_verify_1.rb
CHANGED
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
data/sample/zap_basic_3.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
|
2
2
|
require "mongous"
|
3
3
|
|
4
|
-
Mongous.connect!
|
5
|
-
|
6
4
|
class Card
|
7
5
|
include Mongous::Document
|
8
6
|
field :i1, Integer
|
@@ -15,31 +13,35 @@ class Card
|
|
15
13
|
field :d2, Date
|
16
14
|
field :t1, Time
|
17
15
|
field :t2, Time
|
16
|
+
field :r1, Float
|
17
|
+
field :r2, Float
|
18
18
|
|
19
19
|
index :i2, unique: true
|
20
20
|
index :f2, unique: true
|
21
21
|
index :s2, unique: true
|
22
22
|
index :d2, unique: true
|
23
23
|
index :t2, unique: true
|
24
|
+
index :r2
|
24
25
|
end
|
25
26
|
|
26
27
|
require "benchmark"
|
27
28
|
require "date"
|
28
29
|
|
29
|
-
COUNT =
|
30
|
+
COUNT = 1000
|
30
31
|
|
31
32
|
D0 = Date.parse( "2020-01-01" )
|
32
33
|
T0 = D0.to_time
|
33
34
|
|
34
|
-
Benchmark.bm 32 do |
|
35
|
+
Benchmark.bm 32 do |bm|
|
35
36
|
if COUNT != Card.count
|
36
37
|
Card.delete
|
37
|
-
|
38
|
+
bm.report "create #{COUNT}" do
|
38
39
|
(0...COUNT).each do |i|
|
39
40
|
f = i.to_f
|
40
41
|
s = i.to_s
|
41
42
|
d = D0 + i
|
42
43
|
t = T0 + i
|
44
|
+
r = rand
|
43
45
|
card = Card.create(
|
44
46
|
i1: i,
|
45
47
|
i2: i,
|
@@ -51,57 +53,59 @@ Benchmark.bm 32 do |r|
|
|
51
53
|
d2: d,
|
52
54
|
t1: t,
|
53
55
|
t2: t,
|
56
|
+
r1: r,
|
57
|
+
r2: r,
|
54
58
|
)
|
55
59
|
end
|
56
60
|
end
|
57
61
|
end
|
58
62
|
|
59
|
-
|
63
|
+
bm.report "find a integer without index" do
|
60
64
|
(0...COUNT).each do |i|
|
61
65
|
Card.where( i1: i ).first
|
62
66
|
end
|
63
67
|
end
|
64
|
-
|
68
|
+
bm.report "find a integer with index" do
|
65
69
|
(0...COUNT).each do |i|
|
66
70
|
Card.where( i2: i ).first
|
67
71
|
end
|
68
72
|
end
|
69
|
-
|
73
|
+
bm.report "find a float without index" do
|
70
74
|
(0...COUNT).each do |i|
|
71
75
|
Card.where( f1: i.to_f ).first
|
72
76
|
end
|
73
77
|
end
|
74
|
-
|
78
|
+
bm.report "find a float with index" do
|
75
79
|
(0...COUNT).each do |i|
|
76
80
|
Card.where( f2: i.to_f ).first
|
77
81
|
end
|
78
82
|
end
|
79
|
-
|
83
|
+
bm.report "find a string without index" do
|
80
84
|
(0...COUNT).each do |i|
|
81
85
|
Card.where( s1: i.to_s ).first
|
82
86
|
end
|
83
87
|
end
|
84
|
-
|
88
|
+
bm.report "find a string with index" do
|
85
89
|
(0...COUNT).each do |i|
|
86
90
|
Card.where( s2: i.to_s ).first
|
87
91
|
end
|
88
92
|
end
|
89
|
-
|
93
|
+
bm.report "find a date without index" do
|
90
94
|
(0...COUNT).each do |i|
|
91
95
|
Card.where( d1: D0 + i ).first
|
92
96
|
end
|
93
97
|
end
|
94
|
-
|
98
|
+
bm.report "find a date with index" do
|
95
99
|
(0...COUNT).each do |i|
|
96
100
|
Card.where( d2: D0 + i ).first
|
97
101
|
end
|
98
102
|
end
|
99
|
-
|
103
|
+
bm.report "find a time without index" do
|
100
104
|
(0...COUNT).each do |i|
|
101
105
|
Card.where( t1: T0 + i ).first
|
102
106
|
end
|
103
107
|
end
|
104
|
-
|
108
|
+
bm.report "find a time with index" do
|
105
109
|
(0...COUNT).each do |i|
|
106
110
|
Card.where( t2: T0 + i ).first
|
107
111
|
end
|
@@ -1,8 +1,6 @@
|
|
1
1
|
|
2
2
|
require "mongous"
|
3
3
|
|
4
|
-
Mongous.connect!
|
5
|
-
|
6
4
|
class Card
|
7
5
|
include Mongous::Document
|
8
6
|
field :i1, Integer
|
@@ -15,31 +13,35 @@ class Card
|
|
15
13
|
field :d2, Date
|
16
14
|
field :t1, Time
|
17
15
|
field :t2, Time
|
16
|
+
field :r1, Float
|
17
|
+
field :r2, Float
|
18
18
|
|
19
19
|
index :i2, unique: true
|
20
20
|
index :f2, unique: true
|
21
21
|
index :s2, unique: true
|
22
22
|
index :d2, unique: true
|
23
23
|
index :t2, unique: true
|
24
|
+
index :r2
|
24
25
|
end
|
25
26
|
|
26
27
|
require "benchmark"
|
27
28
|
require "date"
|
28
29
|
|
29
|
-
COUNT =
|
30
|
+
COUNT = 1000
|
30
31
|
|
31
32
|
D0 = Date.parse( "2020-01-01" )
|
32
33
|
T0 = D0.to_time
|
33
34
|
|
34
|
-
Benchmark.bm 32 do |
|
35
|
+
Benchmark.bm 32 do |bm|
|
35
36
|
if COUNT != Card.count
|
36
37
|
Card.delete
|
37
|
-
|
38
|
+
bm.report "create #{COUNT}" do
|
38
39
|
(0...COUNT).each do |i|
|
39
40
|
f = i.to_f
|
40
41
|
s = i.to_s
|
41
42
|
d = D0 + i
|
42
43
|
t = T0 + i
|
44
|
+
r = rand
|
43
45
|
card = Card.create(
|
44
46
|
i1: i,
|
45
47
|
i2: i,
|
@@ -51,57 +53,59 @@ Benchmark.bm 32 do |r|
|
|
51
53
|
d2: d,
|
52
54
|
t1: t,
|
53
55
|
t2: t,
|
56
|
+
r1: r,
|
57
|
+
r2: r,
|
54
58
|
)
|
55
59
|
end
|
56
60
|
end
|
57
61
|
end
|
58
62
|
|
59
|
-
|
63
|
+
bm.report "find range integer without index" do
|
60
64
|
(0...COUNT).each do |i|
|
61
65
|
Card.where( i1: ( i ... (i+10) ) ).all
|
62
66
|
end
|
63
67
|
end
|
64
|
-
|
68
|
+
bm.report "find range integer with index" do
|
65
69
|
(0...COUNT).each do |i|
|
66
70
|
Card.where( i2: ( i ... (i+10) ) ).all
|
67
71
|
end
|
68
72
|
end
|
69
|
-
|
73
|
+
bm.report "find range float without index" do
|
70
74
|
(0...COUNT).each do |i|
|
71
75
|
Card.where( f1: ( i.to_f ... (i+10).to_f ) ).all
|
72
76
|
end
|
73
77
|
end
|
74
|
-
|
78
|
+
bm.report "find range float with index" do
|
75
79
|
(0...COUNT).each do |i|
|
76
80
|
Card.where( f2: ( i.to_f ... (i+10).to_f ) ).all
|
77
81
|
end
|
78
82
|
end
|
79
|
-
|
83
|
+
bm.report "find range string without index" do
|
80
84
|
(0...COUNT).each do |i|
|
81
85
|
Card.where( s1: ( i.to_s ... (i+10).to_s ) ).all
|
82
86
|
end
|
83
87
|
end
|
84
|
-
|
88
|
+
bm.report "find range string with index" do
|
85
89
|
(0...COUNT).each do |i|
|
86
90
|
Card.where( s2: ( i.to_s ... (i+10).to_s ) ).all
|
87
91
|
end
|
88
92
|
end
|
89
|
-
|
93
|
+
bm.report "find range date without index" do
|
90
94
|
(0...COUNT).each do |i|
|
91
95
|
Card.where( d1: ( (D0 + i) ... (D0 + i + 10) ) ).all
|
92
96
|
end
|
93
97
|
end
|
94
|
-
|
98
|
+
bm.report "find range date with index" do
|
95
99
|
(0...COUNT).each do |i|
|
96
100
|
Card.where( d2: ( (D0 + i) ... (D0 + i + 10) ) ).all
|
97
101
|
end
|
98
102
|
end
|
99
|
-
|
103
|
+
bm.report "find range time without index" do
|
100
104
|
(0...COUNT).each do |i|
|
101
105
|
Card.where( t1: ( (T0 + i) ... (T0 + i + 10) ) ).all
|
102
106
|
end
|
103
107
|
end
|
104
|
-
|
108
|
+
bm.report "find range time with index" do
|
105
109
|
(0...COUNT).each do |i|
|
106
110
|
Card.where( t2: ( (T0 + i) ... (T0 + i + 10) ) ).all
|
107
111
|
end
|
@@ -1,9 +1,7 @@
|
|
1
1
|
|
2
2
|
require "mongous"
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
class Card
|
4
|
+
class Plate
|
7
5
|
include Mongous::Document
|
8
6
|
field :i1, Integer
|
9
7
|
field :i2, Integer
|
@@ -34,17 +32,17 @@ COUNT = 100000
|
|
34
32
|
D0 = Date.parse( "2020-01-01" )
|
35
33
|
T0 = D0.to_time
|
36
34
|
|
37
|
-
Benchmark.bm 40 do |
|
38
|
-
if COUNT !=
|
39
|
-
|
40
|
-
|
35
|
+
Benchmark.bm 40 do |bm|
|
36
|
+
if COUNT != Plate.count
|
37
|
+
Plate.delete
|
38
|
+
bm.report "create #{COUNT}" do
|
41
39
|
(0...COUNT).each do |i|
|
42
40
|
f = i.to_f
|
43
41
|
s = i.to_s
|
44
42
|
d = D0 + i
|
45
43
|
t = T0 + i
|
46
|
-
|
47
|
-
card =
|
44
|
+
r = rand
|
45
|
+
card = Plate.create(
|
48
46
|
i1: i,
|
49
47
|
i2: i,
|
50
48
|
f1: f,
|
@@ -55,36 +53,36 @@ Benchmark.bm 40 do |r|
|
|
55
53
|
d2: d,
|
56
54
|
t1: t,
|
57
55
|
t2: t,
|
58
|
-
r1:
|
59
|
-
r2:
|
56
|
+
r1: r,
|
57
|
+
r2: r,
|
60
58
|
)
|
61
59
|
end
|
62
60
|
end
|
63
61
|
end
|
64
62
|
|
65
|
-
|
66
|
-
|
63
|
+
bm.report "first, order by asc without index" do
|
64
|
+
Plate.sort( r1: 1 ).first
|
67
65
|
end
|
68
|
-
|
69
|
-
|
66
|
+
bm.report "first, order by desc without index" do
|
67
|
+
Plate.sort( r1: -1 ).first
|
70
68
|
end
|
71
|
-
|
72
|
-
|
69
|
+
bm.report "top 10, order by asc without index" do
|
70
|
+
Plate.sort( r1: 1 )[0,10].all
|
73
71
|
end
|
74
|
-
|
75
|
-
|
72
|
+
bm.report "top 10, order by desc without index" do
|
73
|
+
Plate.sort( r1: -1 )[0,10].all
|
76
74
|
end
|
77
|
-
|
78
|
-
|
75
|
+
bm.report "first, order by asc with index" do
|
76
|
+
Plate.sort( r2: 1 ).first
|
79
77
|
end
|
80
|
-
|
81
|
-
|
78
|
+
bm.report "first, order by desc with index" do
|
79
|
+
Plate.sort( r2: -1 ).first
|
82
80
|
end
|
83
|
-
|
84
|
-
|
81
|
+
bm.report "top 10, order by asc with index" do
|
82
|
+
Plate.sort( r2: 1 )[0,10].all
|
85
83
|
end
|
86
|
-
|
87
|
-
|
84
|
+
bm.report "top 10, order by desc with index" do
|
85
|
+
Plate.sort( r2: -1 )[0,10].all
|
88
86
|
end
|
89
87
|
end
|
90
88
|
|