Skip to content

Commit

Permalink
[CLIENT-3072] Fix an issue where statement.return_data is not respected
Browse files Browse the repository at this point in the history
  • Loading branch information
khaf committed Aug 12, 2024
1 parent 8bc8188 commit 612f595
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
3 changes: 2 additions & 1 deletion lib/aerospike/command/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,8 @@ def set_query(cluster, policy, statement, background, node_partitions)

if statement.function_name
write_field_header(1, FieldType::UDF_OP)
@data_offset += @data_buffer.write_byte(1, @data_offset)
ret_marker = statement.return_data ? 1 : 2
@data_offset += @data_buffer.write_byte(ret_marker, @data_offset)
write_field_string(statement.package_name, FieldType::UDF_PACKAGE_NAME)
write_field_string(statement.function_name, FieldType::UDF_FUNCTION)
write_field_string(function_arg_buffer, FieldType::UDF_ARGLIST)
Expand Down
18 changes: 9 additions & 9 deletions spec/aerospike/scan_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@
let(:client) { Support.client }

before :all do
@namespace = "test"
@namespace = Support.namespace
@set = "scan1000"
@record_count = 1000
@record_count.times do |i|
key = Aerospike::Key.new(@namespace, @set, i)
bin_map = {
'bin1' => "value#{i}",
'bin2' => i,
'bin4' => ['value4', {'map1' => 'map val'}],
'bin5' => {'value5' => [124, "string value"]},
'bin4' => ['value4', { 'map1' => 'map val' }],
'bin5' => { 'value5' => [124, "string value"] }
}
Support.client.put(key, bin_map, :send_key => true)
end
Expand All @@ -53,7 +53,7 @@ def scan_method(type, compressed, bin_names=[], ops={})
[true, false].each do |compressed|
[:single_node, :multiple_nodes].each do |type|

context "#{type.to_s}" do
context "#{type}" do

it "should return all records with all bins" do
rs_list = scan_method(type, compressed, nil, :record_queue_size => 10)
Expand Down Expand Up @@ -94,7 +94,7 @@ def scan_method(type, compressed, bin_names=[], ops={})
end # it

it "should return only the selected bins" do
rs_list = scan_method(type, compressed, ['bin1', 'bin2'], :record_queue_size => 10)
rs_list = scan_method(type, compressed, %w[bin1 bin2], :record_queue_size => 10)

count = 0
rs_list.each do |rs|
Expand Down Expand Up @@ -127,14 +127,14 @@ def scan_method(type, compressed, bin_names=[], ops={})
rs_list.each do |rs|
sleep(1) # fill the queue to make sure deadlock doesn't happen
rs.cancel
expect {rs.next_record}.to raise_exception(Aerospike::ResultCode.message(Aerospike::ResultCode::SCAN_TERMINATED))
expect { rs.next_record }.to raise_exception(Aerospike::ResultCode.message(Aerospike::ResultCode::SCAN_TERMINATED))
end

rs_list = scan_method(type, compressed)
rs_list.each do |rs|
rs = rs_list.first
rs.cancel
expect {rs.next_record}.to raise_exception(Aerospike::ResultCode.message(Aerospike::ResultCode::SCAN_TERMINATED))
expect { rs.next_record }.to raise_exception(Aerospike::ResultCode.message(Aerospike::ResultCode::SCAN_TERMINATED))
end

end # it
Expand All @@ -146,12 +146,12 @@ def scan_method(type, compressed, bin_names=[], ops={})
i = 0
rs.each do |rec|
i +=1
break if (i == 15)
break if i == 15
end
expect(i).to eq 15

rs.cancel
expect {rs.next_record}.to raise_exception(Aerospike::ResultCode.message(Aerospike::ResultCode::SCAN_TERMINATED))
expect { rs.next_record }.to raise_exception(Aerospike::ResultCode.message(Aerospike::ResultCode::SCAN_TERMINATED))
end

end # it
Expand Down
6 changes: 3 additions & 3 deletions spec/aerospike/udf_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,14 @@
end

it "should execute a UDF on all records" do
ns = 'test'
ns = Support.namespace
set = Support.rand_string(10)
div = 2

number_of_records = 100
number_of_records.times do |i|
number_of_records.times do
key = Support.gen_random_key(50, { :set => set })
bin1 = Aerospike::Bin.new('bin1', (i + 1) * div)
bin1 = Aerospike::Bin.new('bin1', div)
bin2 = Aerospike::Bin.new('bin2', -1)
client.put(key, [bin1, bin2])
end
Expand Down

0 comments on commit 612f595

Please sign in to comment.