Class: Aerospike::BatchCommandExists
- Inherits:
-
BatchCommand
- Object
- Command
- BatchCommand
- Aerospike::BatchCommandExists
- Defined in:
- lib/aerospike/command/batch_command_exists.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#initialize(node, batch_namespace, policy, key_map, exists_array) ⇒ BatchCommandExists
constructor
A new instance of BatchCommandExists.
-
#parse_record_results(receive_size) ⇒ Object
Parse all results in the batch.
- #write_buffer ⇒ Object
Methods inherited from BatchCommand
#parse_key, #parse_record, #parse_result, #read_bytes, #stop, #valid?
Methods inherited from Command
#execute, #set_batch_exists, #set_batch_get, #set_delete, #set_exists, #set_operate, #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_namespace, policy, key_map, exists_array) ⇒ BatchCommandExists
Returns a new instance of BatchCommandExists.
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/aerospike/command/batch_command_exists.rb', line 25 def initialize(node, batch_namespace, policy, key_map, exists_array) super(node) @batch_namespace = batch_namespace @policy = policy @key_map = key_map @exists_array = exists_array self end |
Instance Method Details
#parse_record_results(receive_size) ⇒ Object
Parse all results in the batch. Add records to shared list. If the record was not found, the bins will be nil.
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 80 81 82 83 84 85 86 87 88 |
# File 'lib/aerospike/command/batch_command_exists.rb', line 42 def parse_record_results(receive_size) #Parse each message response and add it to the result array @data_offset = 0 while @data_offset < receive_size if !valid? raise Aerospike::Exceptions::QueryTerminated.new end read_bytes(MSG_REMAINING_HEADER_SIZE) result_code = @data_buffer.read(5).ord & 0xFF # The only valid server return codes are "ok" and "not found". # If other return codes are received, then abort the batch. if result_code != 0 && result_code != Aerospike::ResultCode::KEY_NOT_FOUND_ERROR raise Aerospike::Exceptions::Aerospike.new(result_code) end info3 = @data_buffer.read(3).ord # If cmd is the end marker of the response, do not proceed further return false if info3 & INFO3_LAST == INFO3_LAST field_count = @data_buffer.read_int16(18) op_count = @data_buffer.read_int16(20) if op_count > 0 raise Aerospike::Exceptions::Parse('Received bins that were not requested!') end key = parse_key(field_count) item = @key_map[key.digest] if item index = item.index # only set the results to true; as a result, no synchronization is needed @exists_array[index] = (result_code == 0) else Aerospike::logger.debug("Unexpected batch key returned: #{key.namespace}, #{key.digest}") end end # while return true end |
#write_buffer ⇒ Object
36 37 38 |
# File 'lib/aerospike/command/batch_command_exists.rb', line 36 def write_buffer set_batch_exists(@policy, @batch_namespace) end |