tarantool 0.5.2 → 0.5.3
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 +13 -5
- data/ext/tarantool/extconf.rb +5 -2
- data/ext/tarantool/response_c.c +97 -147
- data/lib/tarantool.rb +13 -4
- data/lib/tarantool/em_db.rb +16 -0
- data/lib/tarantool/response.rb +88 -88
- data/lib/tarantool/util.rb +3 -0
- data/lib/tarantool/version.rb +1 -1
- metadata +21 -23
- data/test/tarantool.log +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MmM2OTBiNjJhNzdhNWEyZGY3ODc5NmY2OGZiNmRiOTMyMTI5ZmI0Mw==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
Y2I2MDI0Y2NlNTU3NDcxMzJkMWUxMzdlYzkwZTFlMDA1MzJiZDE3OQ==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MzVhMTVjNTYwNjUxY2Q3ZWFlNGMxYTNkYzVhMDE1MDliYjBhMjVjYzNhNzY2
|
10
|
+
NDE3ODQ4ODVmN2I3YmJiYjJjNGM4NzA4ZmEwYTFjZDkyYzRjNGNhZDNkMzJh
|
11
|
+
ZmIyN2I1NzUyMTRhZjdkMzZkMzdmYTgzM2YyNjc2MDAyMjkxMjY=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ZWNlZWMwM2FjNDhhMTY1MDI4NGY0NDVhMGU5NGMwMWU3ZWRkMmQ4NjBjM2Ji
|
14
|
+
OGUzNTljOTNjYTk0Y2RlOWRkZjZkOWQwMGMxNzg4ODQxZWM2MmE4ZGQ0NWY4
|
15
|
+
OGIyZDUzMGViMDc0MmViOThkNzc3NTNkZTZiNDM3MDE5MzA5NDc=
|
data/ext/tarantool/extconf.rb
CHANGED
@@ -1,8 +1,11 @@
|
|
1
|
-
|
1
|
+
begin
|
2
|
+
if RUBY_ENGINE != 'ruby' || "\x01\x02\x03\x04".unpack('L') != [0x04030201]
|
3
|
+
raise ':('
|
4
|
+
end
|
2
5
|
require 'mkmf'
|
3
6
|
have_func('rb_str_drop_bytes')
|
4
7
|
create_makefile("response_c")
|
5
|
-
|
8
|
+
rescue
|
6
9
|
File.open(File.dirname(__FILE__) + "/Makefile", 'w') do |f|
|
7
10
|
f.write("install:\n\t#nothing to build")
|
8
11
|
end
|
data/ext/tarantool/response_c.c
CHANGED
@@ -58,18 +58,6 @@ typedef unsigned long long uint64_t;
|
|
58
58
|
#define NUM2U64(v) NUM2ULL(v)
|
59
59
|
#endif
|
60
60
|
|
61
|
-
#ifndef HAVE_RB_STR_DROP_BYTES
|
62
|
-
/* rubinius has no rb_str_drop_bytes */
|
63
|
-
ID aslice;
|
64
|
-
static VALUE
|
65
|
-
rb_str_drop_bytes(VALUE str, long bytes)
|
66
|
-
{
|
67
|
-
VALUE args[2] = {0, INT2FIX(bytes)};
|
68
|
-
rb_funcall2(str, aslice, 2, args);
|
69
|
-
return str;
|
70
|
-
}
|
71
|
-
#endif
|
72
|
-
|
73
61
|
ID id_rshft, id_band, id_get_serializer, id_decode;
|
74
62
|
VALUE sym_int, sym_integer, sym_string, sym_str, sym_int64, sym_bytes, sym_int16;
|
75
63
|
VALUE sym_int8, sym_sint, sym_sint64, sym_sint16, sym_sint8, sym_varint, sym_auto;
|
@@ -112,147 +100,108 @@ get_uint64(const char *str)
|
|
112
100
|
}
|
113
101
|
|
114
102
|
static VALUE
|
115
|
-
|
103
|
+
unpack_field(VALUE self, VALUE data, VALUE field, VALUE i_o, VALUE realfield_o, VALUE serializers)
|
116
104
|
{
|
117
|
-
|
118
|
-
uint32_t tuplesn = NUM2UINT(tuples_affected);
|
119
|
-
uint32_t tail = NUM2UINT(_tail);
|
105
|
+
int i = NUM2INT(i_o);
|
120
106
|
const char *str = StringValuePtr(data);
|
121
107
|
size_t len = RSTRING_LEN(data);
|
122
|
-
|
108
|
+
size_t fieldsize = slice_ber((const uint8_t**)&str, &len);
|
109
|
+
VALUE value;
|
110
|
+
rb_str_drop_bytes(data, RSTRING_LEN(data) - len);
|
111
|
+
str = StringValuePtr(data);
|
123
112
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
VALUE tuple;
|
131
|
-
if (len < 8) {
|
132
|
-
rb_raise(rb_eValueError, "Response too short");
|
133
|
-
}
|
134
|
-
end = str + 8 + get_uint32(str);
|
135
|
-
tuplen = get_uint32(str+4);
|
136
|
-
tuple = rb_ary_new2(tuplen);
|
137
|
-
str += 8;
|
138
|
-
len -= 8;
|
139
|
-
for(i = 0; i < tuplen; i++) {
|
140
|
-
size_t fieldsize = slice_ber((const uint8_t**)&str, &len);
|
141
|
-
VALUE field, value;
|
142
|
-
if (fieldsize == 0) {
|
143
|
-
rb_ary_push(tuple, Qnil);
|
144
|
-
continue;
|
145
|
-
}
|
146
|
-
if (fieldsize > len) {
|
147
|
-
rb_raise(rb_eValueError, "Response mailformed at field #%u fieldsize: %zu tail len: %zu", i, fieldsize, len);
|
148
|
-
}
|
149
|
-
realfield = i;
|
150
|
-
if (i >= fieldsn) {
|
151
|
-
if (tail == 1) {
|
152
|
-
realfield = fieldsn - 1;
|
153
|
-
} else {
|
154
|
-
realfield = fieldsn + (i - fieldsn) % tail - tail;
|
155
|
-
}
|
156
|
-
}
|
157
|
-
field = RARRAY_CONST_PTR(fields)[realfield];
|
113
|
+
if (fieldsize == 0) {
|
114
|
+
return Qnil;
|
115
|
+
}
|
116
|
+
if (fieldsize > len) {
|
117
|
+
rb_raise(rb_eValueError, "Response mailformed at field #%u fieldsize: %zu tail len: %zu", i, fieldsize, len);
|
118
|
+
}
|
158
119
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
value = rb_enc_str_new(str, fieldsize, utf8);
|
232
|
-
if (fieldsize == 2 || fieldsize == 4 || fieldsize == 8) {
|
233
|
-
value = rb_class_new_instance(1, &value, rb_cAutoType);
|
234
|
-
}
|
235
|
-
} else {
|
236
|
-
VALUE serializer = rb_ary_entry(serializers, realfield);
|
237
|
-
VALUE substr = rb_enc_str_new(str, fieldsize, binary);
|
238
|
-
if (!RTEST(serializer)) {
|
239
|
-
serializer = rb_funcall2(self, id_get_serializer, 1, &field);
|
240
|
-
rb_ary_store(serializers, realfield, serializer);
|
241
|
-
}
|
242
|
-
value = rb_funcall2(serializer, id_decode, 1, &substr);
|
243
|
-
}
|
244
|
-
str += fieldsize;
|
245
|
-
len -= fieldsize;
|
246
|
-
rb_ary_push(tuple, value);
|
247
|
-
}
|
248
|
-
if (end != str) {
|
249
|
-
rb_raise(rb_eValueError, "Response mailformed");
|
250
|
-
}
|
251
|
-
rb_ary_push(tuples, tuple);
|
120
|
+
if (field == sym_int || field == sym_integer) {
|
121
|
+
if (fieldsize != 4) {
|
122
|
+
rb_raise(rb_eValueError, "Bad field size %zd for integer field #%u", fieldsize, i);
|
123
|
+
}
|
124
|
+
value = UINT2NUM(get_uint32(str));
|
125
|
+
} else if (field == sym_str || field == sym_string) {
|
126
|
+
if (*str == 0 && fieldsize > 0) {
|
127
|
+
value = rb_enc_str_new(str+1, fieldsize-1, rb_utf8_encoding());
|
128
|
+
} else {
|
129
|
+
value = rb_enc_str_new(str, fieldsize, rb_utf8_encoding());
|
130
|
+
}
|
131
|
+
} else if (field == sym_int64) {
|
132
|
+
if (fieldsize != 8) {
|
133
|
+
rb_raise(rb_eValueError, "Bad field size %zd for 64bit integer field #%u", fieldsize, i);
|
134
|
+
}
|
135
|
+
value = U642NUM(get_uint64(str));
|
136
|
+
} else if (field == sym_bytes) {
|
137
|
+
value = rb_enc_str_new(str, fieldsize, rb_ascii8bit_encoding());
|
138
|
+
} else if (field == sym_int16) {
|
139
|
+
if (fieldsize != 2) {
|
140
|
+
rb_raise(rb_eValueError, "Bad field size %zd for 16bit integer field #%u", fieldsize, i);
|
141
|
+
}
|
142
|
+
value = UINT2NUM(get_uint16(str));
|
143
|
+
} else if (field == sym_int8) {
|
144
|
+
if (fieldsize != 1) {
|
145
|
+
rb_raise(rb_eValueError, "Bad field size %zd for 8bit integer field #%u", fieldsize, i);
|
146
|
+
}
|
147
|
+
value = UINT2NUM(*(uint8_t*)str);
|
148
|
+
} else if (field == sym_sint) {
|
149
|
+
if (fieldsize != 4) {
|
150
|
+
rb_raise(rb_eValueError, "Bad field size %zd for integer field #%u", fieldsize, i);
|
151
|
+
}
|
152
|
+
value = INT2NUM((int32_t)get_uint32(str));
|
153
|
+
} else if (field == sym_sint64) {
|
154
|
+
if (fieldsize != 8) {
|
155
|
+
rb_raise(rb_eValueError, "Bad field size %zd for 64bit integer field #%u", fieldsize, i);
|
156
|
+
}
|
157
|
+
value = I642NUM((int64_t)get_uint64(str));
|
158
|
+
} else if (field == sym_sint16) {
|
159
|
+
if (fieldsize != 2) {
|
160
|
+
rb_raise(rb_eValueError, "Bad field size %zd for 16bit integer field #%u", fieldsize, i);
|
161
|
+
}
|
162
|
+
value = INT2NUM((int16_t)get_uint16(str));
|
163
|
+
} else if (field == sym_sint8) {
|
164
|
+
if (fieldsize != 1) {
|
165
|
+
rb_raise(rb_eValueError, "Bad field size %zd for 8bit integer field #%u", fieldsize, i);
|
166
|
+
}
|
167
|
+
value = INT2NUM(*(int8_t*)str);
|
168
|
+
} else if (field == sym_varint) {
|
169
|
+
if (fieldsize == 4) {
|
170
|
+
value = UINT2NUM(get_uint32(str));
|
171
|
+
} else if (fieldsize == 8) {
|
172
|
+
value = U642NUM(get_uint64(str));
|
173
|
+
} else if (fieldsize == 2) {
|
174
|
+
value = UINT2NUM(get_uint16(str));
|
175
|
+
} else {
|
176
|
+
rb_raise(rb_eValueError, "Bad field size %zd for integer field %d", fieldsize, i);
|
177
|
+
}
|
178
|
+
} else if (field == sym_auto) {
|
179
|
+
value = rb_enc_str_new(str, fieldsize, rb_utf8_encoding());
|
180
|
+
if (fieldsize == 2 || fieldsize == 4 || fieldsize == 8) {
|
181
|
+
value = rb_class_new_instance(1, &value, rb_cAutoType);
|
182
|
+
}
|
183
|
+
} else {
|
184
|
+
int realfield = NUM2INT(realfield_o);
|
185
|
+
VALUE serializer = rb_ary_entry(serializers, realfield);
|
186
|
+
VALUE substr = rb_enc_str_new(str, fieldsize, rb_ascii8bit_encoding());
|
187
|
+
if (!RTEST(serializer)) {
|
188
|
+
serializer = rb_funcall2(self, id_get_serializer, 1, &field);
|
189
|
+
rb_ary_store(serializers, realfield, serializer);
|
190
|
+
}
|
191
|
+
value = rb_funcall2(serializer, id_decode, 1, &substr);
|
252
192
|
}
|
193
|
+
rb_str_drop_bytes(data, fieldsize);
|
194
|
+
return value;
|
195
|
+
}
|
253
196
|
|
254
|
-
|
255
|
-
|
197
|
+
static VALUE
|
198
|
+
get_tail_no(VALUE self, VALUE array, VALUE index_o, VALUE tail_o)
|
199
|
+
{
|
200
|
+
int size = RARRAY_LEN(array);
|
201
|
+
int index = NUM2INT(index_o);
|
202
|
+
int tail = NUM2INT(tail_o);
|
203
|
+
int pos = index < size ? index : (size - tail + (index - size) % tail);
|
204
|
+
return INT2NUM(pos);
|
256
205
|
}
|
257
206
|
|
258
207
|
void
|
@@ -261,7 +210,8 @@ Init_response_c()
|
|
261
210
|
VALUE rb_mTarantool = rb_define_module("Tarantool");
|
262
211
|
VALUE rb_mUnpackTuples = rb_define_module_under(rb_mTarantool, "UnpackTuples");
|
263
212
|
VALUE rb_mUtil = rb_const_get(rb_mTarantool, rb_intern("Util"));
|
264
|
-
rb_define_method(rb_mUnpackTuples, "
|
213
|
+
rb_define_method(rb_mUnpackTuples, "_unpack_field", unpack_field, 5);
|
214
|
+
rb_define_private_method(rb_mUnpackTuples, "get_tail_no", get_tail_no, 3);
|
265
215
|
rb_eValueError = rb_const_get(rb_mTarantool, rb_intern("ValueError"));
|
266
216
|
rb_cAutoType = rb_const_get(rb_mUtil, rb_intern("AutoType"));
|
267
217
|
|
data/lib/tarantool.rb
CHANGED
@@ -141,15 +141,24 @@ module Tarantool
|
|
141
141
|
def _shard(number)
|
142
142
|
@connections[number] ||= begin
|
143
143
|
@shards[number].map do |host, port|
|
144
|
-
IProto.get_connection(host, port, self.class::IPROTO_CONNECTION_TYPE)
|
144
|
+
con = IProto.get_connection(host, port, self.class::IPROTO_CONNECTION_TYPE)
|
145
|
+
_tune_new_connection(con)
|
146
|
+
con
|
145
147
|
end
|
146
148
|
end
|
147
149
|
end
|
148
150
|
|
149
|
-
def
|
150
|
-
|
151
|
-
|
151
|
+
def _tune_new_connection(con)
|
152
|
+
end
|
153
|
+
|
154
|
+
def each_connection
|
155
|
+
@connections.each do |num, replicas|
|
156
|
+
replicas.each{|r| yield r}
|
152
157
|
end
|
158
|
+
end
|
159
|
+
|
160
|
+
def close_connection
|
161
|
+
each_connection{|c| c.close}
|
153
162
|
@connections.clear
|
154
163
|
end
|
155
164
|
|
data/lib/tarantool/em_db.rb
CHANGED
@@ -4,6 +4,22 @@ module Tarantool
|
|
4
4
|
IPROTO_CONNECTION_TYPE = :em_callback
|
5
5
|
INITIAL = Object.new.freeze
|
6
6
|
|
7
|
+
def inactivity_timeout
|
8
|
+
@inactivity_timeout ||= 0
|
9
|
+
end
|
10
|
+
|
11
|
+
def inactivity_timeout=(v)
|
12
|
+
@inactivity_timeout = v || 0
|
13
|
+
each_connection do |c|
|
14
|
+
c.comm_inactivity_timeout = @inactivity_timeout
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def _tune_new_connection(con)
|
19
|
+
super
|
20
|
+
con.comm_inactivity_timeout = inactivity_timeout
|
21
|
+
end
|
22
|
+
|
7
23
|
class Curry1 < Struct.new(:obj, :arg)
|
8
24
|
def call
|
9
25
|
obj.call arg
|
data/lib/tarantool/response.rb
CHANGED
@@ -84,103 +84,103 @@ module Tarantool
|
|
84
84
|
end
|
85
85
|
orig_data = data.dup
|
86
86
|
begin
|
87
|
-
|
87
|
+
tuples = []
|
88
|
+
serializers = []
|
89
|
+
while tuples_affected > 0
|
90
|
+
byte_size = ::BinUtils.slice_int32_le!(data)
|
91
|
+
fields_num = ::BinUtils.slice_int32_le!(data)
|
92
|
+
tuple_str = data.slice!(0, byte_size)
|
93
|
+
i = 0
|
94
|
+
tuple = []
|
95
|
+
while i < fields_num
|
96
|
+
field = fields[fieldno = i] || fields[fieldno = get_tail_no(fields, i, tail)]
|
97
|
+
tuple << _unpack_field(tuple_str, field, i, fieldno, serializers)
|
98
|
+
i += 1
|
99
|
+
end
|
100
|
+
tuples << tuple
|
101
|
+
tuples_affected -= 1
|
102
|
+
end
|
103
|
+
tuples
|
88
104
|
rescue ValueError => e
|
89
105
|
$stderr.puts "Value Error: tuples=#{tuples_affected}, data='#{orig_data.each_byte.map{|b| format(X02, b)}.join(' ')}'"
|
90
106
|
raise e
|
91
107
|
end
|
92
108
|
end
|
93
109
|
|
94
|
-
def
|
95
|
-
|
96
|
-
|
97
|
-
byte_size = ::BinUtils.slice_int32_le!(data)
|
98
|
-
fields_num = ::BinUtils.slice_int32_le!(data)
|
99
|
-
tuple_str = data.slice!(0, byte_size)
|
100
|
-
i = 0
|
101
|
-
tuple = []
|
102
|
-
while i < fields_num
|
103
|
-
field_size = ::BinUtils.slice_ber!(tuple_str)
|
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
|
104
113
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
when :sint64
|
141
|
-
if field_size != 8
|
142
|
-
raise ValueError, "Bad field size #{field_size} for 64bit integer field ##{i}"
|
143
|
-
end
|
144
|
-
::BinUtils.slice_sint64_le!(tuple_str)
|
145
|
-
when :sint16
|
146
|
-
if field_size != 2
|
147
|
-
raise ValueError, "Bad field size #{field_size} for 16bit integer field ##{i}"
|
148
|
-
end
|
149
|
-
::BinUtils.slice_sint16_le!(tuple_str)
|
150
|
-
when :sint8
|
151
|
-
if field_size != 1
|
152
|
-
raise ValueError, "Bad field size #{field_size} for 8bit integer field ##{i}"
|
153
|
-
end
|
154
|
-
::BinUtils.slice_sint8!(tuple_str)
|
155
|
-
when :varint
|
156
|
-
case field_size
|
157
|
-
when 8
|
158
|
-
::BinUtils.slice_int64_le!(tuple_str)
|
159
|
-
when 4
|
160
|
-
::BinUtils.slice_int32_le!(tuple_str)
|
161
|
-
when 2
|
162
|
-
::BinUtils.slice_int16_le!(tuple_str)
|
163
|
-
else
|
164
|
-
raise ValueError, "Bad field size #{field_size} for integer field ##{i}"
|
165
|
-
end
|
166
|
-
when :auto
|
167
|
-
str = tuple_str.slice!(0, field_size).force_encoding('utf-8')
|
168
|
-
case field_size
|
169
|
-
when 8, 4, 2
|
170
|
-
Util::AutoType.new(str)
|
171
|
-
else
|
172
|
-
str
|
173
|
-
end
|
174
|
-
else
|
175
|
-
get_serializer(field).decode(tuple_str.slice!(0, field_size))
|
176
|
-
end)
|
177
|
-
i += 1
|
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}"
|
178
149
|
end
|
179
|
-
|
180
|
-
|
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))
|
181
182
|
end
|
182
|
-
|
183
|
-
end unless method_defined?(:_unpack_tuples)
|
183
|
+
end unless method_defined?(:_unpack_field)
|
184
184
|
|
185
185
|
def return_code(data)
|
186
186
|
::BinUtils.slice_int32_le!(data)
|
data/lib/tarantool/util.rb
CHANGED
data/lib/tarantool/version.rb
CHANGED
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.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Rudenko
|
@@ -9,64 +9,64 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-10-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
prerelease: false
|
16
|
-
name: iproto
|
17
15
|
version_requirements: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
|
-
- - '>='
|
17
|
+
- - ! '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.3.
|
19
|
+
version: 0.3.15
|
20
|
+
prerelease: false
|
22
21
|
requirement: !ruby/object:Gem::Requirement
|
23
22
|
requirements:
|
24
|
-
- - '>='
|
23
|
+
- - ! '>='
|
25
24
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.3.
|
25
|
+
version: 0.3.15
|
27
26
|
type: :runtime
|
27
|
+
name: iproto
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
|
-
prerelease: false
|
30
|
-
name: murmurhash3
|
31
29
|
version_requirements: !ruby/object:Gem::Requirement
|
32
30
|
requirements:
|
33
|
-
- - '>='
|
31
|
+
- - ! '>='
|
34
32
|
- !ruby/object:Gem::Version
|
35
33
|
version: 0.1.1
|
34
|
+
prerelease: false
|
36
35
|
requirement: !ruby/object:Gem::Requirement
|
37
36
|
requirements:
|
38
|
-
- - '>='
|
37
|
+
- - ! '>='
|
39
38
|
- !ruby/object:Gem::Version
|
40
39
|
version: 0.1.1
|
41
40
|
type: :runtime
|
41
|
+
name: murmurhash3
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
|
-
prerelease: false
|
44
|
-
name: sumbur
|
45
43
|
version_requirements: !ruby/object:Gem::Requirement
|
46
44
|
requirements:
|
47
|
-
- - '>='
|
45
|
+
- - ! '>='
|
48
46
|
- !ruby/object:Gem::Version
|
49
47
|
version: 0.0.2
|
48
|
+
prerelease: false
|
50
49
|
requirement: !ruby/object:Gem::Requirement
|
51
50
|
requirements:
|
52
|
-
- - '>='
|
51
|
+
- - ! '>='
|
53
52
|
- !ruby/object:Gem::Version
|
54
53
|
version: 0.0.2
|
55
54
|
type: :runtime
|
55
|
+
name: sumbur
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
|
-
prerelease: false
|
58
|
-
name: bin_utils
|
59
57
|
version_requirements: !ruby/object:Gem::Requirement
|
60
58
|
requirements:
|
61
59
|
- - ~>
|
62
60
|
- !ruby/object:Gem::Version
|
63
61
|
version: 0.0.3
|
62
|
+
prerelease: false
|
64
63
|
requirement: !ruby/object:Gem::Requirement
|
65
64
|
requirements:
|
66
65
|
- - ~>
|
67
66
|
- !ruby/object:Gem::Version
|
68
67
|
version: 0.0.3
|
69
68
|
type: :runtime
|
69
|
+
name: bin_utils
|
70
70
|
description: Tarantool KV-storage client.
|
71
71
|
email:
|
72
72
|
- ceo@prepor.ru
|
@@ -115,7 +115,6 @@ files:
|
|
115
115
|
- test/shared_space_array.rb
|
116
116
|
- test/shared_space_hash.rb
|
117
117
|
- test/tarantool.cfg
|
118
|
-
- test/tarantool.log
|
119
118
|
- test/tarantool1.cfg
|
120
119
|
- test/test_light_record.rb
|
121
120
|
- test/test_light_record_callback.rb
|
@@ -143,17 +142,17 @@ require_paths:
|
|
143
142
|
- ext
|
144
143
|
required_ruby_version: !ruby/object:Gem::Requirement
|
145
144
|
requirements:
|
146
|
-
- - '>='
|
145
|
+
- - ! '>='
|
147
146
|
- !ruby/object:Gem::Version
|
148
147
|
version: '0'
|
149
148
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
149
|
requirements:
|
151
|
-
- - '>='
|
150
|
+
- - ! '>='
|
152
151
|
- !ruby/object:Gem::Version
|
153
152
|
version: '0'
|
154
153
|
requirements: []
|
155
154
|
rubyforge_project:
|
156
|
-
rubygems_version: 2.
|
155
|
+
rubygems_version: 2.4.2
|
157
156
|
signing_key:
|
158
157
|
specification_version: 4
|
159
158
|
summary: Tarantool KV-storage client.
|
@@ -168,7 +167,6 @@ test_files:
|
|
168
167
|
- test/shared_space_array.rb
|
169
168
|
- test/shared_space_hash.rb
|
170
169
|
- test/tarantool.cfg
|
171
|
-
- test/tarantool.log
|
172
170
|
- test/tarantool1.cfg
|
173
171
|
- test/test_light_record.rb
|
174
172
|
- test/test_light_record_callback.rb
|
data/test/tarantool.log
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
1344852766.959 28990 1/spawner _ C> initialized
|
2
|
-
1344852766.975 28988 1/sched _ I> space 0 successfully configured
|
3
|
-
1344852766.975 28988 1/sched _ I> space 1 successfully configured
|
4
|
-
1344852766.975 28988 1/sched _ I> space 2 successfully configured
|
5
|
-
1344852766.975 28988 1/sched _ I> space 3 successfully configured
|
6
|
-
1344852766.975 28988 1/sched _ I> recovery start
|
7
|
-
1344852766.975 28988 1/sched _ I> recover from `./00000000000000000001.snap'
|
8
|
-
1344852766.975 28988 1/sched _ I> snapshot recovered, confirmed lsn: 1
|
9
|
-
1344852766.976 28988 1/sched _ I> building secondary indexes
|
10
|
-
1344852766.976 28988 1/sched _ I> Building secondary keys in space 0...
|
11
|
-
1344852766.976 28988 1/sched _ I> Space 0: done
|
12
|
-
1344852766.976 28988 1/sched _ I> Building secondary keys in space 2...
|
13
|
-
1344852766.976 28988 1/sched _ I> Space 2: done
|
14
|
-
1344852766.976 28988 1/sched _ I> Building secondary keys in space 3...
|
15
|
-
1344852766.976 28988 1/sched _ I> Space 3: done
|
16
|
-
1344852766.976 28988 101/33013/primary _ I> bound to port 33013
|
17
|
-
1344852766.976 28988 101/33013/primary _ I> I am primary
|
18
|
-
1344852766.976 28988 102/33014/secondary _ I> bound to port 33014
|
19
|
-
1344852766.977 28988 103/33015/admin _ I> bound to port 33015
|
20
|
-
1344852766.977 28988 104/33016/replication _ I> bound to port 33016
|
21
|
-
1344852766.977 28988 105/init.lua _ I> loading ./init.lua
|
22
|
-
1344852766.977 28988 1/sched _ C> log level 4
|
23
|
-
1344852766.977 28988 1/sched _ C> entering event loop
|
24
|
-
1344852784.410 28988 1/sched _ C> exiting loop
|
25
|
-
1344852784.412 28990 1/spawner _ I> Exiting: master shutdown
|