tarantool 0.3.0.7 → 0.4.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. data/Gemfile +2 -3
  2. data/README.md +90 -30
  3. data/Rakefile +6 -1
  4. data/lib/tarantool.rb +93 -18
  5. data/lib/tarantool/base_record.rb +97 -10
  6. data/lib/tarantool/block_db.rb +104 -6
  7. data/lib/tarantool/callback_db.rb +7 -0
  8. data/lib/tarantool/core-ext.rb +24 -8
  9. data/lib/tarantool/em_db.rb +189 -20
  10. data/lib/tarantool/exceptions.rb +4 -0
  11. data/lib/tarantool/fiber_db.rb +15 -1
  12. data/lib/tarantool/light_record.rb +17 -0
  13. data/lib/tarantool/query.rb +15 -9
  14. data/lib/tarantool/record/select.rb +21 -3
  15. data/lib/tarantool/request.rb +130 -43
  16. data/lib/tarantool/response.rb +70 -7
  17. data/lib/tarantool/serializers.rb +26 -5
  18. data/lib/tarantool/serializers/ber_array.rb +14 -0
  19. data/lib/tarantool/shards_support.rb +204 -0
  20. data/lib/tarantool/space_array.rb +38 -13
  21. data/lib/tarantool/space_hash.rb +49 -27
  22. data/lib/tarantool/util.rb +96 -10
  23. data/lib/tarantool/version.rb +2 -1
  24. data/test/helper.rb +154 -4
  25. data/test/{tarant/init.lua → init.lua} +0 -0
  26. data/test/run_all.rb +2 -2
  27. data/test/shared_record.rb +59 -0
  28. data/test/shared_replicated_shard.rb +1018 -0
  29. data/test/shared_reshard.rb +380 -0
  30. data/test/tarantool.cfg +2 -0
  31. data/test/test_light_record.rb +2 -0
  32. data/test/test_light_record_callback.rb +92 -0
  33. data/test/test_query_block.rb +1 -0
  34. data/test/test_query_fiber.rb +1 -0
  35. data/test/test_reshard_block.rb +7 -0
  36. data/test/test_reshard_fiber.rb +11 -0
  37. data/test/test_shard_replication_block.rb +7 -0
  38. data/test/test_shard_replication_fiber.rb +11 -0
  39. data/test/test_space_array_block.rb +1 -0
  40. data/test/test_space_array_callback.rb +50 -121
  41. data/test/test_space_array_callback_nodef.rb +39 -96
  42. data/test/test_space_array_fiber.rb +1 -0
  43. data/test/test_space_hash_block.rb +1 -0
  44. data/test/test_space_hash_fiber.rb +1 -0
  45. metadata +54 -17
  46. data/lib/tarantool/record.rb +0 -164
  47. data/test/box.pid +0 -1
  48. data/test/tarantool.log +0 -6
  49. data/test/tarantool_repl.cfg +0 -53
  50. data/test/test_record.rb +0 -88
  51. data/test/test_record_composite_pk.rb +0 -77
@@ -1,6 +1,7 @@
1
1
  require File.expand_path('../shared_space_array.rb', __FILE__)
2
2
 
3
3
  describe 'Tarantool::FiberDB::SpaceArray' do
4
+ before { TConf.run(:master1) }
4
5
  let(:tarantool) { Tarantool.new(TCONFIG.merge(type: :block)) }
5
6
  it_behaves_like :blocking_array_space
6
7
  end
@@ -1,6 +1,7 @@
1
1
  require File.expand_path('../shared_query.rb', __FILE__)
2
2
 
3
3
  describe 'Tarantool::FiberDB::Query' do
4
+ before { TConf.run(:master1) }
4
5
  let(:tarantool) { Tarantool.new(TCONFIG.merge(type: :em)) }
5
6
  alias blockrun fibrun
6
7
  it_behaves_like :blocking_query
