Skip to content

Commit

Permalink
fix: BatchRead with operations (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
opti authored Sep 30, 2024
1 parent c1d72f3 commit 7482273
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/aerospike/batch_read.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/aerospike/command/batch_operate_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 12 additions & 0 deletions spec/aerospike/batch_operate_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7482273

Please sign in to comment.