fdb 5.2.6 → 6.3.22

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: d19471f94d2976258e1454d1cefb3a4c57a8e6f2
4
- data.tar.gz: 6140bebcdbeb2741fd9bdb75cb42b34d6213c7ff
3
+ metadata.gz: c73a96c929aa30cb3ed7a71c79a7c0db2a19db89
4
+ data.tar.gz: 810653df13089e8a154cfeac0f1af06e17607f99
5
5
  SHA512:
6
- metadata.gz: 109d762db1f5cdd6826e6e6af5a5eb331ad19ec4486cdd7a1db46083c8493816a104054a2b7b9664dd11a777b37769da40a8580cc443326d5298bb67e2195c40
7
- data.tar.gz: c2eb5f01dd39c5ead2131f3f212d1a8819e208c9e2873185f42cf5f9d511a8925a5a726c25b6fc1dc33943d7fd52c21c865940a5949246938f8411e110a62870
6
+ metadata.gz: 40b8e63b4f0ca0b62154fbd47134afae1d5851ded510f181f4edfb38c1e50ea2139a119cd97ae8f0862838db0a3959e222150f92b2dc0b6a851f89c1633e2adf
7
+ data.tar.gz: d3302608acd34e82235634359585619eefcd329ade1214529cc5546c42820789b4f114c7ca117393cdf3822c0c005bd8547eb40b2e3e28a788e0bc90a521bdf1
@@ -36,7 +36,7 @@ module FDB
36
36
  end
37
37
  end
38
38
  def self.api_version(version)
39
- header_version = 520
39
+ header_version = 630
40
40
  if self.is_api_version_selected?()
41
41
  if @@chosen_version != version
42
42
  raise "FDB API already loaded at version #{@@chosen_version}."
@@ -70,8 +70,15 @@ module FDB
70
70
  raise "FoundationDB API version error"
71
71
  end
72
72
 
73
+ FDBC.init_c_api()
74
+
73
75
  require_relative 'fdbtuple'
74
76
  require_relative 'fdbdirectory'
77
+
78
+ if version < 610
79
+ require_relative 'fdbimpl_v609'
80
+ end
81
+
75
82
  if version > 22
76
83
  require_relative 'fdblocality'
77
84
  end
@@ -64,64 +64,63 @@ module FDB
64
64
  typedef :int, :fdb_error
65
65
  typedef :int, :fdb_bool
66
66
 
67
- attach_function :fdb_get_error, [ :fdb_error ], :string
68
-
69
- attach_function :fdb_network_set_option, [ :int, :pointer, :int ], :fdb_error
70
- attach_function :fdb_setup_network, [ ], :fdb_error
71
- attach_function :fdb_run_network, [ ], :fdb_error, :blocking => true
72
- attach_function :fdb_stop_network, [ ], :fdb_error
73
-
74
- attach_function :fdb_future_cancel, [ :pointer ], :void
75
- attach_function :fdb_future_release_memory, [ :pointer ], :void
76
- attach_function :fdb_future_destroy, [ :pointer ], :void
77
- attach_function :fdb_future_block_until_ready, [ :pointer ], :fdb_error, :blocking => true
78
- attach_function :fdb_future_is_ready, [ :pointer ], :fdb_bool
79
-
80
- callback :fdb_future_callback, [ :pointer, :pointer ], :void
81
- attach_function :fdb_future_set_callback, [ :pointer, :fdb_future_callback, :pointer ], :fdb_error
82
-
83
- attach_function :fdb_future_get_error, [ :pointer ], :fdb_error
84
- attach_function :fdb_future_get_version, [ :pointer, :pointer ], :fdb_error
85
- attach_function :fdb_future_get_key, [ :pointer, :pointer, :pointer ], :fdb_error
86
- attach_function :fdb_future_get_cluster, [ :pointer, :pointer ], :fdb_error
87
- attach_function :fdb_future_get_database, [ :pointer, :pointer ], :fdb_error
88
- attach_function :fdb_future_get_value, [ :pointer, :pointer, :pointer, :pointer ], :fdb_error
89
- attach_function :fdb_future_get_keyvalue_array, [ :pointer, :pointer, :pointer, :pointer ], :fdb_error
90
- attach_function :fdb_future_get_string_array, [ :pointer, :pointer, :pointer ], :fdb_error
91
-
92
- attach_function :fdb_create_cluster, [ :string ], :pointer
93
- attach_function :fdb_cluster_destroy, [ :pointer ], :void
94
- attach_function :fdb_cluster_set_option, [ :pointer, :int, :pointer, :int ], :fdb_error
95
-
96
- attach_function :fdb_cluster_create_database, [ :pointer, :pointer, :int ], :pointer
97
- attach_function :fdb_database_destroy, [ :pointer ], :void
98
- attach_function :fdb_database_set_option, [ :pointer, :int, :pointer, :int ], :fdb_error
99
-
100
- attach_function :fdb_database_create_transaction, [ :pointer, :pointer ], :fdb_error
101
- attach_function :fdb_transaction_destroy, [ :pointer ], :void
102
- attach_function :fdb_transaction_cancel, [ :pointer ], :void
103
- attach_function :fdb_transaction_atomic_op, [ :pointer, :pointer, :int, :pointer, :int, :int ], :void
104
- attach_function :fdb_transaction_add_conflict_range, [ :pointer, :pointer, :int, :pointer, :int, :int ], :int
105
- attach_function :fdb_transaction_get_addresses_for_key, [ :pointer, :pointer, :int ], :pointer
106
- attach_function :fdb_transaction_set_option, [ :pointer, :int, :pointer, :int ], :fdb_error
107
- attach_function :fdb_transaction_set_read_version, [ :pointer, :int64 ], :void
108
- attach_function :fdb_transaction_get_read_version, [ :pointer ], :pointer
109
- attach_function :fdb_transaction_get, [ :pointer, :pointer, :int, :int ], :pointer
110
- attach_function :fdb_transaction_get_key, [ :pointer, :pointer, :int, :int, :int, :int ], :pointer
111
- attach_function :fdb_transaction_get_range, [ :pointer, :pointer, :int, :int, :int, :pointer, :int, :int, :int, :int, :int, :int, :int, :int, :int ], :pointer
112
- attach_function :fdb_transaction_set, [ :pointer, :pointer, :int, :pointer, :int ], :void
113
- attach_function :fdb_transaction_clear, [ :pointer, :pointer, :int ], :void
114
- attach_function :fdb_transaction_clear_range, [ :pointer, :pointer, :int, :pointer, :int ], :void
115
- attach_function :fdb_transaction_watch, [ :pointer, :pointer, :int ], :pointer
116
- attach_function :fdb_transaction_commit, [ :pointer ], :pointer
117
- attach_function :fdb_transaction_get_committed_version, [ :pointer, :pointer ], :fdb_error
118
- attach_function :fdb_transaction_get_versionstamp, [ :pointer ], :pointer
119
- attach_function :fdb_transaction_on_error, [ :pointer, :fdb_error ], :pointer
120
- attach_function :fdb_transaction_reset, [ :pointer ], :void
121
-
122
67
  attach_function :fdb_select_api_version_impl, [ :int, :int ], :fdb_error
