Class: Aerospike::BatchDirectCommand
- Inherits:
-
MultiCommand
- Object
- Command
- MultiCommand
- Aerospike::BatchDirectCommand
- Defined in:
- lib/aerospike/command/batch_direct_command.rb
Overview
:nodoc:
Direct Known Subclasses
Instance Attribute Summary collapse
-
#batch ⇒ Object
Returns the value of attribute batch.
-
#bin_names ⇒ Object
Returns the value of attribute bin_names.
-
#key_map ⇒ Object
Returns the value of attribute key_map.
-
#policy ⇒ Object
Returns the value of attribute policy.
-
#read_attr ⇒ Object
Returns the value of attribute read_attr.
-
#results ⇒ Object
Returns the value of attribute results.
Instance Method Summary collapse
-
#initialize(node, batch, policy, key_map, bin_names, results, read_attr) ⇒ BatchDirectCommand
constructor
A new instance of BatchDirectCommand.
-
#parse_row(result_code) ⇒ Object
Parse all results in the batch.
- #write_buffer ⇒ Object
Methods inherited from MultiCommand
#compressed?, #get_node, #parse_group, #parse_key, #parse_record, #parse_result, #read_bytes, #skip_key, #stop, #valid?
Methods inherited from Command
#execute, #set_delete, #set_exists, #set_operate, #set_query, #set_read, #set_read_for_key_only, #set_read_header, #set_scan, #set_touch, #set_udf, #set_write, #write_bins
Constructor Details
#initialize(node, batch, policy, key_map, bin_names, results, read_attr) ⇒ BatchDirectCommand
Returns a new instance of BatchDirectCommand.
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/aerospike/command/batch_direct_command.rb', line 31 def initialize(node, batch, policy, key_map, bin_names, results, read_attr) super(node) @batch = batch @policy = policy @key_map = key_map @bin_names = bin_names @results = results @read_attr = read_attr end |
Instance Attribute Details
#batch ⇒ Object
Returns the value of attribute batch.
24 25 26 |
# File 'lib/aerospike/command/batch_direct_command.rb', line 24 def batch @batch end |
#bin_names ⇒ Object
Returns the value of attribute bin_names.
27 28 29 |
# File 'lib/aerospike/command/batch_direct_command.rb', line 27 def bin_names @bin_names end |
#key_map ⇒ Object
Returns the value of attribute key_map.
26 27 28 |
# File 'lib/aerospike/command/batch_direct_command.rb', line 26 def key_map @key_map end |
#policy ⇒ Object
Returns the value of attribute policy.
25 26 27 |
# File 'lib/aerospike/command/batch_direct_command.rb', line 25 def policy @policy end |
#read_attr ⇒ Object
Returns the value of attribute read_attr.
29 30 31 |
# File 'lib/aerospike/command/batch_direct_command.rb', line 29 def read_attr @read_attr end |
#results ⇒ Object
Returns the value of attribute results.
28 29 30 |
# File 'lib/aerospike/command/batch_direct_command.rb', line 28 def results @results end |
Instance Method Details
#parse_row(result_code) ⇒ Object
Parse all results in the batch. Add records to shared list. If the record was not found, the bins will be nil.
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/aerospike/command/batch_direct_command.rb', line 83 def parse_row(result_code) generation = @data_buffer.read_int32(6) expiration = @data_buffer.read_int32(10) field_count = @data_buffer.read_int16(18) op_count = @data_buffer.read_int16(20) key = parse_key(field_count) item = key_map[key.digest] if item if result_code == 0 index = item.index key = item.key results[index] = parse_record(key, op_count, generation, expiration) end else Aerospike.logger.warn("Unexpected batch key returned: #{key}") end end |
#write_buffer ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/aerospike/command/batch_direct_command.rb', line 42 def write_buffer # Estimate buffer size begin_cmd byte_size = batch.keys.length * DIGEST_SIZE @data_offset += batch.namespace.bytesize + FIELD_HEADER_SIZE + byte_size + FIELD_HEADER_SIZE if bin_names bin_names.each do |bin_name| estimate_operation_size_for_bin_name(bin_name) end end size_buffer operation_count = 0 if bin_names operation_count = bin_names.length end write_header_read(policy, read_attr, 0, 2, operation_count) write_field_string(batch.namespace, Aerospike::FieldType::NAMESPACE) write_field_header(byte_size, Aerospike::FieldType::DIGEST_RIPE_ARRAY) batch.keys.each do |key| @data_offset += @data_buffer.write_binary(key.digest, @data_offset) end if bin_names bin_names.each do |bin_name| write_operation_for_bin_name(bin_name, Aerospike::Operation::READ) end end end_cmd mark_compressed(@policy) end |