aerospike 2.29.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +30 -0
  3. data/README.md +13 -9
  4. data/lib/aerospike/batch_attr.rb +292 -0
  5. data/lib/aerospike/batch_delete.rb +48 -0
  6. data/lib/aerospike/batch_read.rb +97 -0
  7. data/lib/aerospike/batch_record.rb +83 -0
  8. data/lib/aerospike/batch_results.rb +38 -0
  9. data/lib/aerospike/batch_udf.rb +76 -0
  10. data/lib/aerospike/batch_write.rb +79 -0
  11. data/lib/aerospike/cdt/bit_operation.rb +4 -5
  12. data/lib/aerospike/cdt/map_operation.rb +24 -10
  13. data/lib/aerospike/cdt/map_policy.rb +6 -3
  14. data/lib/aerospike/cdt/map_return_type.rb +8 -0
  15. data/lib/aerospike/client.rb +39 -56
  16. data/lib/aerospike/cluster.rb +50 -46
  17. data/lib/aerospike/command/batch_index_command.rb +7 -11
  18. data/lib/aerospike/command/batch_index_node.rb +3 -4
  19. data/lib/aerospike/command/batch_operate_command.rb +151 -0
  20. data/lib/aerospike/command/batch_operate_node.rb +51 -0
  21. data/lib/aerospike/command/command.rb +231 -128
  22. data/lib/aerospike/exp/exp.rb +54 -27
  23. data/lib/aerospike/exp/exp_bit.rb +24 -24
  24. data/lib/aerospike/exp/exp_hll.rb +12 -12
  25. data/lib/aerospike/exp/exp_list.rb +101 -86
  26. data/lib/aerospike/exp/exp_map.rb +118 -110
  27. data/lib/aerospike/exp/operation.rb +2 -2
  28. data/lib/aerospike/info.rb +2 -4
  29. data/lib/aerospike/node.rb +20 -3
  30. data/lib/aerospike/operation.rb +38 -0
  31. data/lib/aerospike/policy/batch_delete_policy.rb +71 -0
  32. data/lib/aerospike/policy/batch_policy.rb +53 -4
  33. data/lib/aerospike/{command/batch_direct_node.rb → policy/batch_read_policy.rb} +17 -19
  34. data/lib/aerospike/policy/batch_udf_policy.rb +75 -0
  35. data/lib/aerospike/policy/batch_write_policy.rb +105 -0
  36. data/lib/aerospike/policy/policy.rb +3 -40
  37. data/lib/aerospike/query/query_command.rb +3 -205
  38. data/lib/aerospike/query/query_executor.rb +2 -2
  39. data/lib/aerospike/query/query_partition_command.rb +4 -230
  40. data/lib/aerospike/query/scan_executor.rb +2 -2
  41. data/lib/aerospike/query/scan_partition_command.rb +3 -3
  42. data/lib/aerospike/query/server_command.rb +2 -2
  43. data/lib/aerospike/query/statement.rb +5 -21
  44. data/lib/aerospike/task/execute_task.rb +2 -2
  45. data/lib/aerospike/utils/buffer.rb +15 -15
  46. data/lib/aerospike/version.rb +1 -1
  47. data/lib/aerospike.rb +13 -12
  48. metadata +16 -14
  49. data/lib/aerospike/command/batch_direct_command.rb +0 -105
  50. data/lib/aerospike/command/batch_direct_exists_command.rb +0 -51
  51. data/lib/aerospike/query/pred_exp/and_or.rb +0 -32
  52. data/lib/aerospike/query/pred_exp/geo_json_value.rb +0 -41
  53. data/lib/aerospike/query/pred_exp/integer_value.rb +0 -32
  54. data/lib/aerospike/query/pred_exp/op.rb +0 -27
  55. data/lib/aerospike/query/pred_exp/regex.rb +0 -32
  56. data/lib/aerospike/query/pred_exp/regex_flags.rb +0 -23
  57. data/lib/aerospike/query/pred_exp/string_value.rb +0 -29
  58. data/lib/aerospike/query/pred_exp.rb +0 -192
