fdb 6.0.13 → 6.0.17

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/fdbimpl.rb +1 -1
  3. data/lib/fdbtuple.rb +44 -9
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 01029de57f0c0760dab2f59acd36434ec1a702a9
4
- data.tar.gz: b3db4c3812b6a1d7b3ce84fbf4e35fee08cc3b58
3
+ metadata.gz: b6898eb1a3cfa0cfc9809de320b334f71ff81dd4
4
+ data.tar.gz: a6561099447bbe6964f3d6f45c41e9555a09b49f
5
5
  SHA512:
6
- metadata.gz: 65b9329695ad8dba6972bf269573474707d60e1c59f4b8bbc0b8eadefc0513aeab94c16a427ecc3f0d2fd7a68b019033d6d618233595d41b5f8598ec2feeb970
7
- data.tar.gz: 46f459ebb3171566a3d61c4d8bf95610c6ed8f1e74c45b8d35c863b19c9d62b96e78cafed2ceaf9f040c7ac26f2896500b3cc88bd8e1b4e702106bed1999f38d
6
+ metadata.gz: 8e41fbe32e66e7bf4d961b346751279dea7ee05280def8390850bd1a5878f9c82ae152b74fa7a398998bd2af34a69a87307dfb1b7262830ed9a4f22e07bbeb9e
7
+ data.tar.gz: 241dde317b72dd653c7b7ebd5b795078e32a2b45bf016335030baca701ba0aa3d90deba628e26b2e10f8de3eaf4f2cc80cdd2e019863d5d71273c88ba2219efc
data/lib/fdbimpl.rb CHANGED
@@ -170,7 +170,7 @@ module FDB
170
170
  Proc.new do || @setfunc.call(v[0], nil) end
171
171
  when String then
172
172
  Proc.new do |opt=nil| @setfunc.call(v[0], (opt.nil? ? opt : opt.encode('UTF-8')) ) end
173
- when Fixnum then
173
+ when Integer then
174
174
  Proc.new do |opt| @setfunc.call(v[0], [opt].pack("q<")) end
175
175
  else
176
176
  raise ArgumentError, "Don't know how to set options of type #{v[2].class}"
data/lib/fdbtuple.rb CHANGED
@@ -35,8 +35,8 @@ module FDB
35
35
  @@STRING_CODE = 0x02
36
36
  @@NESTED_CODE = 0x05
37
37
  @@INT_ZERO_CODE = 0x14
38
- @@POS_INT_END = 0x1c
39
- @@NEG_INT_START = 0x0c
38
+ @@POS_INT_END = 0x1d
39
+ @@NEG_INT_START = 0x0b
40
40
  @@FLOAT_CODE = 0x20
41
41
  @@DOUBLE_CODE = 0x21
42
42
  @@FALSE_CODE = 0x26
@@ -117,12 +117,28 @@ module FDB
117
117
  elsif code == @@STRING_CODE
118
118
  epos = find_terminator(v, pos+1)
119
119
  [v.slice(pos+1, epos-pos-1).gsub("\x00\xFF", "\x00").force_encoding("UTF-8"), epos+1]
120
- elsif code >= @@INT_ZERO_CODE && code <= @@POS_INT_END
120
+ elsif code >= @@INT_ZERO_CODE && code < @@POS_INT_END
121
121
  n = code - @@INT_ZERO_CODE
122
122
  [("\x00" * (8-n) + v.slice(pos+1, n)).unpack("Q>")[0], pos+n+1]
123
- elsif code >= @@NEG_INT_START and code < @@INT_ZERO_CODE
123
+ elsif code > @@NEG_INT_START and code < @@INT_ZERO_CODE
124
124
  n = @@INT_ZERO_CODE - code
125
125
  [("\x00" * (8-n) + v.slice(pos+1, n)).unpack("Q>")[0]-@@size_limits[n], pos+n+1]
126
+ elsif code == @@POS_INT_END
127
+ length = v.getbyte(pos+1)
128
+ val = 0
129
+ length.times do |i|
130
+ val = val << 8
131
+ val += v.getbyte(pos+2+i)
132
+ end
133
+ [val, pos+length+2]
134
+ elsif code == @@NEG_INT_START
135
+ length = v.getbyte(pos+1) ^ 0xff
136
+ val = 0
137
+ length.times do |i|
138
+ val = val << 8
139
+ val += v.getbyte(pos+2+i)
140
+ end
141
+ [val - (1 << (length*8)) + 1, pos+length+2]
126
142
  elsif code == @@FALSE_CODE
127
143
  [false, pos+1]
128
144
  elsif code == @@TRUE_CODE
@@ -182,15 +198,34 @@ module FDB
182
198
  raise ArgumentError, "unsupported encoding #{v.encoding.name}"
183
199
  end
184
200
  elsif v.kind_of? Integer
185
- raise RangeError, "value outside inclusive range -2**64+1 to 2**64-1" if v < -2**64+1 || v > 2**64-1
201
+ raise RangeError, "Integer magnitude is too large (more than 255 bytes)" if v < -2**2040+1 || v > 2**2040-1
186
202
  if v == 0
187
203
  @@INT_ZERO_CODE.chr
188
204
  elsif v > 0
189
- n = bisect_left( @@size_limits, v )
190
- (20+n).chr + [v].pack("Q>").slice(8-n, n)
205
+ if v > @@size_limits[-1]
206
+ length = (v.bit_length + 7) / 8
207
+ result = @@POS_INT_END.chr + length.chr
208
+ length.times do |i|
209
+ result << ((v >> (8 * (length-i-1))) & 0xff)
210
+ end
211
+ result
212
+ else
213
+ n = bisect_left( @@size_limits, v )
214
+ (@@INT_ZERO_CODE+n).chr + [v].pack("Q>").slice(8-n, n)
215
+ end
191
216
  else
192
- n = bisect_left( @@size_limits, -v )
193
- (20-n).chr + [@@size_limits[n]+v].pack("Q>").slice(8-n, n)
217
+ if -v > @@size_limits[-1]
218
+ length = ((-v).bit_length + 7) / 8
219
+ v += (1 << (length * 8)) - 1
220
+ result = @@NEG_INT_START.chr + (length ^ 0xff).chr
221
+ length.times do |i|
222
+ result << ((v >> (8 * (length-i-1))) & 0xff)
223
+ end
224
+ result
225
+ else
226
+ n = bisect_left( @@size_limits, -v )
227
+ (@@INT_ZERO_CODE-n).chr + [@@size_limits[n]+v].pack("Q>").slice(8-n, n)
228
+ end
194
229
  end
195
230
  elsif v.kind_of? TrueClass
196
231
  @@TRUE_CODE.chr
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.13
4
+ version: 6.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - FoundationDB
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-10 00:00:00.000000000 Z
11
+ date: 2018-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi