tarantool 0.5.5.1 → 0.5.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a2ba9359cf06075c2df1253f0b5ea50b0d154871
4
- data.tar.gz: d224be6e4900c2b6c400e58ad00b66c4c6fb1cd3
3
+ metadata.gz: 8aac164a2c5b7dea301ff686ce276e3e25e95ba2
4
+ data.tar.gz: aabe618a99624fec57ee6473ff153f7bb5f5a453
5
5
  SHA512:
6
- metadata.gz: 5f12001871eba01ab75d1a9eb9e9a4892141009efe6c88aa43a47a7c9ad7066b24860479e1ea71cdf6a9ff84cfb33081f5b136e452f0113827daff14677a0e1b
7
- data.tar.gz: fd7f23675481a2e8daeb36f44a3aefed5d8c5fa28d53f2b6b9f941fc9638e66cd4040b73f5aa4fd0927c76615721164246caf19909a100ff7315ba3ab15b721f
6
+ metadata.gz: 7f1d95caea8a114a6381b04369e9d365a10bb69cee65e7bbc4b8fb07bb76baa6e5dc42ca21dd6027a1599b94617049abc411d04193e084b9fea2a83b7846c0f7
7
+ data.tar.gz: 03a5848ccb38582768f5a017337b8154a39277e23e9875a76b1f949b2b158d19d4a05229ba5c55b25d11009a97bb8c3b4f00a6a449a50aed75caf1ba59e4d617
@@ -103,12 +103,11 @@ static VALUE
103
103
  unpack_field(VALUE self, VALUE data, VALUE field, VALUE i_o, VALUE realfield_o, VALUE serializers)
104
104
  {
105
105
  int i = NUM2INT(i_o);
106
- const char *str = StringValuePtr(data);
106
+ const char *str = RSTRING_PTR(data);
107
107
  size_t len = RSTRING_LEN(data);
108
108
  size_t fieldsize = slice_ber((const uint8_t**)&str, &len);
109
109
  VALUE value;
110
- rb_str_drop_bytes(data, RSTRING_LEN(data) - len);
111
- str = StringValuePtr(data);
110
+ size_t offset = RSTRING_LEN(data) - len;
112
111
 
113
112
  if (fieldsize == 0) {
114
113
  return Qnil;
@@ -190,7 +189,7 @@ unpack_field(VALUE self, VALUE data, VALUE field, VALUE i_o, VALUE realfield_o,
190
189
  }
191
190
  value = rb_funcall2(serializer, id_decode, 1, &substr);
192
191
  }
193
- rb_str_drop_bytes(data, fieldsize);
192
+ rb_str_drop_bytes(data, offset + fieldsize);
194
193
  return value;
195
194
  }
196
195
 
@@ -4,14 +4,86 @@ require 'tarantool/serializers'
4
4
 
5
5
  module Tarantool
6
6
  module UnpackTuples