123
68
  attach_function :fdb_get_max_api_version, [ ], :int
124
69
 
70
+ def self.init_c_api
71
+ attach_function :fdb_get_error, [ :fdb_error ], :string
72
+
73
+ attach_function :fdb_network_set_option, [ :int, :pointer, :int ], :fdb_error
74
+ attach_function :fdb_setup_network, [ ], :fdb_error
75
+ attach_function :fdb_run_network, [ ], :fdb_error, :blocking => true
76
+ attach_function :fdb_stop_network, [ ], :fdb_error
77
+
78
+ attach_function :fdb_future_cancel, [ :pointer ], :void
79
+ attach_function :fdb_future_release_memory, [ :pointer ], :void
80
+ attach_function :fdb_future_destroy, [ :pointer ], :void
81
+ attach_function :fdb_future_block_until_ready, [ :pointer ], :fdb_error, :blocking => true
82
+ attach_function :fdb_future_is_ready, [ :pointer ], :fdb_bool
83
+
84
+ callback :fdb_future_callback, [ :pointer, :pointer ], :void
85
+ attach_function :fdb_future_set_callback, [ :pointer, :fdb_future_callback, :pointer ], :fdb_error
86
+
87
+ attach_function :fdb_future_get_error, [ :pointer ], :fdb_error
88
+ attach_function :fdb_future_get_int64, [ :pointer, :pointer ], :fdb_error
89
+ attach_function :fdb_future_get_key, [ :pointer, :pointer, :pointer ], :fdb_error
90
+ attach_function :fdb_future_get_value, [ :pointer, :pointer, :pointer, :pointer ], :fdb_error
91
+ attach_function :fdb_future_get_keyvalue_array, [ :pointer, :pointer, :pointer, :pointer ], :fdb_error
92
+ attach_function :fdb_future_get_string_array, [ :pointer, :pointer, :pointer ], :fdb_error
93
+
94
+ attach_function :fdb_create_database, [ :string, :pointer ], :fdb_error
95
+
96
+ attach_function :fdb_database_destroy, [ :pointer ], :void
97
+ attach_function :fdb_database_set_option, [ :pointer, :int, :pointer, :int ], :fdb_error
98
+
99
+ attach_function :fdb_database_create_transaction, [ :pointer, :pointer ], :fdb_error
100
+ attach_function :fdb_transaction_destroy, [ :pointer ], :void
101
+ attach_function :fdb_transaction_cancel, [ :pointer ], :void
102
+ attach_function :fdb_transaction_atomic_op, [ :pointer, :pointer, :int, :pointer, :int, :int ], :void
103
+ attach_function :fdb_transaction_add_conflict_range, [ :pointer, :pointer, :int, :pointer, :int, :int ], :int
104
+ attach_function :fdb_transaction_get_addresses_for_key, [ :pointer, :pointer, :int ], :pointer
105
+ attach_function :fdb_transaction_set_option, [ :pointer, :int, :pointer, :int ], :fdb_error
106
+ attach_function :fdb_transaction_set_read_version, [ :pointer, :int64 ], :void
107
+ attach_function :fdb_transaction_get_read_version, [ :pointer ], :pointer
108
+ attach_function :fdb_transaction_get, [ :pointer, :pointer, :int, :int ], :pointer
109
+ attach_function :fdb_transaction_get_key, [ :pointer, :pointer, :int, :int, :int, :int ], :pointer
110
+ attach_function :fdb_transaction_get_range, [ :pointer, :pointer, :int, :int, :int, :pointer, :int, :int, :int, :int, :int, :int, :int, :int, :int ], :pointer
111
+ attach_function :fdb_transaction_get_estimated_range_size_bytes, [ :pointer, :pointer, :int, :pointer, :int ], :pointer
112
+ attach_function :fdb_transaction_set, [ :pointer, :pointer, :int, :pointer, :int ], :void
113
+ attach_function :fdb_transaction_clear, [ :pointer, :pointer, :int ], :void
114
+ attach_function :fdb_transaction_clear_range, [ :pointer, :pointer, :int, :pointer, :int ], :void
115
+ attach_function :fdb_transaction_watch, [ :pointer, :pointer, :int ], :pointer
116
+ attach_function :fdb_transaction_commit, [ :pointer ], :pointer
117
+ attach_function :fdb_transaction_get_committed_version, [ :pointer, :pointer ], :fdb_error
118
+ attach_function :fdb_transaction_get_approximate_size, [ :pointer ], :pointer
119
+ attach_function :fdb_transaction_get_versionstamp, [ :pointer ], :pointer
120
+ attach_function :fdb_transaction_on_error, [ :pointer, :fdb_error ], :pointer
121
+ attach_function :fdb_transaction_reset, [ :pointer ], :void
122
+ end
123
+
125
124
  class KeyValueStruct < FFI::Struct
126
125
  pack 4
127
126
  layout :key, :pointer,
@@ -156,7 +155,7 @@ module FDB
156
155
  @@ffi_callbacks
157
156
  end
158
157
 
159
- [ "Network", "Cluster", "Database", "Transaction" ].each do |scope|
158
+ [ "Network", "Database", "Transaction" ].each do |scope|
160
159
  klass = FDB.const_set("#{scope}Options", Class.new)
161
160
  klass.class_eval do
162
161
  define_method(:initialize) do |setfunc|
@@ -170,7 +169,7 @@ module FDB
170
169
  Proc.new do || @setfunc.call(v[0], nil) end
171
170
  when String then
172
171
  Proc.new do |opt=nil| @setfunc.call(v[0], (opt.nil? ? opt : opt.encode('UTF-8')) ) end
173
- when Fixnum then
172
+ when Integer then
174
173
  Proc.new do |opt| @setfunc.call(v[0], [opt].pack("q<")) end
175
174
  else