@@ -0,0 +1,7 @@
1
+ require File.expand_path('../shared_reshard.rb', __FILE__)
2
+
3
+ describe "Resharding with blocking connection" do
4
+ let(:tarantool_type){ :block }
5
+ def bsleep(sec) sleep(sec) end
6
+ it_behaves_like 'resharding'
7
+ end
@@ -0,0 +1,11 @@
1
+ require File.expand_path('../shared_reshard.rb', __FILE__)
2
+
3
+ describe "Resharding with fibered connection" do
4
+ let(:tarantool_type){ :em_fiber }
5
+ alias blockrun fibrun
6
+ def bsleep(sec)
7
+ EM.add_timer(sec, Fiber.current)
8
+ Fiber.yield
9
+ end
10
+ it_behaves_like 'resharding'
11
+ end
@@ -0,0 +1,7 @@
1
+ require File.expand_path('../shared_replicated_shard.rb', __FILE__)
2
+
3
+ describe "Replication Shard with blocking connection" do
4
+ let(:tarantool_type){ :block }
5
+ def bsleep(sec) sleep(sec) end
6
+ it_behaves_like 'replication and shards'
7
+ end
@@ -0,0 +1,11 @@
1
+ require File.expand_path('../shared_replicated_shard.rb', __FILE__)
2
+
3
+ describe "Replication Shard with fibered connection" do
4
+ let(:tarantool_type){ :em_fiber }
5
+ alias blockrun fibrun
6
+ def bsleep(sec)
7
+ EM.add_timer(sec, Fiber.current)
8
+ Fiber.yield
9
+ end
10
+ it_behaves_like 'replication and shards'
11
+ end
@@ -1,6 +1,7 @@
1
1
  require File.expand_path('../shared_space_array.rb', __FILE__)
2
2
 
3
3
  describe 'Tarantool::BlockDB::SpaceArray' do
4
+ before { TConf.run(:master1) }
4
5
  let(:tarantool) { Tarantool.new(TCONFIG.merge(type: :block)) }
5
6
  it_behaves_like :blocking_array_space
6
7
  end
@@ -1,6 +1,7 @@
1
1
  require File.expand_path('../helper.rb', __FILE__)
2
2
 
3
3
  describe 'Tarantool::CallbackDB::SpaceArray' do
4
+ before { TConf.run(:master1) }
4
5
  before { clear_db }
5
6
 
6
7
  let(:tarantool) { Tarantool.new(TCONFIG.merge(type: :em_callback)) }
@@ -13,31 +14,16 @@ describe 'Tarantool::CallbackDB::SpaceArray' do
13
14
  let(:ilya) { ['ilya', 'zimov', 'il@zi.bot', 13] }
14
15
  let(:fedor){ ['fedor', 'kuklin', 'ku@kl.in', 13] }
15
16
  it "should be selectable" do
16
- results = []
17
17
  emrun(8) {
18
- space0.select(0, 'vasya'){|res| results[0] = res; emstop}
19
- space0.select(0, ['vasya']){|res| results[1] = res; emstop}
20
- space0.select(0, ['vasya', 'ilya']){|res|
21
- results[2] = res; emstop
22
- }
23
- space0.select(0, [['vasya'], ['ilya']]){|res|
24
- results[3] = res; emstop
25
- }
26
- space0.select(0, [['ilya'], ['vasya']]){|res|
27
- results[4] = res; emstop
28
- }
29
- space0.select(0, [['ilya'], ['vasya']], 0, 1){|res|
30
- results[5] = res; emstop
31
- }
32
- space0.select(0, [['ilya'], ['vasya']], 1, 1){|res|
33
- results[6] = res; emstop
34
- }
35
- space0.select(2, 13, 0, 2){|res|
36
- results[7] = res; emstop
37
- }
38
- space0.select(1, [['zimov','il@zi.bot']]){|res|
39
- results[8] = res; emstop
40
- }
18
+ space0.select(0, 'vasya', &setp(0))
19
+ space0.select(0, ['vasya'], &setp(1))
20
+ space0.select(0, ['vasya', 'ilya'], &setp(2))
21
+ space0.select(0, [['vasya'], ['ilya']], &setp(3))
22
+ space0.select(0, [['ilya'], ['vasya']], &setp(4))
23
+ space0.select(0, [['ilya'], ['vasya']], 0, 1, &setp(5))
24
+ space0.select(0, [['ilya'], ['vasya']], 1, 1, &setp(6))
25
+ space0.select(2, 13, 0, 2, &setp(7))
26
+ space0.select(1, [['zimov','il@zi.bot']], &setp(8))
41
27
  }
