From c075534a0c7d41a40231fe4273c8f4518efaf55b Mon Sep 17 00:00:00 2001 From: Matthew Eagar Date: Mon, 29 Apr 2024 16:04:44 +0000 Subject: [PATCH] Add support for row ranges --- .../test/test_proxy/test_proxy.rb | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/google-cloud-bigtable/test/test_proxy/test_proxy.rb b/google-cloud-bigtable/test/test_proxy/test_proxy.rb index 170fa123756b..76d0c84169fa 100644 --- a/google-cloud-bigtable/test/test_proxy/test_proxy.rb +++ b/google-cloud-bigtable/test/test_proxy/test_proxy.rb @@ -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.to(r.end_key_closed, inclusive: true) + elsif r.end_key_open + range = range.to(r.end_key_open, inclusive: false) + end + + range + end + end + + result = table.read_rows(**options) result = result.to_a