Skip to content

Commit

Permalink
Add support for row ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Eagar committed Apr 29, 2024
1 parent 4d07da5 commit bd793dc
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions google-cloud-bigtable/test/test_proxy/test_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,35 @@ def read_rows req, _call
assert req.request.app_profile_id == "", "An app profile ID was specified when non was expected"

# TODO: req.request.reverse is not supported by the client library; when it is, fix this
result = Client.get(req.client_id)
table = Client.get(req.client_id)
.table(req.request.table_name)
.read_rows(keys: req.request&.rows&.row_keys&.to_a, limit: req.request.rows_limit)


options = {
keys: req.request&.rows&.row_keys&.to_a,
limit: req.request.rows_limit
}

if req.request.rows&.row_ranges&.any?
options[:ranges] = req.request.rows.row_ranges.map do |r|
range = table.new_row_range
if r.start_key_closed
range = range.from(r.start_key_closed, inclusive: true)
elsif r.start_key_open
range = range.from(r.start_key_open, inclusive: false)
end

if r.end_key_closed
range = range.from(r.end_key_closed, inclusive: true)
elsif r.end_key_open
range = range.from(r.end_key_open, inclusive: false)
end

range
end
end

result = table.read_rows(**options)

result = result.to_a

Expand Down

0 comments on commit bd793dc

Please sign in to comment.