@@ -0,0 +1,76 @@
1
+ # encoding: utf-8
2
+ # Copyright 2014-2024 Aerospike, Inc.
3
+ #
4
+ # Portions may be licensed to Aerospike, Inc. under one or more contributor
5
+ # license agreements.
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License") you may not
8
+ # use this file except in compliance with the License. You may obtain a copy of
9
+ # the License at http:#www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ # License for the specific language governing permissions and limitations under
15
+ # the License.
16
+
17
+ # Batch key and read only operations with default policy.
18
+ # Used in batch read commands where different bins are needed for each key.
19
+
20
+ module Aerospike
21
+
22
+ # Batch user defined functions.
23
+ class BatchUDF < BatchRecord
24
+
25
+ # Optional UDF policy.
26
+ attr_accessor :policy
27
+
28
+ # Package or lua module name.
29
+ attr_accessor :package_name
30
+
31
+ # Lua function name.
32
+ attr_accessor :function_name
33
+
34
+ # Optional arguments to lua function.
35
+ attr_accessor :function_args
36
+
37
+ # Wire protocol bytes for function args. For internal use only.
38
+ attr_reader :arg_bytes
39
+
40
+ # Constructor using default policy.
41
+ def initialize(key, package_name, function_name, function_args, opt = {})
42
+ super(key, has_write: true)
43
+ @policy = BatchRecord.create_policy(opt, BatchUDFPolicy, DEFAULT_BATCH_UDF_POLICY)
44
+ @package_name = package_name
45
+ @function_name = function_name
46
+ @function_args = ListValue.new(function_args)
47
+ # Do not set arg_bytes here because may not be necessary if batch repeat flag is used.
48
+ end
49
+
50
+ # Optimized reference equality check to determine batch wire protocol repeat flag.
51
+ # For internal use only.
52
+ def ==(other) # :nodoc:
53
+ other && other.instance_of?(self.class) &&
54
+ @function_name == other.function_name && @function_args == other.function_args &&
55
+ @package_name == other.package_name && @policy == other.policy
56
+ end
57
+
58
+ DEFAULT_BATCH_UDF_POLICY = BatchUDFPolicy.new
59
+
60
+ # Return wire protocol size. For internal use only.
61
+ def size # :nodoc:
62
+ size = 6 # gen(2) + exp(4) = 6
63
+
64
+ size += @policy&.filter_exp&.size if @policy&.filter_exp
65
+
66
+ if @policy&.send_key
67
+ size += @key.user_key.estimate_size + Aerospike::FIELD_HEADER_SIZE + 1
68
+ end
69
+ size += @package_name.bytesize + Aerospike::FIELD_HEADER_SIZE
70
+ size += @function_name.bytesize + Aerospike::FIELD_HEADER_SIZE
71
+ @arg_bytes = @function_args.to_bytes
72
+ size += @arg_bytes.bytesize + Aerospike::FIELD_HEADER_SIZE
73
+ size
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,79 @@
1
+ # encoding: utf-8
2
+ # Copyright 2014-2024 Aerospike, Inc.
3
+ #
4
+ # Portions may be licensed to Aerospike, Inc. under one or more contributor
5
+ # license agreements.
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License") you may not
8
+ # use this file except in compliance with the License. You may obtain a copy of
9
+ # the License at http:#www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ # License for the specific language governing permissions and limitations under
15
+ # the License.
16
+
17
+ # Batch key and read only operations with default policy.
18
+ # Used in batch read commands where different bins are needed for each key.
19
+
20
+ module Aerospike
21
+
22
+ private
23
+
24
+ # Batch key and read/write operations with write policy.
25
+ class BatchWrite < BatchRecord
26
+ # Optional write policy.
27
+ attr_accessor :policy
28
+
29
+ # Required operations for this key.
30
+ attr_accessor :ops
31
+
32
+ # Initialize batch key and read/write operations.
33
+ #
34
+ # {Operation#get()} is not allowed because it returns a variable number of bins and
35
+ # makes it difficult (sometimes impossible) to lineup operations with results. Instead,
36
+ # use {Operation#get(bin_name)} for each bin name.
37
+ def initialize(key, ops, opt = {})
38
+ super(key, has_write: true)
39
+ @policy = BatchRecord.create_policy(opt, BatchWritePolicy, DEFAULT_BATCH_WRITE_POLICY)
40
+ @ops = ops
41
+ end
42
+
43
+ # Optimized reference equality check to determine batch wire protocol repeat flag.
44
+ # For internal use only.
45
+ def ==(other) # :nodoc:
46
+ other && other.instance_of?(self.class) &&
47
+ @ops == other.ops && @policy == other.policy && (@policy.nil? || !@policy.send_key)
48
+ end
49
+
50
+ DEFAULT_BATCH_WRITE_POLICY = BatchWritePolicy.new
51
+
52
+ # Return wire protocol size. For internal use only.
53
+ def size # :nodoc:
54
+ size = 6 # gen(2) + exp(4) = 6
55
+
56
+ size += @policy&.filter_exp&.size if @policy&.filter_exp
57
+
58
+ if @policy&.send_key
59
+ size += @key.user_key.estimate_size + Aerospike::FIELD_HEADER_SIZE + 1
60
+ end
61
+
62
+ has_write = false
63
+ @ops&.each do |op|
64
+ if op.is_write?
65
+ has_write = true
66
+ end
67
+
68
+ size += op.bin_name.bytesize + Aerospike::OPERATION_HEADER_SIZE if op.bin_name
69
+ size += op.bin_value.estimate_size if op.bin_value
70
+ end
71
+
72
+ unless has_write
73
+ raise AerospikeException.new(ResultCode::PARAMETER_ERROR, "Batch write operations do not contain a write")
74
+ end
75
+
76
+ size
77
+ end
78
+ end
79
+ end
@@ -65,9 +65,8 @@ module Aerospike
65
65
  @arguments = arguments