176
175
  raise ArgumentError, "Don't know how to set options of type #{v[2].class}"
@@ -242,6 +241,10 @@ module FDB
242
241
  nil
243
242
  end
244
243
 
244
+ class << self
245
+ private :init
246
+ end
247
+
245
248
  def self.stop()
246
249
  FDBC.check_error FDBC.fdb_stop_network
247
250
  end
@@ -254,11 +257,10 @@ module FDB
254
257
  end
255
258
  end
256
259
 
257
- @@open_clusters = {}
258
260
  @@open_databases = {}
259
261
  @@cache_lock = Mutex.new
260
262
 
261
- def self.open( cluster_file = nil, database_name = "DB" )
263
+ def self.open( cluster_file = nil )
262
264
  @@network_thread_monitor.synchronize do
263
265
  if ! @@network_thread
264
266
  init
@@ -266,15 +268,13 @@ module FDB
266
268
  end
267
269
 
268
270
  @@cache_lock.synchronize do
269
- if ! @@open_clusters.has_key? cluster_file
270
- @@open_clusters[cluster_file] = create_cluster( cluster_file )
271
- end
272
-
273
- if ! @@open_databases.has_key? [cluster_file, database_name]
274
- @@open_databases[[cluster_file, database_name]] = @@open_clusters[cluster_file].open_database(database_name)
271
+ if ! @@open_databases.has_key? [cluster_file]
272
+ dpointer = FFI::MemoryPointer.new :pointer
273
+ FDBC.check_error FDBC.fdb_create_database(cluster_file, dpointer)
274
+ @@open_databases[cluster_file] = Database.new dpointer.get_pointer(0)
275
275
  end
276
276
 
277
- @@open_databases[[cluster_file, database_name]]
277
+ @@open_databases[cluster_file]
278
278
  end
279
279
  end
280
280
 
@@ -445,11 +445,11 @@ module FDB
445
445
  end
446
446
  end
447
447
 
448
- class Version < LazyFuture
448
+ class Int64Future < LazyFuture
449
449
  def getter
450
- version = FFI::MemoryPointer.new :int64
451
- FDBC.check_error FDBC.fdb_future_get_version(@fpointer, version)
452
- @value = version.read_long_long
450
+ val = FFI::MemoryPointer.new :int64
451
+ FDBC.check_error FDBC.fdb_future_get_int64(@fpointer, val)
452
+ @value = val.read_long_long
453
453
  end
454
454
  private :getter
455
455
  end
@@ -503,41 +503,6 @@ module FDB
503
503
  end
504
504
  end
505
505
 
506
- def self.create_cluster(cluster=nil)
507
- f = FDBC.fdb_create_cluster(cluster)
508
- cpointer = FFI::MemoryPointer.new :pointer
509
- FDBC.check_error FDBC.fdb_future_block_until_ready(f)
510
- FDBC.check_error FDBC.fdb_future_get_cluster(f, cpointer)
511
- Cluster.new cpointer.get_pointer(0)
512
- end
513
-
514
- class Cluster < FormerFuture
515
- attr_reader :options
516
-
517
- def self.finalize(ptr)
518
- proc do
519
- # puts "Destroying cluster #{ptr}"
520
- FDBC.fdb_cluster_destroy(ptr)
521
- end
522
- end
523
-
524
- def initialize(cpointer)
525
- @cpointer = cpointer
526
- @options = ClusterOptions.new lambda { |code, param|
527
- FDBC.check_error FDBC.fdb_cluster_set_option(cpointer, code, param, param.nil? ? 0 : param.bytesize)
528
- }
529
- ObjectSpace.define_finalizer(self, self.class.finalize(@cpointer))
530
- end
531
-
532
- def open_database(name="DB")
533
- f = FDBC.fdb_cluster_create_database(@cpointer, name, name.bytesize)
534
- dpointer = FFI::MemoryPointer.new :pointer
535
- FDBC.check_error FDBC.fdb_future_block_until_ready(f)
536
- FDBC.check_error FDBC.fdb_future_get_database(f, dpointer)
537
- Database.new dpointer.get_pointer(0)
538
- end
539
- end
540
-
541
506
  class Database < FormerFuture
542
507
  attr_reader :options
543
508
 
@@ -724,7 +689,7 @@ module FDB
724
689
  end
725
690
 
726
691
  def get_read_version
727
- Version.new(FDBC.fdb_transaction_get_read_version @tpointer)
692
+ Int64Future.new(FDBC.fdb_transaction_get_read_version @tpointer)
728
693
  end
729
694
 
730
695
  def get(key)
@@ -853,6 +818,13 @@ module FDB
853
818
  prefix = prefix.dup.force_encoding "BINARY"
854
819
  get_range(prefix, FDB.strinc(prefix), options, &block)
855
820
  end
821
+
822
+ def get_estimated_range_size_bytes(begin_key, end_key)
823
+ bkey = FDB.key_to_bytes(begin_key)
824
+ ekey = FDB.key_to_bytes(end_key)
825
+ Int64Future.new(FDBC.fdb_transaction_get_estimated_range_size_bytes(@tpointer, bkey, bkey.bytesize, ekey, ekey.bytesize))
826
+ end
827
+
856
828
  end
857
829
 
858
830
  TransactionRead.class_variable_set("@@StreamingMode", @@StreamingMode)
@@ -941,6 +913,10 @@ module FDB
941
913
  version.read_long_long
942
914
  end
943
915
 
916
+ def get_approximate_size
917
+ Int64Future.new(FDBC.fdb_transaction_get_approximate_size @tpointer)
918
+ end
919
+
944
920
  def get_versionstamp
945
921
  Key.new(FDBC.fdb_transaction_get_versionstamp(@tpointer))
946
922
  end
