diff --git a/lib/aerospike/batch_read.rb b/lib/aerospike/batch_read.rb index ef0f093..a22eb93 100644 --- a/lib/aerospike/batch_read.rb +++ b/lib/aerospike/batch_read.rb @@ -88,7 +88,7 @@ def size # :nodoc: raise AerospikeException.new(ResultCode::PARAMETER_ERROR, "Write operations not allowed in batch read") end size += op.bin_name.bytesize + Aerospike::OPERATION_HEADER_SIZE - size += op.value.estimate_size + size += op.bin_value.estimate_size end size diff --git a/lib/aerospike/command/batch_operate_command.rb b/lib/aerospike/command/batch_operate_command.rb index db816e8..c16b3ee 100644 --- a/lib/aerospike/command/batch_operate_command.rb +++ b/lib/aerospike/command/batch_operate_command.rb @@ -92,7 +92,7 @@ def write_buffer if record.bin_names&.length&.> 0 write_batch_bin_names(key, record.bin_names, attr, attr.filter_exp) elsif record.ops&.length&.> 0 - attr.adjust_read(br.ops) + attr.adjust_read(record.ops) write_batch_operations(key, record.ops, attr, attr.filter_exp) else attr.adjust_read_all_bins(record.read_all_bins) diff --git a/spec/aerospike/batch_operate_spec.rb b/spec/aerospike/batch_operate_spec.rb index a165f8e..54663fd 100644 --- a/spec/aerospike/batch_operate_spec.rb +++ b/spec/aerospike/batch_operate_spec.rb @@ -61,6 +61,18 @@ expect(records[0].record.bins.length).to eql 3 end + it 'returns bins specified with operations' do + ops = [ + Aerospike::Operation.get("idx"), + Aerospike::Operation.get("rnd") + ] + records = [Aerospike::BatchRead.ops(keys.first, ops)] + client.batch_operate(records, batch_policy) + + expect(records[0].result_code).to eql(0) + expect(records[0].record.bins).to eql({ "idx"=>0, "rnd"=>99 }) + end + it 'filter out' do records = [Aerospike::BatchRead.read_all_bins(keys.first)] client.batch_operate(records, opts)