42
28
  results[0].must_equal [vasya]
43
29
  results[1].must_equal [vasya]
@@ -51,29 +37,16 @@ describe 'Tarantool::CallbackDB::SpaceArray' do
51
37
  end
52
38
 
53
39
  it "should be able to all_by_keys" do
54
- results = []
55
40
  emrun(8) {
56
- space0.all_by_keys(0, 'vasya'){|res| results[0] = res; emstop}
57
- space0.all_by_keys(0, ['vasya']){|res| results[1] = res; emstop}
58
- space0.all_by_keys(0, ['vasya', 'ilya']){|res|
59
- results[2] = res; emstop
60
- }
61
- space0.all_by_keys(0, [['vasya'], ['ilya']]){|res|
62
- results[3] = res; emstop
63
- }
64
- space0.all_by_keys(0, [['ilya'], ['vasya']]){|res|
65
- results[4] = res; emstop
66
- }
67
- space0.all_by_keys(0, [['ilya'], ['vasya']], limit: 1){|res|
68
- results[5] = res; emstop
69
- }
70
- space0.all_by_keys(0, [['ilya'], ['vasya']], limit: 1, offset: 1){|res|
71
- results[6] = res; emstop
72
- }
73
- space0.all_by_keys(2, 13){|res| results[7] = res; emstop }
74
- space0.all_by_keys(1, [['zimov','il@zi.bot']]){|res|
75
- results[8] = res; emstop
76
- }
41
+ space0.all_by_keys(0, 'vasya', &setp(0))
42
+ space0.all_by_keys(0, ['vasya'], &setp(1))
43
+ space0.all_by_keys(0, ['vasya', 'ilya'], &setp(2))
44
+ space0.all_by_keys(0, [['vasya'], ['ilya']], &setp(3))
45
+ space0.all_by_keys(0, [['ilya'], ['vasya']], &setp(4))
46
+ space0.all_by_keys(0, [['ilya'], ['vasya']], limit: 1, &setp(5))
47
+ space0.all_by_keys(0, [['ilya'], ['vasya']], limit: 1, offset: 1, &setp(6))
48
+ space0.all_by_keys(2, 13, &setp(7))
49
+ space0.all_by_keys(1, [['zimov','il@zi.bot']], &setp(8))
77
50
  }
78
51
  results[0].must_equal [vasya]
79
52
  results[1].must_equal [vasya]
@@ -87,14 +60,11 @@ describe 'Tarantool::CallbackDB::SpaceArray' do
87
60
  end
88
61
 
89
62
  it "should be able to all_by_key" do
90
- results = []
91
63
  emrun(4) {
92
- space0.all_by_key(0, 'vasya'){|res| results[0] = res; emstop}
93
- space0.all_by_key(0, ['vasya']){|res| results[1] = res; emstop}
94
- space0.all_by_key(2, 13){|res| results[2] = res; emstop }
95
- space0.all_by_key(1, ['zimov','il@zi.bot']){|res|
96
- results[3] = res; emstop
97
- }
64
+ space0.all_by_key(0, 'vasya', &setp(0))
65
+ space0.all_by_key(0, ['vasya'], &setp(1))
66
+ space0.all_by_key(2, 13, &setp(2))
67
+ space0.all_by_key(1, ['zimov','il@zi.bot'], &setp(3))
98
68
  }