7
- end
8
- begin
9
- require 'tarantool/response_c'
10
- rescue LoadError
7
+ include Util::Packer
8
+ include Util::TailGetter
9
+ UTF8 = 'utf-8'.freeze
10
+ def _unpack_field(tuple_str, field, i, realfield, serializers)
11
+ field_size = ::BinUtils.slice_ber!(tuple_str)
12
+ return nil if field_size == 0
13
+
14
+ case field
15
+ when :int, :integer
16
+ if field_size != 4
17
+ raise ValueError, "Bad field size #{field_size} for integer field ##{i}"
18
+ end
19
+ ::BinUtils.slice_int32_le!(tuple_str)
20
+ when :string, :str
21
+ str = tuple_str.slice!(0, field_size)
22
+ str[0,1] = EMPTY if str < ONE
23
+ str.force_encoding(UTF8)
24
+ when :int64
25
+ if field_size != 8
26
+ raise ValueError, "Bad field size #{field_size} for 64bit integer field ##{i}"
27
+ end
28
+ ::BinUtils.slice_int64_le!(tuple_str)
29
+ when :bytes
30
+ tuple_str.slice!(0, field_size)
31
+ when :int16
32
+ if field_size != 2
33
+ raise ValueError, "Bad field size #{field_size} for 16bit integer field ##{i}"
34
+ end
35
+ ::BinUtils.slice_int16_le!(tuple_str)
36
+ when :int8
37
+ if field_size != 1
38
+ raise ValueError, "Bad field size #{field_size} for 8bit integer field ##{i}"
39
+ end
40
+ ::BinUtils.slice_int8!(tuple_str)
41
+ when :sint
42
+ if field_size != 4
43
+ raise ValueError, "Bad field size #{field_size} for integer field ##{i}"
44
+ end
45
+ ::BinUtils.slice_sint32_le!(tuple_str)
46
+ when :sint64
47
+ if field_size != 8
48
+ raise ValueError, "Bad field size #{field_size} for 64bit integer field ##{i}"
49
+ end
50
+ ::BinUtils.slice_sint64_le!(tuple_str)
51
+ when :sint16
52
+ if field_size != 2
53
+ raise ValueError, "Bad field size #{field_size} for 16bit integer field ##{i}"
54
+ end
55
+ ::BinUtils.slice_sint16_le!(tuple_str)
56
+ when :sint8
57
+ if field_size != 1
58
+ raise ValueError, "Bad field size #{field_size} for 8bit integer field ##{i}"
59
+ end
60
+ ::BinUtils.slice_sint8!(tuple_str)
61
+ when :varint
62
+ case field_size
63
+ when 8
64
+ ::BinUtils.slice_int64_le!(tuple_str)
65
+ when 4
66
+ ::BinUtils.slice_int32_le!(tuple_str)
67
+ when 2
68
+ ::BinUtils.slice_int16_le!(tuple_str)
69
+ else
70
+ raise ValueError, "Bad field size #{field_size} for integer field ##{i}"
71
+ end
72
+ when :auto
73
+ str = tuple_str.slice!(0, field_size).force_encoding('utf-8')
74
+ case field_size
75
+ when 8, 4, 2
76
+ Util::AutoType.new(str)
77
+ else
78
+ str
79
+ end
80
+ else
81
+ (serializers[realfield] ||= get_serializer(field)).decode(tuple_str.slice!(0, field_size))
82
+ end
83
+ end
11
84
  end
12
85
 
13
86
  module ParseIProto
14
- include Util::Packer
15
87
  def _parse_iproto(data)
16
88
  if Exception === data || data == ''
17
89
  data
@@ -25,11 +97,8 @@ module Tarantool
25
97
  end
26
98
 
27
99
  class Response < Struct.new(:cb, :request_type, :body, :get_tuples, :fields, :translators)
28
- include Util::Packer
29
- include Util::TailGetter
30
100
  include Serializers
31
101
  include UnpackTuples
32
- UTF8 = 'utf-8'.freeze
33
102
 
34
103
  def call(data)
35
104
  if Exception === data
@@ -73,9 +142,9 @@ module Tarantool
73
142
  end
74
143
  end
75
144
 
76
- X02 = '%02x'.freeze
77
145
  def unpack_tuples(data)
78
146
  tuples_affected = ::BinUtils.slice_int32_le!(data)
147
+ ta = tuples_affected
79
148
  fields = fields()
80
149
  if Integer === fields.last
81
150
  *fields, tail = fields
@@ -102,86 +171,11 @@ module Tarantool
102
171
  end
103
172
  tuples
104
173
  rescue ValueError => e
105
- $stderr.puts "Value Error: tuples=#{tuples_affected}, data='#{orig_data.each_byte.map{|b| format(X02, b)}.join(' ')}'"
174
+ $stderr.puts "Value Error: tuples=#{ta} now=#{ta-tuples_affected}, remains=#{data.bytesize} remains_data='#{data.unpack('H*')[0].gsub(/../,'\& ')}' orig_size=#{orig_data.size} orig_data='#{orig_data.unpack('H*')[0].gsub(/../,'\& ')}'"
106
175
  raise e
107
176
  end
108
177
  end
109
178
 