66
66
  end
67
67
 
68
-
69
68
  # BitResizeOp creates byte "resize" operation.
70
- # Server resizes byte[] to byte_size according to resize_flags (See {@link BitResizeFlags}).
69
+ # Server resizes byte[] to byte_size according to resize_flags (See {BitResizeFlags}).
71
70
  # Server does not return a value.
72
71
  # Example:
73
72
  # bin = [0b00000001, 0b01000010]
@@ -195,7 +194,7 @@ module Aerospike
195
194
  # BitAddOp creates bit "add" operation.
196
195
  # Server adds value to byte[] bin starting at bit_offset for bit_size. Bit_size must be <= 64.
197
196
  # Signed indicates if bits should be treated as a signed number.
198
- # If add overflows/underflows, {@link BitOverflowAction} is used.
197
+ # If add overflows/underflows, {BitOverflowAction} is used.
199
198
  # Server does not return a value.
200
199
  # Example:
201
200
  # bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101]
@@ -223,7 +222,7 @@ module Aerospike
223
222
  # BitSubtractOp creates bit "subtract" operation.
224
223
  # Server subtracts value from byte[] bin starting at bit_offset for bit_size. Bit_size must be <= 64.
225
224
  # Signed indicates if bits should be treated as a signed number.
226
- # If add overflows/underflows, {@link BitOverflowAction} is used.
225
+ # If add overflows/underflows, {BitOverflowAction} is used.
227
226
  # Server does not return a value.
228
227
  # Example:
229
228
  # bin = [0b00000001, 0b01000010, 0b00000011, 0b00000100, 0b00000101]
@@ -351,7 +350,7 @@ module Aerospike
351
350
  bytes = nil
352
351
  args = arguments.dup
353
352
  Packer.use do |packer|
354
- if @ctx != nil && @ctx.length > 0
353
+ if !@ctx.nil? && @ctx.length > 0
355
354
  packer.write_array_header(3)
356
355
  Value.of(0xff).pack(packer)
357
356
 
@@ -110,14 +110,23 @@ module Aerospike
110
110
  self
111
111
  end
112
112
 
113
- ##
114
- # Creates a map create operation.
115
- # Server creates map at given context level.
116
- def self.create(bin_name, order, ctx: nil)
117
- if !ctx || ctx.length == 0
113
+ # Create map create operation.
114
+ # Server creates a map at the given context level.
115
+ #
116
+ # @param [String] bin_name The bin name.
117
+ # @param [Integer] order The map order.
118
+ # @param [Boolean] persist_index If true, persist map index. A map index improves lookup performance,
119
+ # but requires more storage. A map index can be created for a top-level
120
+ # ordered map only. Nested and unordered map indexes are not supported.
121
+ # @param [String] ctx Optional path to a nested map. If not defined, the top-level map is used.
122
+ def self.create(bin_name, order, persistent_index, ctx: nil)
123
+ if !ctx || ctx.empty?
118
124
  # If context not defined, the set order for top-level bin map.
119
- self.set_policy(MapPolicy.new(order: order, flag: 0), bin_name)
125
+ attr = order[:attr]
126
+ attr += 0x10 if persistent_index
127
+ MapOperation.new(Operation::CDT_MODIFY, SET_TYPE, bin_name, attr, ctx: ctx, flag: order[:flag])
120
128
  else