99
69
  results[0].must_equal [vasya]
100
70
  results[1].must_equal [vasya]
@@ -103,14 +73,11 @@ describe 'Tarantool::CallbackDB::SpaceArray' do
103
73
  end
104
74
 
105
75
  it "should be able to first_by_key" do
106
- results = []
107
76
  emrun(4) {
108
- space0.first_by_key(0, 'vasya'){|res| results[0] = res; emstop}
109
- space0.first_by_key(0, ['ilya']){|res| results[1] = res; emstop}
110
- space0.first_by_key(2, 13){|res| results[2] = res; emstop }
111
- space0.first_by_key(1, ['petrov','eb@lo.com']){|res|
112
- results[3] = res; emstop
113
- }
77
+ space0.first_by_key(0, 'vasya', &setp(0))
78
+ space0.first_by_key(0, ['ilya'], &setp(1))
79
+ space0.first_by_key(2, 13, &setp(2))
80
+ space0.first_by_key(1, ['petrov','eb@lo.com'], &setp(3))
114
81
  }
115
82
  results[0].must_equal vasya
116
83
  results[1].must_equal ilya
@@ -119,13 +86,10 @@ describe 'Tarantool::CallbackDB::SpaceArray' do
119
86
  end
120
87
 
121
88
  it "should be able to by_pk" do
122
- results = []
123
89
  emrun(3) {
124
- space0.by_pk('vasya'){|res| results[0] = res; emstop}
125
- space0.by_pk(['ilya']){|res| results[1] = res; emstop}
126
- space2.by_pk(['hi zo', 'ho zo']){|res|
127
- results[2] = res; emstop
128
- }
90
+ space0.by_pk('vasya', &setp(0))
91
+ space0.by_pk(['ilya'], &setp(1))
92
+ space2.by_pk(['hi zo', 'ho zo'], &setp(2))
129
93
  }
130
94
  results[0].must_equal vasya
131
95
  results[1].must_equal ilya
@@ -135,38 +99,33 @@ describe 'Tarantool::CallbackDB::SpaceArray' do
135
99
  it "should raise on not matched pk" do
136
100
  proc {
137
101
  emrun(1) {
138
- space0.by_pk(['il','ya']){|res| assert false; emstop }
102
+ space0.by_pk(['il','ya']){}
139
103
  }
140
104
  }.must_raise Tarantool::ArgumentError
141
105
  end
142
106
 
143
107
  it "should fetch longer records" do
144
- results = []
145
108
  emrun(2) {
146
- space2.by_pk(['hi zo', 'pidas']){|res| results[0] = res; emstop}
147
- space1.by_pk(2){|res| results[1] = res; emstop}
109
+ space2.by_pk(['hi zo', 'pidas'], &setp(0))
110
+ space1.by_pk(2, &setp(1))
148
111
  }
149
112
  results[0].must_equal ['hi zo', 'pidas', 1, 3, 5]
150
113
  results[1].must_equal [2, 'medium', 6, 'common', 7]
151
114
  end
152
115
 
153
116
  it "should be able to insert" do
154
- results = []
155
117
  asdf = ['asdf', 'asdf', 'asdf', 4, 5]
156
118
  qwer = ['qwer', 'qwer', 'qwer', 4, 20, 19]
157
119
  zxcv = [4, 'zxcv', 7, 'zxcv', 8]
158
120
  xcvb = [5, 'xcvb', 7, 'xcvb', 8]
159
121
  emrun(4) {
160
- space0.insert(asdf){|res| results[0] = res; emstop}
161
- space0.insert(qwer, return_tuple: true){|res| results[1] = res; emstop }
122
+ space0.insert(asdf, &setp(0))
123
+ space0.insert(qwer, return_tuple: true, &setp(1))
162
124
  space1.insert(zxcv){|res|
163
125
  results[2] = res
164
- space1.by_pk(4){|res|
165
- results[3] = res
166
- emstop
167
- }
126
+ space1.by_pk(4, &setp(3))
168
127
  }
169
- space1.insert(xcvb, return_tuple: true){|res| results[4] = res; emstop }
128
+ space1.insert(xcvb, return_tuple: true, &setp(4))
170
129
  }