@@ -0,0 +1,62 @@
1
+ #encoding: BINARY
2
+
3
+ #
4
+ # fdbimpl.rb
5
+ #
6
+ # This source file is part of the FoundationDB open source project
7
+ #
8
+ # Copyright 2013-2018 Apple Inc. and the FoundationDB project authors
9
+ #
10
+ # Licensed under the Apache License, Version 2.0 (the "License");
11
+ # you may not use this file except in compliance with the License.
12
+ # You may obtain a copy of the License at
13
+ #
14
+ # http://www.apache.org/licenses/LICENSE-2.0
15
+ #
16
+ # Unless required by applicable law or agreed to in writing, software
17
+ # distributed under the License is distributed on an "AS IS" BASIS,
18
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ # See the License for the specific language governing permissions and
20
+ # limitations under the License.
21
+ #
22
+
23
+ # FoundationDB Ruby API
24
+
25
+ # Documentation for this API can be found at
26
+ # https://apple.github.io/foundationdb/api-ruby.html
27
+
28
+ module FDB
29
+ class << self
30
+ alias_method :open_impl, :open
31
+ def open( cluster_file = nil, database_name = "DB" )
32
+ if database_name != "DB"
33
+ raise Error.new(2013) # invalid_database_name
34
+ end
35
+
36
+ open_impl(cluster_file)
37
+ end
38
+
39
+ def create_cluster(cluster_file_path=nil)
40
+ Cluster.new cluster_file_path
41
+ end
42
+
43
+ public :init
44
+ end
45
+
46
+ class ClusterOptions
47
+ end
48
+
49
+ class Cluster < FormerFuture
50
+ attr_reader :options
51
+
52
+ def initialize(cluster_file_path)
53
+ @cluster_file_path = cluster_file_path
54
+ @options = ClusterOptions.new
55
+ end
56
+
57
+ def open_database(name="DB")
58
+ FDB.open(@cluster_file_path, name)
59
+ end
60
+ end
61
+
62
+ end
@@ -64,7 +64,7 @@ module FDB
64
64
  end
65
65
  _bkey = _ekey
66
66
  rescue FDB::Error => e
67
- if e.code == 1007 and _bkey != _lastbkey # if we get a past_version and *something* has happened, then we are no longer transactional
67
+ if e.code == 1007 and _bkey != _lastbkey # if we get a transaction_too_old and *something* has happened, then we are no longer transactional
68
68
  _tr = _tr.db.create_transaction
69
69
  else
70
70
  _tr.on_error(e).wait
@@ -29,9 +29,13 @@ module FDB
29
29
  "TRACE_ENABLE" => [30, "Enables trace output to a file in a directory of the clients choosing", '', "path to output directory (or NULL for current working directory)"],
30
30
  "TRACE_ROLL_SIZE" => [31, "Sets the maximum size in bytes of a single trace output file. This value should be in the range ``[0, INT64_MAX]``. If the value is set to 0, there is no limit on individual file size. The default is a maximum size of 10,485,760 bytes.", 0, "max size of a single trace output file"],
31
31
  "TRACE_MAX_LOGS_SIZE" => [32, "Sets the maximum size of all the trace output files put together. This value should be in the range ``[0, INT64_MAX]``. If the value is set to 0, there is no limit on the total size of the files. The default is a maximum size of 104,857,600 bytes. If the default roll size is used, this means that a maximum of 10 trace files will be written at a time.", 0, "max total size of trace files"],
32
- "TRACE_LOG_GROUP" => [33, "Sets the 'logGroup' attribute with the specified value for all events in the trace output files. The default log group is 'default'.", '', "value of the logGroup attribute"],
32
+ "TRACE_LOG_GROUP" => [33, "Sets the 'LogGroup' attribute with the specified value for all events in the trace output files. The default log group is 'default'.", '', "value of the LogGroup attribute"],
33
+ "TRACE_FORMAT" => [34, "Select the format of the log files. xml (the default) and json are supported.", '', "Format of trace files"],
34
+ "TRACE_CLOCK_SOURCE" => [35, "Select clock source for trace files. now (the default) or realtime are supported.", '', "Trace clock source"],
35
+ "TRACE_FILE_IDENTIFIER" => [36, "Once provided, this string will be used to replace the port/PID in the log file names.", '', "The identifier that will be part of all trace file names"],
36
+ "TRACE_PARTIAL_FILE_SUFFIX" => [39, "", '', nil],
33
37
  "KNOB" => [40, "Set internal tuning or debugging knobs", '', "knob_name=knob_value"],
34
- "TLS_PLUGIN" => [41, "Set the TLS plugin to load. This option, if used, must be set before any other TLS options", '', "file path or linker-resolved name"],
38
+ "TLS_PLUGIN" => [41, "Deprecated", '', "file path or linker-resolved name"],
35
39
  "TLS_CERT_BYTES" => [42, "Set the certificate chain", '', "certificates"],
36
40
  "TLS_CERT_PATH" => [43, "Set the file from which to load the certificate chain", '', "file path"],
37
41
  "TLS_KEY_BYTES" => [45, "Set the private key corresponding to your own certificate", '', "key"],
@@ -48,13 +52,15 @@ module FDB
48
52
  "CALLBACKS_ON_EXTERNAL_THREADS" => [61, "If set, callbacks from external client libraries can be called from threads created by the FoundationDB client library. Otherwise, callbacks will be called from either the thread used to add the callback or the network thread. Setting this option can improve performance when connected using an external client, but may not be safe to use in all environments. Must be set before setting up the network. WARNING: This feature is considered experimental at this time.", nil, nil],
49
53
  "EXTERNAL_CLIENT_LIBRARY" => [62, "Adds an external client library for use by the multi-version client API. Must be set before setting up the network.", '', "path to client library"],
50
54
  "EXTERNAL_CLIENT_DIRECTORY" => [63, "Searches the specified path for dynamic libraries and adds them to the list of client libraries for use by the multi-version client API. Must be set before setting up the network.", '', "path to directory containing client libraries"],
51
- "DISABLE_LOCAL_CLIENT" => [64, "Prevents connections through the local client, allowing only connections through externally loaded client libraries. Intended primarily for testing.", nil, nil],
55
+ "DISABLE_LOCAL_CLIENT" => [64, "Prevents connections through the local client, allowing only connections through externally loaded client libraries.", nil, nil],
56
+ "CLIENT_THREADS_PER_VERSION" => [65, "Spawns multiple worker threads for each version of the client that is loaded. Setting this to a number greater than one implies disable_local_client.", 0, "Number of client threads to be spawned. Each cluster will be serviced by a single client thread."],
52
57
  "DISABLE_CLIENT_STATISTICS_LOGGING" => [70, "Disables logging of client statistics, such as sampled transaction activity.", nil, nil],