110
- def _unpack_field(tuple_str, field, i, realfield, serializers)
111
- field_size = ::BinUtils.slice_ber!(tuple_str)
112
- return nil if field_size == 0
113
-
114
- case field
115
- when :int, :integer
116
- if field_size != 4
117
- raise ValueError, "Bad field size #{field_size} for integer field ##{i}"
118
- end
119
- ::BinUtils.slice_int32_le!(tuple_str)
120
- when :string, :str
121
- str = tuple_str.slice!(0, field_size)
122
- str[0,1] = EMPTY if str < ONE
123
- str.force_encoding(UTF8)
124
- when :int64
125
- if field_size != 8
126
- raise ValueError, "Bad field size #{field_size} for 64bit integer field ##{i}"
127
- end
128
- ::BinUtils.slice_int64_le!(tuple_str)
129
- when :bytes
130
- tuple_str.slice!(0, field_size)
131
- when :int16
132
- if field_size != 2
133
- raise ValueError, "Bad field size #{field_size} for 16bit integer field ##{i}"
134
- end
135
- ::BinUtils.slice_int16_le!(tuple_str)
136
- when :int8
137
- if field_size != 1
138
- raise ValueError, "Bad field size #{field_size} for 8bit integer field ##{i}"
139
- end
140
- ::BinUtils.slice_int8!(tuple_str)
141
- when :sint
142
- if field_size != 4
143
- raise ValueError, "Bad field size #{field_size} for integer field ##{i}"
144
- end
145
- ::BinUtils.slice_sint32_le!(tuple_str)
146
- when :sint64
147
- if field_size != 8
148
- raise ValueError, "Bad field size #{field_size} for 64bit integer field ##{i}"
149
- end
150
- ::BinUtils.slice_sint64_le!(tuple_str)
151
- when :sint16
152
- if field_size != 2
153
- raise ValueError, "Bad field size #{field_size} for 16bit integer field ##{i}"
154
- end
155
- ::BinUtils.slice_sint16_le!(tuple_str)
156
- when :sint8
157
- if field_size != 1
158
- raise ValueError, "Bad field size #{field_size} for 8bit integer field ##{i}"
159
- end
160
- ::BinUtils.slice_sint8!(tuple_str)
161
- when :varint
162
- case field_size
163
- when 8
164
- ::BinUtils.slice_int64_le!(tuple_str)
165
- when 4
166
- ::BinUtils.slice_int32_le!(tuple_str)
167
- when 2
168
- ::BinUtils.slice_int16_le!(tuple_str)
169
- else
170
- raise ValueError, "Bad field size #{field_size} for integer field ##{i}"
171
- end
172
- when :auto
173
- str = tuple_str.slice!(0, field_size).force_encoding('utf-8')
174
- case field_size
175
- when 8, 4, 2
176
- Util::AutoType.new(str)
177
- else
178
- str
179
- end
180
- else
181
- (serializers[realfield] ||= get_serializer(field)).decode(tuple_str.slice!(0, field_size))
182
- end
183
- end unless method_defined?(:_unpack_field)
184
-
185
179
  def return_code(data)
186
180
  ::BinUtils.slice_int32_le!(data)
187
181
  end
@@ -1,4 +1,4 @@
1
1
  module Tarantool
2
- VERSION = "0.5.5.1"
2
+ VERSION = "0.5.8"
3
3
  RECORD_VERSION = "0.4.3"
4
4
  end
@@ -74,6 +74,7 @@ module TConf
74
74
  Dir.chdir(conf[:dir]) do
75
75
  conf[:pid] = spawn('tarantool_box')
76
76
  end
77
+ sleep(0.01)
77
78
  end
78
79
 
79
80
  def self.stop(name)
@@ -197,8 +198,9 @@ module Helper
197
198
  def exec_tarantool(cmd, lines_to_read)
198
199
  cmd = cmd.gsub(/^\s+/, '')
199
200
  pipe = tarantool_pipe
200
- pipe.puts(cmd)
201
+ pipe.write(cmd)
201
202
  pipe.flush
203
+ pipe.close_write
202
204
  lines_to_read.times do
203
205
  #STDERR.puts pipe.gets
204
206
  pipe.gets
@@ -211,7 +213,7 @@ module Helper
211
213
  lua truncate(1)
212
214
  lua truncate(2)
213
215
  lua truncate(3)
214
- ", 12
216
+ ", 8
215
217
  end
216
218
 
217
219
  def seed
@@ -224,7 +226,7 @@ module Helper
224
226
  insert into t2 values ('hi zo', 'ho zo', 1)