129
+ # Create nested map. persistIndex does not apply here, so ignore it
121
130
  MapOperation.new(Operation::CDT_MODIFY, SET_TYPE, bin_name, order[:attr], ctx: ctx, flag: order[:flag])
122
131
  end
123
132
  end
@@ -128,7 +137,12 @@ module Aerospike
128
137
  #
129
138
  # The required map policy attributes can be changed after the map is created.
130
139
  def self.set_policy(bin_name, policy, ctx: nil)
131
- MapOperation.new(Operation::CDT_MODIFY, SET_TYPE, bin_name, policy.order[:attr], ctx: ctx)
140
+ attr = policy.attributes
141
+ # Remove persistIndex flag for nested maps.
142
+ if !ctx.nil? && !ctx.empty? && (attr & 0x10) != 0
143
+ attr &= ~0x10
144
+ end
145
+ MapOperation.new(Operation::CDT_MODIFY, SET_TYPE, bin_name, attr, ctx: ctx)
132
146
  end
133
147
 
134
148
  ##
@@ -635,7 +649,7 @@ module Aerospike
635
649
  args.unshift(return_type) if return_type
636
650
 
637
651
  Packer.use do |packer|
638
- if @ctx != nil && @ctx.length > 0
652
+ if @ctx != nil && !@ctx.empty?
639
653
  packer.write_array_header(3)
640
654
  Value.of(0xff).pack(packer)
641
655
 
@@ -645,12 +659,12 @@ module Aerospike
645
659
  Value.of(@map_op).pack(packer)
646
660
  else
647
661
  packer.write_raw_short(@map_op)
648
- if args.length > 0
662
+ if !args.empty?
649
663
  packer.write_array_header(args.length)
650
664
  end
651
665
  end
652
666
 
653
- if args.length > 0
667
+ if !args.empty?
654
668
  args.each do |value|
655
669
  Value.of(value).pack(packer)
656
670
  end
@@ -17,10 +17,9 @@
17
17
  module Aerospike
18
18
  module CDT
19
19
  class MapPolicy
20
- attr_accessor :order, :write_mode, :flags
21
- attr_accessor :item_command, :items_command, :attributes
20
+ attr_accessor :order, :write_mode, :flags, :item_command, :items_command, :attributes, :persist_index
22
21
 
23
- def initialize(order: nil, write_mode: nil, flags: nil)
22
+ def initialize(order: nil, write_mode: nil, persist_index: false, flags: nil)
24
23
  if write_mode && flags
25
24
  raise ArgumentError, "Use write mode for server versions < 4.3; use write flags for server versions >= 4.3."
26
25
  end
@@ -30,6 +29,10 @@ module Aerospike
30
29
  @flags = flags || MapWriteFlags::DEFAULT
31
30
  @attributes = order ? order[:attr] : 0
32
31
 
32
+ if @persist_index
33
+ @attributes |= 0x10
34
+ end
35
+
33
36
  case @write_mode
34
37
  when CDT::MapWriteMode::DEFAULT
35
38
  @item_command = CDT::MapOperation::PUT
@@ -69,6 +69,14 @@ module Aerospike
69
69
  # Return true if count > 0.
70
70
  EXISTS = 13
71
71
 
72
+ ##
73
+ # Return an unordered map.
74
+ UNORDERED_MAP = 16
75
+
76
+ ##
77
+ # Return an ordered map.
78
+ ORDERED_MAP = 17
79
+
72
80
  ##
73
81
  # :private
74
82
  #
@@ -36,15 +36,7 @@ module Aerospike
36
36
  # +:fail_if_not_connected+ set to true
37
37
 
38
38
  class Client
39
- attr_accessor :default_admin_policy
40
- attr_accessor :default_batch_policy
41
- attr_accessor :default_info_policy
42
- attr_accessor :default_query_policy
43
- attr_accessor :default_read_policy
44
- attr_accessor :default_scan_policy
45
- attr_accessor :default_write_policy
46
- attr_accessor :default_operate_policy
47
- attr_accessor :cluster
39
+ attr_accessor :default_admin_policy, :default_batch_policy, :default_info_policy, :default_query_policy, :default_read_policy, :default_scan_policy, :default_write_policy, :default_operate_policy, :cluster
48
40
 
