Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

strictly little-endian integer encoding

  • Loading branch information...
commit 28a7a105996f30f5e3f468a26465fddbc3dd9e9e 1 parent dbc9a1b
@funny-falcon funny-falcon authored
View
8 lib/tarantool/request.rb
@@ -11,7 +11,7 @@ def request_type(name = nil)
end
def pack_tuple(*values)
- [values.size].pack('L') + values.map { |v| pack_field(v) }.join
+ [values.size].pack('V') + values.map { |v| pack_field(v) }.join
end
def pack_field(value)
@@ -21,9 +21,9 @@ def pack_field(value)
[value.bytesize, value].pack('wa*')
when Integer
if value < 4294967296 # 2 ^ 32
- [4, value].pack('wL')
+ [4, value].pack('wV')
else
- [8, value].pack('wQ')
+ [8, value].pack('wQ<')
end
when Tarantool::Field
[value.data.bytesize].pack('w') + value.data
@@ -53,7 +53,7 @@ def parse_args
end
def make_response(data)
- return_code, = data[0,4].unpack('L')
+ return_code, = data[0,4].unpack('V')
if return_code == 0
Response.new(data[4, data.size], response_params)
else
View
4 lib/tarantool/requests/call.rb
@@ -11,10 +11,10 @@ def parse_args
end
def make_body
- [flags].pack('L') +
+ [flags].pack('V') +
self.class.pack_field(proc_name) +
self.class.pack_tuple(*tuple)
end
end
end
-end
+end
View
4 lib/tarantool/requests/delete.rb
@@ -10,9 +10,9 @@ def parse_args
end
def make_body
- [space_no, flags].pack('LL') +
+ [space_no, flags].pack('VV') +
self.class.pack_tuple(*key)
end
end
end
-end
+end
View
4 lib/tarantool/requests/insert.rb
@@ -11,9 +11,9 @@ def parse_args
end
def make_body
- [space_no, flags].pack('LL') +
+ [space_no, flags].pack('VV') +
self.class.pack_tuple(*values)
end
end
end
-end
+end
View
4 lib/tarantool/requests/select.rb
@@ -14,9 +14,9 @@ def parse_args
end
def make_body
- [space_no, index_no, offset, limit, tuples.size].pack('LLLLL') +
+ [space_no, index_no, offset, limit, tuples.size].pack('VVVVV') +
tuples.map { |tuple| self.class.pack_tuple(*tuple) }.join
end
end
end
-end
+end
View
8 lib/tarantool/requests/update.rb
@@ -12,7 +12,7 @@ def self.pack_ops(ops)
field_no, op_symbol, op_arg = op
op_code = OP_CODES[op_symbol] || raise(ArgumentError.new("Unsupported operation symbol '#{op_symbol}'"))
- [field_no, op_code].pack('LC') + self.pack_field(op_arg)
+ [field_no, op_code].pack('VC') + self.pack_field(op_arg)
end.join
end
@@ -25,11 +25,11 @@ def parse_args
end
def make_body
- [space_no, flags].pack('LL') +
+ [space_no, flags].pack('VV') +
self.class.pack_tuple(*key) +
- [ops.size].pack('L') +
+ [ops.size].pack('V') +
self.class.pack_ops(ops)
end
end
end
-end
+end
View
8 lib/tarantool/response.rb
@@ -8,9 +8,9 @@ def initialize(data)
def to_i
@i ||= case data.bytesize
when 8
- data.unpack('Q')[0]
+ data.unpack('Q<')[0]
when 4
- data.unpack('L')[0]
+ data.unpack('V')[0]
when 2
data.unpack('S')[0]
else
@@ -26,7 +26,7 @@ class Response
attr_reader :tuples_affected, :offset, :tuples
def initialize(data, params = {})
@offset = 0
- @tuples_affected, = data[0, 4].unpack('L')
+ @tuples_affected, = data[0, 4].unpack('V')
@offset += 4
if params[:return_tuple]
@tuples = (1..tuples_affected).map do
@@ -43,7 +43,7 @@ def tuple
end
def unpack_tuple(data)
- byte_size, cardinality = data[@offset, 8].unpack("LL")
+ byte_size, cardinality = data[@offset, 8].unpack("VV")
@offset += 8
tuple_data = data[@offset, byte_size]
@offset += byte_size
Please sign in to comment.
Something went wrong with that request. Please try again.