53
- "ENABLE_SLOW_TASK_PROFILING" => [71, "Enables debugging feature to perform slow task profiling. Requires trace logging to be enabled. WARNING: this feature is not recommended for use in production.", nil, nil],
54
- }
55
-
56
- @@ClusterOption = {
57
-
58
+ "ENABLE_SLOW_TASK_PROFILING" => [71, "Deprecated", nil, nil],
59
+ "ENABLE_RUN_LOOP_PROFILING" => [71, "Enables debugging feature to perform run loop profiling. Requires trace logging to be enabled. WARNING: this feature is not recommended for use in production.", nil, nil],
60
+ "CLIENT_BUGGIFY_ENABLE" => [80, "Enable client buggify - will make requests randomly fail (intended for client testing)", nil, nil],
61
+ "CLIENT_BUGGIFY_DISABLE" => [81, "Disable client buggify", nil, nil],
62
+ "CLIENT_BUGGIFY_SECTION_ACTIVATED_PROBABILITY" => [82, "Set the probability of a CLIENT_BUGGIFY section being active for the current execution.", 0, "probability expressed as a percentage between 0 and 100"],
63
+ "CLIENT_BUGGIFY_SECTION_FIRED_PROBABILITY" => [83, "Set the probability of an active CLIENT_BUGGIFY section being fired. A section will only fire if it was activated", 0, "probability expressed as a percentage between 0 and 100"],
58
64
  }
59
65
 
60
66
  @@DatabaseOption = {
@@ -62,12 +68,23 @@ module FDB
62
68
  "MAX_WATCHES" => [20, "Set the maximum number of watches allowed to be outstanding on a database connection. Increasing this number could result in increased resource usage. Reducing this number will not cancel any outstanding watches. Defaults to 10000 and cannot be larger than 1000000.", 0, "Max outstanding watches"],
63
69
  "MACHINE_ID" => [21, "Specify the machine ID that was passed to fdbserver processes running on the same machine as this client, for better location-aware load balancing.", '', "Hexadecimal ID"],
64
70
  "DATACENTER_ID" => [22, "Specify the datacenter ID that was passed to fdbserver processes running in the same datacenter as this client, for better location-aware load balancing.", '', "Hexadecimal ID"],
71
+ "SNAPSHOT_RYW_ENABLE" => [26, "Snapshot read operations will see the results of writes done in the same transaction. This is the default behavior.", nil, nil],
72
+ "SNAPSHOT_RYW_DISABLE" => [27, "Snapshot read operations will not see the results of writes done in the same transaction. This was the default behavior prior to API version 300.", nil, nil],
73
+ "TRANSACTION_LOGGING_MAX_FIELD_LENGTH" => [405, "Sets the maximum escaped length of key and value fields to be logged to the trace file via the LOG_TRANSACTION option. This sets the ``transaction_logging_max_field_length`` option of each transaction created by this database. See the transaction option description for more information.", 0, "Maximum length of escaped key and value fields."],
74
+ "TRANSACTION_TIMEOUT" => [500, "Set a timeout in milliseconds which, when elapsed, will cause each transaction automatically to be cancelled. This sets the ``timeout`` option of each transaction created by this database. See the transaction option description for more information. Using this option requires that the API version is 610 or higher.", 0, "value in milliseconds of timeout"],
75
+ "TRANSACTION_RETRY_LIMIT" => [501, "Set a maximum number of retries after which additional calls to ``onError`` will throw the most recently seen error code. This sets the ``retry_limit`` option of each transaction created by this database. See the transaction option description for more information.", 0, "number of times to retry"],
76
+ "TRANSACTION_MAX_RETRY_DELAY" => [502, "Set the maximum amount of backoff delay incurred in the call to ``onError`` if the error is retryable. This sets the ``max_retry_delay`` option of each transaction created by this database. See the transaction option description for more information.", 0, "value in milliseconds of maximum delay"],
77
+ "TRANSACTION_SIZE_LIMIT" => [503, "Set the maximum transaction size in bytes. This sets the ``size_limit`` option on each transaction created by this database. See the transaction option description for more information.", 0, "value in bytes"],
78
+ "TRANSACTION_CAUSAL_READ_RISKY" => [504, "The read version will be committed, and usually will be the latest committed, but might not be the latest committed in the event of a simultaneous fault and misbehaving clock.", nil, nil],
79
+ "TRANSACTION_INCLUDE_PORT_IN_ADDRESS" => [505, "Addresses returned by get_addresses_for_key include the port when enabled. As of api version 630, this option is enabled by default and setting this has no effect.", nil, nil],
80
+ "TRANSACTION_BYPASS_UNREADABLE" => [700, "Allows ``get`` operations to read from sections of keyspace that have become unreadable because of versionstamp operations. This sets the ``bypass_unreadable`` option of each transaction created by this database. See the transaction option description for more information.", nil, nil],
65
81
  }
66
82
 