171
130
  results[0].must_equal 1
172
131
  results[1].must_equal qwer
@@ -176,34 +135,18 @@ describe 'Tarantool::CallbackDB::SpaceArray' do
176
135
  end
177
136
 
178
137
  it "should be able to update" do
179
- results = []
180
138
  emrun(6) {
181
- space0.update('vasya', {1 => 'holodov', 3 => [:+, 2]}, return_tuple: true){|res|
182
- results[0] = res; emstop
183
- }
184
- space0.update('ilya', {[2, :set] => 'we@al.hero', 3 => [:&, 7]}, return_tuple: true){|res|
185
- results[1] = res; emstop
186
- }
139
+ space0.update('vasya', {1 => 'holodov', 3 => [:+, 2]}, return_tuple: true, &setp(0))
140
+ space0.update('ilya', {[2, :set] => 'we@al.hero', 3 => [:&, 7]}, return_tuple: true, &setp(1))
187
141
  space1.update(2, [[2, :^, 3], [4, :|, 20]]){|res|
188
142
  results[2] = res
189
- space1.by_pk(2){|res|
190
- results[3] = res; emstop
191
- }
192
- }
193
- space1.update(1, [1, :splice, 2, 2, 'nd'], return_tuple: true){|res|
194
- results[4] = res
195
- emstop
196
- }
197
- space2.update(['hi zo', 'pidas'], [[2, :delete], [3, :delete]], return_tuple: true){|res|
198
- results[5] = res
199
- emstop
143
+ space1.by_pk(2, &setp(3))
200
144
  }
145
+ space1.update(1, [1, :splice, 2, 2, 'nd'], return_tuple: true, &setp(4))
146
+ space2.update(['hi zo', 'pidas'], [[2, :delete], [3, :delete]], return_tuple: true, &setp(5))
201
147
  space2.update(['coma', 'peredoma'], [2, :insert, 1]){|res|
202
148
  results[6] = res
203
- space2.all_by_key(1, 1){|res|
204
- results[7] = res
205
- emstop
206
- }
149
+ space2.all_by_key(1, 1, &setp(7))
207
150
  }
208
151
  }
209
152
  results[0].must_equal ['vasya', 'holodov', 'eb@lo.com', 7]
@@ -214,17 +157,10 @@ describe 'Tarantool::CallbackDB::SpaceArray' do
214
157
  end
215
158
 
216
159
  it "should be able to delete" do
217
- results = []
218
160
  emrun(3) {
219
- space0.delete('vasya', return_tuple: true){|res|
220
- results[0] = res; emstop
221
- }
222
- space1.delete([1], return_tuple: true){|res|
223
- results[1] = res; emstop
224
- }
225
- space2.delete(['hi zo', 'pidas'], return_tuple: true){|res|
226
- results[2] = res; emstop
227
- }
161
+ space0.delete('vasya', return_tuple: true, &setp(0))
162
+ space1.delete([1], return_tuple: true, &setp(1))
163
+ space2.delete(['hi zo', 'pidas'], return_tuple: true, &setp(2))
228
164
  }
229
165
  results[0].must_equal vasya
230
166
  results[1].must_equal [1, 'common', 4]
@@ -232,18 +168,11 @@ describe 'Tarantool::CallbackDB::SpaceArray' do
232
168
  end
233
169
 
234
170
  it "should be able to choose index by field numbers" do