49
41
  def initialize(hosts = nil, policy: ClientPolicy.new, connect: true)
50
42
  hosts = ::Aerospike::Host::Parse.(hosts || ENV["AEROSPIKE_HOSTS"] || "localhost")
@@ -230,11 +222,11 @@ module Aerospike
230
222
  str_cmd = "truncate:namespace=#{namespace}"
231
223
  str_cmd << ";set=#{set_name}" unless set_name.to_s.strip.empty?
232
224
  else
233
- if node.supports_feature?(Aerospike::Features::TRUNCATE_NAMESPACE)
234
- str_cmd = "truncate-namespace:namespace=#{namespace}"
235
- else
236
- str_cmd = "truncate:namespace=#{namespace}"
237
- end
225
+ str_cmd = if node.supports_feature?(Aerospike::Features::TRUNCATE_NAMESPACE)
226
+ "truncate-namespace:namespace=#{namespace}"
227
+ else
228
+ "truncate:namespace=#{namespace}"
229
+ end
238
230
  end
239
231
 
240
232
  if before_last_update
@@ -329,15 +321,8 @@ module Aerospike
329
321
  bin_names = nil
330
322
  end
331
323
 
332
- if policy.use_batch_direct
333
- key_map = BatchItem.generate_map(keys)
334
- execute_batch_direct_commands(policy, keys) do |node, batch|
335
- BatchDirectCommand.new(node, batch, policy, key_map, bin_names, results, info_flags)
336
- end
337
- else
338
- execute_batch_index_commands(policy, keys) do |node, batch|
339
- BatchIndexCommand.new(node, batch, policy, bin_names, results, info_flags)
340
- end
324
+ execute_batch_index_commands(policy, keys) do |node, batch|
325
+ BatchIndexCommand.new(node, batch, policy, bin_names, results, info_flags)
341
326
  end
342
327
 
343
328
  results
@@ -351,6 +336,21 @@ module Aerospike
351
336
  batch_get(keys, :none, options)
352
337
  end
353
338
 
339
+ # Operate on multiple records for specified batch keys in one batch call.
340
+ # This method allows different namespaces/bins for each key in the batch.
341
+ # The returned records are located in the same list.
342
+ #
343
+ # records can be BatchRead, BatchWrite, BatchDelete or BatchUDF.
344
+ #
345
+ # Requires server version 6.0+
346
+ def batch_operate(records, options = nil)
347
+ policy = create_policy(options, BatchPolicy, default_batch_policy)
348
+
349
+ execute_batch_operate_commands(policy, records) do |node, batch|
350
+ BatchOperateCommand.new(node, batch, policy, records)
351
+ end
352
+ end
353
+
354
354
  # Check if multiple record keys exist in one batch call.
355
355
  # The returned boolean array is in positional order with the original key array order.
356
356
  # The policy can be used to specify timeouts and protocol type.
@@ -358,15 +358,8 @@ module Aerospike
358
358
  policy = create_policy(options, BatchPolicy, default_batch_policy)
359
359
  results = Array.new(keys.length)
360
360
 
361
- if policy.use_batch_direct
362
- key_map = BatchItem.generate_map(keys)
363
- execute_batch_direct_commands(policy, keys) do |node, batch|
364
- BatchDirectExistsCommand.new(node, batch, policy, key_map, results)
365
- end
366
- else
367
- execute_batch_index_commands(policy, keys) do |node, batch|
368
- BatchIndexExistsCommand.new(node, batch, policy, results)
369
- end
361
+ execute_batch_index_commands(policy, keys) do |node, batch|
362
+ BatchIndexExistsCommand.new(node, batch, policy, results)
370
363
  end
371
364
 
372
365
  results
@@ -430,7 +423,7 @@ module Aerospike
430
423
  end
431
424
 
432
425
  if res["error"]
433
- raise Aerospike::Exceptions::CommandRejected.new("Registration failed: #{res["error"]}\nFile: #{res["file"]}\nLine: #{res["line"]}\nMessage: #{res["message"]}")
426
+ raise Aerospike::Exceptions::CommandRejected.new("Registration failed: #{res['error']}\nFile: #{res['file']}\nLine: #{res['line']}\nMessage: #{res['message']}")
434
427
  end
435
428
 
436
429
  UdfRegisterTask.new(@cluster, server_path)
@@ -529,7 +522,7 @@ module Aerospike
529
522
  # This method is only supported by Aerospike 3 servers.