67
83
  @@TransactionOption = {
68
84
  "CAUSAL_WRITE_RISKY" => [10, "The transaction, if not self-conflicting, may be committed a second time after commit succeeds, in the event of a fault", nil, nil],
69
- "CAUSAL_READ_RISKY" => [20, "The read version will be committed, and usually will be the latest committed, but might not be the latest committed in the event of a fault or partition", nil, nil],
85
+ "CAUSAL_READ_RISKY" => [20, "The read version will be committed, and usually will be the latest committed, but might not be the latest committed in the event of a simultaneous fault and misbehaving clock.", nil, nil],
70
86
  "CAUSAL_READ_DISABLE" => [21, "", nil, nil],
87
+ "INCLUDE_PORT_IN_ADDRESS" => [23, "Addresses returned by get_addresses_for_key include the port when enabled. As of api version 630, this option is enabled by default and setting this has no effect.", nil, nil],
71
88
  "NEXT_WRITE_NO_WRITE_CONFLICT_RANGE" => [30, "The next write performed on this transaction will not generate a write conflict range. As a result, other transactions which read the key(s) being modified by the next write will not conflict with this transaction. Care needs to be taken when using this option on a transaction that is shared between multiple threads. When setting this option, write conflict ranges will be disabled on the next write operation, regardless of what thread it is on.", nil, nil],
72
89
  "READ_YOUR_WRITES_DISABLE" => [51, "Reads performed by a transaction will not see any prior mutations that occured in that transaction, instead seeing the value which was in the database at the transaction's read version. This option may provide a small performance benefit for the client, but also disables a number of client-side optimizations which are beneficial for transactions which tend to read and write the same keys within a single transaction.", nil, nil],
73
90
  "READ_AHEAD_DISABLE" => [52, "Deprecated", nil, nil],
@@ -75,25 +92,36 @@ module FDB
75
92
  "DURABILITY_RISKY" => [120, "", nil, nil],
76
93
  "DURABILITY_DEV_NULL_IS_WEB_SCALE" => [130, "Deprecated", nil, nil],
77
94
  "PRIORITY_SYSTEM_IMMEDIATE" => [200, "Specifies that this transaction should be treated as highest priority and that lower priority transactions should block behind this one. Use is discouraged outside of low-level tools", nil, nil],
78
- "PRIORITY_BATCH" => [201, "Specifies that this transaction should be treated as low priority and that default priority transactions should be processed first. Useful for doing batch work simultaneously with latency-sensitive work", nil, nil],
95
+ "PRIORITY_BATCH" => [201, "Specifies that this transaction should be treated as low priority and that default priority transactions will be processed first. Batch priority transactions will also be throttled at load levels smaller than for other types of transactions and may be fully cut off in the event of machine failures. Useful for doing batch work simultaneously with latency-sensitive work", nil, nil],
79
96
  "INITIALIZE_NEW_DATABASE" => [300, "This is a write-only transaction which sets the initial configuration. This option is designed for use by database system tools only.", nil, nil],
80
97
  "ACCESS_SYSTEM_KEYS" => [301, "Allows this transaction to read and modify system keys (those that start with the byte 0xFF)", nil, nil],
81
98
  "READ_SYSTEM_KEYS" => [302, "Allows this transaction to read system keys (those that start with the byte 0xFF)", nil, nil],
82
99
  "DEBUG_RETRY_LOGGING" => [401, "", '', "Optional transaction name"],
83
- "TRANSACTION_LOGGING_ENABLE" => [402, "Enables tracing for this transaction and logs results to the client trace logs. Client trace logging must be enabled to get log output.", '', "String identifier to be used in the logs when tracing this transaction. The identifier must not exceed 100 characters."],
84
- "TIMEOUT" => [500, "Set a timeout in milliseconds which, when elapsed, will cause the transaction automatically to be cancelled. Valid parameter values are ``[0, INT_MAX]``. If set to 0, will disable all timeouts. All pending and any future uses of the transaction will throw an exception. The transaction can be used again after it is reset. Like all transaction options, a timeout must be reset after a call to onError. This behavior allows the user to make the timeout dynamic.", 0, "value in milliseconds of timeout"],
85
- "RETRY_LIMIT" => [501, "Set a maximum number of retries after which additional calls to onError will throw the most recently seen error code. Valid parameter values are ``[-1, INT_MAX]``. If set to -1, will disable the retry limit. Like all transaction options, the retry limit must be reset after a call to onError. This behavior allows the user to make the retry limit dynamic.", 0, "number of times to retry"],
86
- "MAX_RETRY_DELAY" => [502, "Set the maximum amount of backoff delay incurred in the call to onError if the error is retryable. Defaults to 1000 ms. Valid parameter values are ``[0, INT_MAX]``. Like all transaction options, the maximum retry delay must be reset after a call to onError. If the maximum retry delay is less than the current retry delay of the transaction, then the current retry delay will be clamped to the maximum retry delay.", 0, "value in milliseconds of maximum delay"],
87
- "SNAPSHOT_RYW_ENABLE" => [600, "Snapshot read operations will see the results of writes done in the same transaction.", nil, nil],
88
- "SNAPSHOT_RYW_DISABLE" => [601, "Snapshot read operations will not see the results of writes done in the same transaction.", nil, nil],
89
- "LOCK_AWARE" => [700, "The transaction can read and write to locked databases, and is resposible for checking that it took the lock.", nil, nil],
100
+ "TRANSACTION_LOGGING_ENABLE" => [402, "Deprecated", '', "String identifier to be used in the logs when tracing this transaction. The identifier must not exceed 100 characters."],
101
+ "DEBUG_TRANSACTION_IDENTIFIER" => [403, "Sets a client provided identifier for the transaction that will be used in scenarios like tracing or profiling. Client trace logging or transaction profiling must be separately enabled.", '', "String identifier to be used when tracing or profiling this transaction. The identifier must not exceed 100 characters."],
102
+ "LOG_TRANSACTION" => [404, "Enables tracing for this transaction and logs results to the client trace logs. The DEBUG_TRANSACTION_IDENTIFIER option must be set before using this option, and client trace logging must be enabled to get log output.", nil, nil],
103
+ "TRANSACTION_LOGGING_MAX_FIELD_LENGTH" => [405, "Sets the maximum escaped length of key and value fields to be logged to the trace file via the LOG_TRANSACTION option, after which the field will be truncated. A negative value disables truncation.", 0, "Maximum length of escaped key and value fields."],
104
+ "SERVER_REQUEST_TRACING" => [406, "Sets an identifier for server tracing of this transaction. When committed, this identifier triggers logging when each part of the transaction authority encounters it, which is helpful in diagnosing slowness in misbehaving clusters. The identifier is randomly generated. When there is also a debug_transaction_identifier, both IDs are logged together.", nil, nil],
105
+ "TIMEOUT" => [500, "Set a timeout in milliseconds which, when elapsed, will cause the transaction automatically to be cancelled. Valid parameter values are ``[0, INT_MAX]``. If set to 0, will disable all timeouts. All pending and any future uses of the transaction will throw an exception. The transaction can be used again after it is reset. Prior to API version 610, like all other transaction options, the timeout must be reset after a call to ``onError``. If the API version is 610 or greater, the timeout is not reset after an ``onError`` call. This allows the user to specify a longer timeout on specific transactions than the default timeout specified through the ``transaction_timeout`` database option without the shorter database timeout cancelling transactions that encounter a retryable error. Note that at all API versions, it is safe and legal to set the timeout each time the transaction begins, so most code written assuming the older behavior can be upgraded to the newer behavior without requiring any modification, and the caller is not required to implement special logic in retry loops to only conditionally set this option.", 0, "value in milliseconds of timeout"],
106
+ "RETRY_LIMIT" => [501, "Set a maximum number of retries after which additional calls to ``onError`` will throw the most recently seen error code. Valid parameter values are ``[-1, INT_MAX]``. If set to -1, will disable the retry limit. Prior to API version 610, like all other transaction options, the retry limit must be reset after a call to ``onError``. If the API version is 610 or greater, the retry limit is not reset after an ``onError`` call. Note that at all API versions, it is safe and legal to set the retry limit each time the transaction begins, so most code written assuming the older behavior can be upgraded to the newer behavior without requiring any modification, and the caller is not required to implement special logic in retry loops to only conditionally set this option.", 0, "number of times to retry"],
107
+ "MAX_RETRY_DELAY" => [502, "Set the maximum amount of backoff delay incurred in the call to ``onError`` if the error is retryable. Defaults to 1000 ms. Valid parameter values are ``[0, INT_MAX]``. If the maximum retry delay is less than the current retry delay of the transaction, then the current retry delay will be clamped to the maximum retry delay. Prior to API version 610, like all other transaction options, the maximum retry delay must be reset after a call to ``onError``. If the API version is 610 or greater, the retry limit is not reset after an ``onError`` call. Note that at all API versions, it is safe and legal to set the maximum retry delay each time the transaction begins, so most code written assuming the older behavior can be upgraded to the newer behavior without requiring any modification, and the caller is not required to implement special logic in retry loops to only conditionally set this option.", 0, "value in milliseconds of maximum delay"],
108
+ "SIZE_LIMIT" => [503, "Set the transaction size limit in bytes. The size is calculated by combining the sizes of all keys and values written or mutated, all key ranges cleared, and all read and write conflict ranges. (In other words, it includes the total size of all data included in the request to the cluster to commit the transaction.) Large transactions can cause performance problems on FoundationDB clusters, so setting this limit to a smaller value than the default can help prevent the client from accidentally degrading the cluster's performance. This value must be at least 32 and cannot be set to higher than 10,000,000, the default transaction size limit.", 0, "value in bytes"],
109
+ "SNAPSHOT_RYW_ENABLE" => [600, "Snapshot read operations will see the results of writes done in the same transaction. This is the default behavior.", nil, nil],
110
+ "SNAPSHOT_RYW_DISABLE" => [601, "Snapshot read operations will not see the results of writes done in the same transaction. This was the default behavior prior to API version 300.", nil, nil],
111
+ "LOCK_AWARE" => [700, "The transaction can read and write to locked databases, and is responsible for checking that it took the lock.", nil, nil],
90
112
  "USED_DURING_COMMIT_PROTECTION_DISABLE" => [701, "By default, operations that are performed on a transaction while it is being committed will not only fail themselves, but they will attempt to fail other in-flight operations (such as the commit) as well. This behavior is intended to help developers discover situations where operations could be unintentionally executed after the transaction has been reset. Setting this option removes that protection, causing only the offending operation to fail.", nil, nil],
91
113
  "READ_LOCK_AWARE" => [702, "The transaction can read from locked databases.", nil, nil],
114
+ "USE_PROVISIONAL_PROXIES" => [711, "This option should only be used by tools which change the database configuration.", nil, nil],
115
+ "REPORT_CONFLICTING_KEYS" => [712, "The transaction can retrieve keys that are conflicting with other transactions.", nil, nil],
116
+ "SPECIAL_KEY_SPACE_RELAXED" => [713, "By default, the special key space will only allow users to read from exactly one module (a subspace in the special key space). Use this option to allow reading from zero or more modules. Users who set this option should be prepared for new modules, which may have different behaviors than the modules they're currently reading. For example, a new module might block or return an error.", nil, nil],
117
+ "TAG" => [800, "Adds a tag to the transaction that can be used to apply manual targeted throttling. At most 5 tags can be set on a transaction.", '', "String identifier used to associated this transaction with a throttling group. Must not exceed 16 characters."],
118
+ "AUTO_THROTTLE_TAG" => [801, "Adds a tag to the transaction that can be used to apply manual or automatic targeted throttling. At most 5 tags can be set on a transaction.", '', "String identifier used to associated this transaction with a throttling group. Must not exceed 16 characters."],
119
+ "BYPASS_UNREADABLE" => [1100, "Allows ``get`` operations to read from sections of keyspace that have become unreadable because of versionstamp operations. These reads will view versionstamp operations as if they were set operations that did not fill in the versionstamp.", nil, nil],
92
120
  }