235
- results = []
236
171
  emrun(4) {
237
- space0.first_by_key([0], 'vasya'){|res| results[0] = res; emstop}
238
- space0.first_by_key([1,2], ['zimov', 'il@zi.bot']){|res|
239
- results[1] = res; emstop
240
- }
241
- space0.all_by_key([3], 13){|res|
242
- results[2] = res; emstop
243
- }
244
- space2.first_by_key([1,0], ['peredoma', 'coma']){|res|
245
- results[3] = res; emstop
246
- }
172
+ space0.first_by_key([0], 'vasya', &setp(0))
173
+ space0.first_by_key([1,2], ['zimov', 'il@zi.bot'], &setp(1))
174
+ space0.all_by_key([3], 13, &setp(2))
175
+ space2.first_by_key([1,0], ['peredoma', 'coma'], &setp(3))
247
176
  }
248
177
  results[0].must_equal vasya
249
178
  results[1].must_equal ilya
@@ -1,6 +1,7 @@
1
1
  require File.expand_path('../helper.rb', __FILE__)
2
2
 
3
3
  describe 'Tarantool::CallbackDB::SpaceArray' do
4
+ before { TConf.run(:master1) }
4
5
  before { clear_db }
5
6
 
6
7
  let(:tarantool) { Tarantool.new(TCONFIG.merge(type: :em_callback)) }
@@ -13,34 +14,17 @@ describe 'Tarantool::CallbackDB::SpaceArray' do
13
14
  let(:_ilya) { %W{ilya zimov il@zi.bot}+[13] }
14
15
  let(:_fedor){ %W{fedor kuklin ku@kl.in}+[13] }
15
16
  it "should be selectable" do
16
- results = []
17
17
  emrun(8) {
18
- clear_space.select(0, 'vasya'){|res| results[0] = res; emstop}
19
- clear_space.select(0, ['vasya']){|res| results[1] = res; emstop}
20
- clear_space.select(0, ['vasya', 'ilya']){|res|
21
- results[2] = res; emstop
22
- }
23
- clear_space.select(0, [['vasya'], ['ilya']]){|res|
24
- results[3] = res; emstop
25
- }
26
- clear_space.select(0, [['ilya'], ['vasya']]){|res|
27
- results[4] = res; emstop
28
- }
29
- clear_space.select(0, [['ilya'], ['vasya']], 0, 1){|res|
30
- results[5] = res; emstop
31
- }
32
- clear_space.select(0, [['ilya'], ['vasya']], 1, 1){|res|
33
- results[6] = res; emstop
34
- }
35
- clear_space.select(2, "\x0D\x00\x00\x00", 0, 2){|res|
36
- results[7] = res; emstop
37
- }
38
- clear_space.select(2, 13, 0, 2){|res|
39
- results[8] = res; emstop
40
- }
41
- clear_space.select(1, [['zimov','il@zi.bot']]){|res|
42
- results[9] = res; emstop
43
- }
18
+ clear_space.select(0, 'vasya', &setp(0))
19
+ clear_space.select(0, ['vasya'], &setp(1))
20
+ clear_space.select(0, ['vasya', 'ilya'], &setp(2))
21
+ clear_space.select(0, [['vasya'], ['ilya']], &setp(3))
22
+ clear_space.select(0, [['ilya'], ['vasya']], &setp(4))
23
+ clear_space.select(0, [['ilya'], ['vasya']], 0, 1, &setp(5))
24
+ clear_space.select(0, [['ilya'], ['vasya']], 1, 1, &setp(6))
25
+ clear_space.select(2, "\x0D\x00\x00\x00", 0, 2, &setp(7))
26
+ clear_space.select(2, 13, 0, 2, &setp(8))
27
+ clear_space.select(1, [['zimov','il@zi.bot']], &setp(9))
44
28
  }
45
29
  results[0].must_equal [vasya]
46
30
  results[1].must_equal [vasya]
@@ -58,34 +42,17 @@ describe 'Tarantool::CallbackDB::SpaceArray' do
58
42
  end
59
43
 
60
44
  it "should be able to all_by_keys" do