225
227
  insert into t2 values ('hi zo', 'pidas', 1, 3, 5)
226
228
  insert into t2 values ('coma', 'peredoma', 2)
227
- ", 16
229
+ ", 8
228
230
  end
229
231
 
230
232
  def clear_db
@@ -292,7 +294,11 @@ end
292
294
 
293
295
  class MiniTest::Unit::TestCase
294
296
  include ::Helper
295
- include ::RR::Adapters::MiniTest
297
+ #include ::RR::Adapters::MiniTest
298
+ end
299
+
300
+ module MiniTest::Spec::SharedExamples
301
+ include ::Helper
296
302
  end
297
303
 
298
304
  class << MiniTest::Spec
@@ -406,7 +406,7 @@ shared_examples_for :record do
406
406
  user_class.by_pk('ruden').must_be_nil
407
407
 
408
408
  user_class.by_pk('petro').attributes.must_equal petro.merge(apples_count: 0)
409
- user_class.invoke('box.delete', user_class.space_no, 'petro', space_no: nil).must_equal 1
409
+ user_class.invoke('box.delete', user_class.space_no, 'petro', space_no: nil, types: [:str, :str]).must_equal 1
410
410
  user_class.by_pk('petro').must_be_nil
411
411
  end
412
412
 
@@ -416,7 +416,7 @@ shared_examples_for :record do
416
416
  user_class.by_pk('ruden').must_be_nil
417
417
 
418
418
  user_class.by_pk('petro').attributes.must_equal petro.merge(apples_count: 0)
419
- user_class.call('box.delete', user_class.space_no, 'petro', space_no: nil)[0].
419
+ user_class.call('box.delete', user_class.space_no, 'petro', space_no: nil, types: [:str, :str])[0].
420
420
  attributes.must_equal petro.merge(apples_count: 0)
421
421
  user_class.by_pk('petro').must_be_nil
422
422
  end
@@ -105,18 +105,20 @@ describe 'Tarantool::CallbackDB::SpaceArray' do
105
105
  end
106
106
 
107
107
  it "should fetch longer records" do
108
- emrun(2) {
108
+ emrun(3) {
109
109
  space2.by_pk(['hi zo', 'pidas'], &setp(0))
110
110
  space1.by_pk(2, &setp(1))
111
+ space1.by_pk(2, &setp(2))
111
112
  }
112
113
  results[0].must_equal ['hi zo', 'pidas', 1, 3, 5]
113
114
  results[1].must_equal [2, 'medium', 6, 'common', 7]
115
+ results[2].must_equal [2, 'medium', 6, 'common', 7]
114
116
  end
115
117
 
116
118
  it "should be able to insert" do
117
119
  asdf = ['asdf', 'asdf', 'asdf', 4, 5]
118
120
  qwer = ['qwer', 'qwer', 'qwer', 4, 20, 19]
119
- zxcv = [4, 'zxcv', 7, 'zxcv', 8]
121
+ zxcv = [4, "\0zxcv", 7, 'zxcv', 8]
120
122
  xcvb = [5, 'xcvb', 7, 'xcvb', 8]
121
123
  emrun(4) {
122
124
  space0.insert(asdf, &setp(0))
@@ -124,6 +126,7 @@ describe 'Tarantool::CallbackDB::SpaceArray' do
124
126
  space1.insert(zxcv){|res|
125
127
  results[2] = res
126
128
  space1.by_pk(4, &setp(3))
129
+ space1.by_pk(2, &setp(5))
127
130
  }
128
131
  space1.insert(xcvb, return_tuple: true, &setp(4))
129
132
  }
@@ -132,6 +135,7 @@ describe 'Tarantool::CallbackDB::SpaceArray' do
132
135
  results[2].must_equal 1
133
136
  results[3].must_equal zxcv
134
137
  results[4].must_equal xcvb
138
+ results[5].must_equal [2, 'medium', 6, 'common', 7]
135
139
  end
136
140
 
137
141
  it "should be able to update" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tarantool
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.5.1
4
+ version: 0.5.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Rudenko
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-12-23 00:00:00.000000000 Z
12
+ date: 2015-03-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: iproto