93
121
 
94
122
  @@StreamingMode = {
95
123
  "WANT_ALL" => [-2, "Client intends to consume the entire range and would like it all transferred as early as possible.", nil, nil],
96
- "ITERATOR" => [-1, "The default. The client doesn't know how much of the range it is likely to used and wants different performance concerns to be balanced. Only a small portion of data is transferred to the client initially (in order to minimize costs if the client doesn't read the entire range), and as the caller iterates over more items in the range larger batches will be transferred in order to minimize latency.", nil, nil],
124
+ "ITERATOR" => [-1, "The default. The client doesn't know how much of the range it is likely to used and wants different performance concerns to be balanced. Only a small portion of data is transferred to the client initially (in order to minimize costs if the client doesn't read the entire range), and as the caller iterates over more items in the range larger batches will be transferred in order to minimize latency. After enough iterations, the iterator mode will eventually reach the same byte limit as ``WANT_ALL``", nil, nil],
97
125
  "EXACT" => [0, "Infrequently used. The client has passed a specific row limit and wants that many rows delivered in a single batch. Because of iterator operation in client drivers make request batches transparent to the user, consider ``WANT_ALL`` StreamingMode instead. A row limit must be specified if this mode is used.", nil, nil],
98
126
  "SMALL" => [1, "Infrequently used. Transfer data in batches small enough to not be much more expensive than reading individual rows, to minimize cost if iteration stops early.", nil, nil],
99
127
  "MEDIUM" => [2, "Infrequently used. Transfer data in batches sized in between small and large.", nil, nil],
@@ -112,10 +140,11 @@ module FDB
112
140
  "APPEND_IF_FITS" => [9, "Appends ``param`` to the end of the existing value already in the database at the given key (or creates the key and sets the value to ``param`` if the key is empty). This will only append the value if the final concatenated value size is less than or equal to the maximum value size (i.e., if it fits). WARNING: No error is surfaced back to the user if the final value is too large because the mutation will not be applied until after the transaction has been committed. Therefore, it is only safe to use this mutation type if one can guarantee that one will keep the total value size under the maximum size.", '', "value to append to the database value"],
113
141
  "MAX" => [12, "Performs a little-endian comparison of byte strings. If the existing value in the database is not present or shorter than ``param``, it is first extended to the length of ``param`` with zero bytes. If ``param`` is shorter than the existing value in the database, the existing value is truncated to match the length of ``param``. The larger of the two values is then stored in the database.", '', "value to check against database value"],
114
142
  "MIN" => [13, "Performs a little-endian comparison of byte strings. If the existing value in the database is not present, then ``param`` is stored in the database. If the existing value in the database is shorter than ``param``, it is first extended to the length of ``param`` with zero bytes. If ``param`` is shorter than the existing value in the database, the existing value is truncated to match the length of ``param``. The smaller of the two values is then stored in the database.", '', "value to check against database value"],
115
- "SET_VERSIONSTAMPED_KEY" => [14, "Transforms ``key`` using a versionstamp for the transaction. Sets the transformed key in the database to ``param``. The key is transformed by removing the final four bytes from the key and reading those as a little-Endian 32-bit integer to get a position ``pos``. The 10 bytes of the key from ``pos`` to ``pos + 10`` are replaced with the versionstamp of the transaction used. The first byte of the key is position 0. A versionstamp is a 10 byte, unique, monotonically (but not sequentially) increasing value for each committed transaction. The first 8 bytes are the committed version of the database (serialized in big-Endian order). The last 2 bytes are monotonic in the serialization order for transactions. WARNING: At this time, versionstamps are compatible with the Tuple layer only in the Java and Python bindings. Also, note that prior to API version 520, the offset was computed from only the final two bytes rather than the final four bytes.", '', "value to which to set the transformed key"],
116
- "SET_VERSIONSTAMPED_VALUE" => [15, "Transforms ``param`` using a versionstamp for the transaction. Sets the ``key`` given to the transformed ``param``. The parameter is transformed by removing the final four bytes from ``param`` and reading those as a little-Endian 32-bit integer to get a position ``pos``. The 10 bytes of the parameter from ``pos`` to ``pos + 10`` are replaced with the versionstamp of the transaction used. The first byte of the parameter is position 0. A versionstamp is a 10 byte, unique, monotonically (but not sequentially) increasing value for each committed transaction. The first 8 bytes are the committed version of the database (serialized in big-Endian order). The last 2 bytes are monotonic in the serialization order for transactions. WARNING: At this time, versionstamps are compatible with the Tuple layer only in the Java and Python bindings. Also, note that prior to API version 520, the versionstamp was always placed at the beginning of the parameter rather than computing an offset.", '', "value to versionstamp and set"],
143
+ "SET_VERSIONSTAMPED_KEY" => [14, "Transforms ``key`` using a versionstamp for the transaction. Sets the transformed key in the database to ``param``. The key is transformed by removing the final four bytes from the key and reading those as a little-Endian 32-bit integer to get a position ``pos``. The 10 bytes of the key from ``pos`` to ``pos + 10`` are replaced with the versionstamp of the transaction used. The first byte of the key is position 0. A versionstamp is a 10 byte, unique, monotonically (but not sequentially) increasing value for each committed transaction. The first 8 bytes are the committed version of the database (serialized in big-Endian order). The last 2 bytes are monotonic in the serialization order for transactions. WARNING: At this time, versionstamps are compatible with the Tuple layer only in the Java, Python, and Go bindings. Also, note that prior to API version 520, the offset was computed from only the final two bytes rather than the final four bytes.", '', "value to which to set the transformed key"],
144
+ "SET_VERSIONSTAMPED_VALUE" => [15, "Transforms ``param`` using a versionstamp for the transaction. Sets the ``key`` given to the transformed ``param``. The parameter is transformed by removing the final four bytes from ``param`` and reading those as a little-Endian 32-bit integer to get a position ``pos``. The 10 bytes of the parameter from ``pos`` to ``pos + 10`` are replaced with the versionstamp of the transaction used. The first byte of the parameter is position 0. A versionstamp is a 10 byte, unique, monotonically (but not sequentially) increasing value for each committed transaction. The first 8 bytes are the committed version of the database (serialized in big-Endian order). The last 2 bytes are monotonic in the serialization order for transactions. WARNING: At this time, versionstamps are compatible with the Tuple layer only in the Java, Python, and Go bindings. Also, note that prior to API version 520, the versionstamp was always placed at the beginning of the parameter rather than computing an offset.", '', "value to versionstamp and set"],
117
145
  "BYTE_MIN" => [16, "Performs lexicographic comparison of byte strings. If the existing value in the database is not present, then ``param`` is stored. Otherwise the smaller of the two values is then stored in the database.", '', "value to check against database value"],
118
146
  "BYTE_MAX" => [17, "Performs lexicographic comparison of byte strings. If the existing value in the database is not present, then ``param`` is stored. Otherwise the larger of the two values is then stored in the database.", '', "value to check against database value"],
147
+ "COMPARE_AND_CLEAR" => [20, "Performs an atomic ``compare and clear`` operation. If the existing value in the database is equal to the given value, then given key is cleared.", '', "Value to compare with"],
119
148
  }