61
- results = []
62
45
  emrun(8) {
63
- clear_space.all_by_keys(0, 'vasya'){|res| results[0] = res; emstop}
64
- clear_space.all_by_keys(0, ['vasya']){|res| results[1] = res; emstop}
65
- clear_space.all_by_keys(0, ['vasya', 'ilya']){|res|
66
- results[2] = res; emstop
67
- }
68
- clear_space.all_by_keys(0, [['vasya'], ['ilya']]){|res|
69
- results[3] = res; emstop
70
- }
71
- clear_space.all_by_keys(0, [['ilya'], ['vasya']]){|res|
72
- results[4] = res; emstop
73
- }
74
- clear_space.all_by_keys(0, [['ilya'], ['vasya']], limit: 1){|res|
75
- results[5] = res; emstop
76
- }
77
- clear_space.all_by_keys(0, [['ilya'], ['vasya']], limit: 1, offset: 1){|res|
78
- results[6] = res; emstop
79
- }
80
- clear_space.all_by_keys(2, "\x0D\x00\x00\x00"){|res|
81
- results[7] = res; emstop
82
- }
83
- clear_space.all_by_keys(2, 13){|res|
84
- results[8] = res; emstop
85
- }
86
- clear_space.all_by_keys(1, [['zimov','il@zi.bot']]){|res|
87
- results[9] = res; emstop
88
- }
46
+ clear_space.all_by_keys(0, 'vasya', &setp(0))
47
+ clear_space.all_by_keys(0, ['vasya'], &setp(1))
48
+ clear_space.all_by_keys(0, ['vasya', 'ilya'], &setp(2))
49
+ clear_space.all_by_keys(0, [['vasya'], ['ilya']], &setp(3))
50
+ clear_space.all_by_keys(0, [['ilya'], ['vasya']], &setp(4))
51
+ clear_space.all_by_keys(0, [['ilya'], ['vasya']], limit: 1, &setp(5))
52
+ clear_space.all_by_keys(0, [['ilya'], ['vasya']], limit: 1, offset: 1, &setp(6))
53
+ clear_space.all_by_keys(2, "\x0D\x00\x00\x00", &setp(7))
54
+ clear_space.all_by_keys(2, 13, &setp(8))
55
+ clear_space.all_by_keys(1, [['zimov','il@zi.bot']], &setp(9))
89
56
  }
90
57
  results[0].must_equal [vasya]
91
58
  results[1].must_equal [vasya]
@@ -100,16 +67,11 @@ describe 'Tarantool::CallbackDB::SpaceArray' do
100
67
  end
101
68
 
102
69
  it "should be able to all_by_key" do
103
- results = []
104
70
  emrun(4) {
105
- clear_space.all_by_key(0, 'vasya'){|res| results[0] = res; emstop}
106
- clear_space.all_by_key(0, ['vasya']){|res| results[1] = res; emstop}
107
- clear_space.all_by_key(2, "\x0D\x00\x00\x00"){|res|
108
- results[2] = res; emstop
109
- }
110
- clear_space.all_by_key(1, ['zimov','il@zi.bot']){|res|
111
- results[3] = res; emstop
112
- }
71
+ clear_space.all_by_key(0, 'vasya', &setp(0))
72
+ clear_space.all_by_key(0, ['vasya'], &setp(1))
73
+ clear_space.all_by_key(2, "\x0D\x00\x00\x00", &setp(2))
74
+ clear_space.all_by_key(1, ['zimov','il@zi.bot'], &setp(3))
113
75
  }
114
76
  results[0].must_equal [vasya]
115
77
  results[1].must_equal [vasya]
@@ -118,16 +80,11 @@ describe 'Tarantool::CallbackDB::SpaceArray' do
118
80
  end
119
81
 
120
82
  it "should be able to first_by_key" do
