Skip to content

Commit

Permalink
return orig key in batch get results
Browse files Browse the repository at this point in the history
  • Loading branch information
jhecking committed Aug 16, 2016
1 parent 5af3228 commit 0fb1016
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/aerospike/command/batch_command_get.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def parse_record_results(receive_size)
if item
if result_code == 0
index = item.index
@records[index] = parse_record(key, op_count, generation, expiration)
@records[index] = parse_record(item.key, op_count, generation, expiration)
end
else
Aerospike.logger.debug("Unexpected batch key returned: #{key.namespace}, #{key.digest}")
Expand Down
9 changes: 7 additions & 2 deletions lib/aerospike/command/batch_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def self.generate_map(keys)
keys.each_with_index do |key, i|
item = key_map[key.digest]
unless item
item = BatchItem.new(i)
item = BatchItem.new(key, i)
key_map[key.digest] = item
else
item.add_duplicate(i)
Expand All @@ -42,7 +42,8 @@ def self.generate_map(keys)
end


def initialize(index)
def initialize(key, index)
@key = key
@index = index
end

Expand All @@ -64,6 +65,10 @@ def index
return r
end

def key
@key
end

end # class

end # module
2 changes: 2 additions & 0 deletions spec/aerospike/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -631,13 +631,15 @@ def cluster_seeds(client)
expect(records.length).to eq 3

expect(records[0].key).to eq key1
expect(records[0].key.user_key).to eq key1.user_key
expect(records[0].bins).to be nil
expect(records[0].generation).to be 1
expect(records[0].expiration).to be_within(10).of(1000)

expect(records[1]).to be nil

expect(records[2].key).to eq key3
expect(records[2].key.user_key).to eq key3.user_key
expect(records[2].bins).to be nil
expect(records[2].generation).to be 1
expect(records[2].expiration).to be_within(10).of(1000)
Expand Down

0 comments on commit 0fb1016

Please sign in to comment.