530
523
  # If the policy is nil, the default relevant policy will be used.
531
524
  def execute_udf_on_query(statement, package_name, function_name, function_args = [], options = nil)
532
- policy = create_policy(options, QueryPolicy, default_query_policy)
525
+ policy = create_policy(options, WritePolicy, default_write_policy)
533
526
 
534
527
  nodes = @cluster.nodes
535
528
  if nodes.empty?
@@ -538,14 +531,12 @@ module Aerospike
538
531
 
539
532
  statement = statement.clone
540
533
  statement.set_aggregate_function(package_name, function_name, function_args, false)
541
-
542
534
  # Use a thread per node
543
535
  nodes.each do |node|
544
- partitions = node.cluster.node_partitions(node, statement.namespace)
545
536
  Thread.new do
546
537
  Thread.current.abort_on_exception = true
547
538
  begin
548
- command = QueryCommand.new(node, policy, statement, nil, partitions)
539
+ command = ServerCommand.new(@cluster, node, policy, statement, true, statement.task_id)
549
540
  execute_command(command)
550
541
  rescue => e
551
542
  Aerospike.logger.error(e)
@@ -568,7 +559,8 @@ module Aerospike
568
559
  # ctx is an optional list of context. Supported on server v6.1+.
569
560
  def create_index(namespace, set_name, index_name, bin_name, index_type, collection_type = nil, options = nil, ctx: nil)
570
561
  if options.nil? && collection_type.is_a?(Hash)
571
- options, collection_type = collection_type, nil
562
+ options = collection_type
563
+ collection_type = nil
572
564
  end
573
565
  policy = create_policy(options, Policy, default_info_policy)
574
566
 
@@ -701,7 +693,6 @@ module Aerospike
701
693
  # If the policy is nil, the default relevant policy will be used.
702
694
  def query_partitions(partition_filter, statement, options = nil)
703
695
  policy = create_policy(options, QueryPolicy, default_query_policy)
704
- new_policy = policy.clone
705
696
 
706
697
  nodes = @cluster.nodes
707
698
  if nodes.empty?
@@ -946,13 +937,11 @@ module Aerospike
946
937
  when Hash
947
938
  policy_klass.new(policy)
948
939
  else
949
- fail TypeError, "policy should be a #{policy_klass.name} instance or a Hash"
940
+ raise TypeError, "policy should be a #{policy_klass.name} instance or a Hash"
950
941
  end
951
942
  end
952
943
 
953
- def cluster=(cluster)
954
- @cluster = cluster
955
- end
944
+ attr_writer :cluster
956
945
 
957
946
  def cluster_config_changed(cluster)
958
947
  Aerospike.logger.debug { "Cluster config change detected; active nodes: #{cluster.nodes.map(&:name)}" }
@@ -1002,24 +991,18 @@ module Aerospike
1002
991
  threads.each(&:join)
1003
992
  end
1004
993
 
1005
- def execute_batch_direct_commands(policy, keys)
994
+ def execute_batch_operate_commands(policy, records)
1006
995
  if @cluster.nodes.empty?
1007
- raise Aerospike::Exceptions::Aerospike.new(Aerospike::ResultCode::SERVER_NOT_AVAILABLE, "Executing Batch Direct command failed because cluster is empty.")
996
+ raise Aerospike::Exceptions::Aerospike.new(Aerospike::ResultCode::SERVER_NOT_AVAILABLE, "Executing Batch Index command failed because cluster is empty.")
1008
997
  end
1009
998
 
1010
- batch_nodes = BatchDirectNode.generate_list(@cluster, policy.replica, keys)
999
+ batch_nodes = BatchOperateNode.generate_list(@cluster, policy.replica, records)
1011
1000
  threads = []
1012
1001
 
1013
- # Use a thread per namespace per node
1014
- batch_nodes.each do |batch_node|
1015
- # copy to avoid race condition
1016
- bn = batch_node
1017
- bn.batch_namespaces.each do |batch|
1018
- threads << Thread.new do
1019
- Thread.current.abort_on_exception = true
1020
- command = yield batch_node.node, batch
1021
- execute_command(command)
1022
- end
1002
+ batch_nodes.each do |batch|
1003
+ threads << Thread.new do
1004
+ command = yield batch.node, batch
1005
+ execute_command(command)
1023
1006
  end
1024
1007
  end
1025
1008