121
- results = []
122
83
  emrun(4) {
123
- clear_space.first_by_key(0, 'vasya'){|res| results[0] = res; emstop}
124
- clear_space.first_by_key(0, ['ilya']){|res| results[1] = res; emstop}
125
- clear_space.first_by_key(2, "\x0D\x00\x00\x00"){|res|
126
- results[2] = res; emstop
127
- }
128
- clear_space.first_by_key(1, ['petrov','eb@lo.com']){|res|
129
- results[3] = res; emstop
130
- }
84
+ clear_space.first_by_key(0, 'vasya', &setp(0))
85
+ clear_space.first_by_key(0, ['ilya'], &setp(1))
86
+ clear_space.first_by_key(2, "\x0D\x00\x00\x00", &setp(2))
87
+ clear_space.first_by_key(1, ['petrov','eb@lo.com'], &setp(3))
131
88
  }
132
89
  results[0].must_equal vasya
133
90
  results[1].must_equal ilya
@@ -136,13 +93,10 @@ describe 'Tarantool::CallbackDB::SpaceArray' do
136
93
  end
137
94
 
138
95
  it "should be able to by_pk" do
139
- results = []
140
96
  emrun(3) {
141
- clear_space.by_pk('vasya'){|res| results[0] = res; emstop}
142
- clear_space.by_pk(['ilya']){|res| results[1] = res; emstop}
143
- tarantool.space_array(2).by_pk(['hi zo', 'ho zo']){|res|
144
- results[2] = res; emstop
145
- }
97
+ clear_space.by_pk('vasya', &setp(0))
98
+ clear_space.by_pk(['ilya'], &setp(1))
99
+ tarantool.space_array(2).by_pk(['hi zo', 'ho zo'], &setp(2))
146
100
  }
147
101
  results[0].must_equal vasya
148
102
  results[1].must_equal ilya
@@ -150,15 +104,10 @@ describe 'Tarantool::CallbackDB::SpaceArray' do
150
104
  end
151
105
 
152
106
  it "should be able to insert" do
153
- results = []
154
107
  emrun(2) {
155
- clear_space.insert(%w{asdf asdf asdf asdf asdf}){|res| results[0] = res; emstop}
156
- clear_space.insert(%w{qwer qwer qwer qwer qwer}, return_tuple: true){|res|
157
- results[1] = res; emstop
158
- }
159
- clear_space.insert([1,2,3,4,5], return_tuple: true){|res|
160
- results[2] = res; emstop
161
- }
108
+ clear_space.insert(%w{asdf asdf asdf asdf asdf}, &setp(0))
109
+ clear_space.insert(%w{qwer qwer qwer qwer qwer}, return_tuple: true, &setp(1))
110
+ clear_space.insert([1,2,3,4,5], return_tuple: true, &setp(2))
162
111
  }
163
112
  results[0].must_equal 1
164
113
  results[1].must_equal %w{qwer qwer qwer qwer qwer}
@@ -166,20 +115,14 @@ describe 'Tarantool::CallbackDB::SpaceArray' do
166
115
  end
167
116
 
168
117
  it "should be able to update" do
169
- results = []
170
118
  emrun(3) {
171
119
  clear_space.update('vasya', {
172
120
  1 => 'korkov',
173
121
  2 => ['set', 'no@mo.re'],
174
- 3 => ['add', 1]}, return_tuple: true){|res|
175
- results[0] = res; emstop
176
- }
177
- clear_space.update('ilya', {'&3' => 12}, return_tuple: true){|res|
178
- results[1] = res; emstop
179
- }
180
- clear_space.update('fedor', {'|3' => 3}, return_tuple: true){|res|
181
- results[2] = res; emstop
182
- }
122
+ 3 => ['add', 1]}, return_tuple: true,
123
+ &setp(0))
124
+ clear_space.update('ilya', {'&3' => 12}, return_tuple: true, &setp(1))
125
+ clear_space.update('fedor', {'|3' => 3}, return_tuple: true, &setp(2))
183
126
  }
184
127
  results[0].must_equal %W{vasya korkov no@mo.re \x06\x00\x00\x00}
185
128
  results[1].must_equal %W{ilya zimov il@zi.bot \x0C\x00\x00\x00}