120
149
 
121
150
  @@ConflictRangeType = {
@@ -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: 5.2.6
4
+ version: 6.3.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - FoundationDB
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-10 00:00:00.000000000 Z
11
+ date: 2021-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -34,14 +34,15 @@ executables: []
34
34
  extensions: []
35
35
  extra_rdoc_files: []
36
36
  files:
37
- - LICENSE
38
- - lib/fdb.rb
39
- - lib/fdbdirectory.rb
40
- - lib/fdbimpl.rb
41
- - lib/fdblocality.rb
42
- - lib/fdboptions.rb
43
- - lib/fdbsubspace.rb
44
- - lib/fdbtuple.rb
37
+ - "/root/src/oOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOo/foundationdb/LICENSE"
38
+ - "/root/src/oOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOo/foundationdb/bindings/ruby/lib/fdb.rb"
39
+ - "/root/src/oOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOo/foundationdb/bindings/ruby/lib/fdbdirectory.rb"
40
+ - "/root/src/oOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOo/foundationdb/bindings/ruby/lib/fdbimpl.rb"
41
+ - "/root/src/oOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOo/foundationdb/bindings/ruby/lib/fdbimpl_v609.rb"
42
+ - "/root/src/oOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOo/foundationdb/bindings/ruby/lib/fdblocality.rb"
43
+ - "/root/src/oOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOo/foundationdb/bindings/ruby/lib/fdboptions.rb"
44
+ - "/root/src/oOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOo/foundationdb/bindings/ruby/lib/fdbsubspace.rb"
45
+ - "/root/src/oOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOo/foundationdb/bindings/ruby/lib/fdbtuple.rb"
45
46
  homepage: https://www.foundationdb.org
46
47
  licenses:
47
48
  - Apache v2
@@ -64,7 +65,7 @@ requirements:
64
65
  - These bindings require the FoundationDB client. The client can be obtained from
65
66
  https://www.foundationdb.org/download/.
66
67
  rubyforge_project:
67
- rubygems_version: 2.2.2
68
+ rubygems_version: 2.6.14.4
68
69
  signing_key:
69
70
  specification_version: 4
70
71
  summary: Ruby bindings for the FoundationDB database