Skip to content

Commit 73f55a7

Browse files
feat: add support for filtering SampleRowKeys to a specific row_range (#34020)
* feat: add support for filtering SampleRowKeys to a specific row_range docs: comments in SampleRowKeys updated to reflect the new row_range field PiperOrigin-RevId: 927321837 Source-Link: googleapis/googleapis@14cccfb Source-Link: googleapis/googleapis-gen@41c0f84 Copy-Tag: eyJwIjoiZ29vZ2xlLWNsb3VkLWJpZ3RhYmxlLXYyLy5Pd2xCb3QueWFtbCIsImgiOiI0MWMwZjg0ODZiOWM1OTE0NmE3N2IxNWU5NjRjM2ZlMDQwZGM0NGFlIn0= * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 1424ae0 commit 73f55a7

5 files changed

Lines changed: 35 additions & 12 deletions

File tree

google-cloud-bigtable-v2/lib/google/bigtable/v2/bigtable_pb.rb

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

google-cloud-bigtable-v2/lib/google/bigtable/v2/bigtable_services_pb.rb

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

google-cloud-bigtable-v2/lib/google/cloud/bigtable/v2/bigtable/client.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,9 @@ def read_rows request, options = nil
361361
# which can be used to break up the data for distributed tasks like
362362
# mapreduces.
363363
#
364+
# If a `row_range` is provided in the request, the returned samples will be
365+
# restricted to the specified range.
366+
#
364367
# @overload sample_row_keys(request, options = nil)
365368
# Pass arguments to `sample_row_keys` via a request object, either of type
366369
# {::Google::Cloud::Bigtable::V2::SampleRowKeysRequest} or an equivalent Hash.
@@ -371,7 +374,7 @@ def read_rows request, options = nil
371374
# @param options [::Gapic::CallOptions, ::Hash]
372375
# Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
373376
#
374-
# @overload sample_row_keys(table_name: nil, authorized_view_name: nil, materialized_view_name: nil, app_profile_id: nil)
377+
# @overload sample_row_keys(table_name: nil, authorized_view_name: nil, materialized_view_name: nil, app_profile_id: nil, row_range: nil)
375378
# Pass arguments to `sample_row_keys` via keyword arguments. Note that at
376379
# least one keyword argument is required. To specify no parameters, or to keep all
377380
# the default parameter values, pass an empty Hash as a request object (see above).
@@ -395,6 +398,11 @@ def read_rows request, options = nil
395398
# @param app_profile_id [::String]
396399
# This value specifies routing for replication. If not specified, the
397400
# "default" application profile will be used.
401+
# @param row_range [::Google::Cloud::Bigtable::V2::RowRange, ::Hash]
402+
# Optional. The row range to sample. If not specified, samples
403+
# from all rows.
404+
# The output will always return the end key in the range as the last sample
405+
# returned.
398406
#
399407
# @yield [response, operation] Access the result along with the RPC operation
400408
# @yieldparam response [::Enumerable<::Google::Cloud::Bigtable::V2::SampleRowKeysResponse>]

google-cloud-bigtable-v2/proto_docs/google/bigtable/v2/bigtable.rb

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,12 @@ class CellChunk
211211
# @return [::String]
212212
# This value specifies routing for replication. If not specified, the
213213
# "default" application profile will be used.
214+
# @!attribute [rw] row_range
215+
# @return [::Google::Cloud::Bigtable::V2::RowRange]
216+
# Optional. The row range to sample. If not specified, samples
217+
# from all rows.
218+
# The output will always return the end key in the range as the last sample
219+
# returned.
214220
class SampleRowKeysRequest
215221
include ::Google::Protobuf::MessageExts
216222
extend ::Google::Protobuf::MessageExts::ClassMethods
@@ -219,17 +225,21 @@ class SampleRowKeysRequest
219225
# Response message for Bigtable.SampleRowKeys.
220226
# @!attribute [rw] row_key
221227
# @return [::String]
222-
# Sorted streamed sequence of sample row keys in the table. The table might
223-
# have contents before the first row key in the list and after the last one,
224-
# but a key containing the empty string indicates "end of table" and will be
225-
# the last response given, if present.
228+
# Sorted streamed sequence of sample row keys in the table, restricted to
229+
# the row_range if specified in the request. The table might have contents
230+
# before the first row key in the list and after the last one, but a key
231+
# containing the empty string indicates "end of table" and will be the last
232+
# response given, if present and within the row-range specified in the
233+
# request.
226234
# Note that row keys in this list may not have ever been written to or read
227235
# from, and users should therefore not make any assumptions about the row key
228236
# structure that are specific to their use case.
229237
# @!attribute [rw] offset_bytes
230238
# @return [::Integer]
231239
# Approximate total storage space used by all rows in the table which precede
232-
# `row_key`. Buffering the contents of all rows between two subsequent
240+
# `row_key` (and if a row-range is specified in the request, which follow
241+
# what would have been the previous sample before the row-range start).
242+
# Buffering the contents of all rows between two subsequent
233243
# samples would require space roughly equal to the difference in their
234244
# `offset_bytes` fields.
235245
class SampleRowKeysResponse

google-cloud-bigtable-v2/test/google/cloud/bigtable/v2/bigtable_test.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ def test_sample_row_keys
164164
authorized_view_name = "hello world"
165165
materialized_view_name = "hello world"
166166
app_profile_id = "hello world"
167+
row_range = {}
167168

168169
sample_row_keys_client_stub = ClientStub.new [grpc_response].to_enum, grpc_operation do |name, request, options:|
169170
assert_equal :sample_row_keys, name
@@ -172,6 +173,7 @@ def test_sample_row_keys
172173
assert_equal "hello world", request["authorized_view_name"]
173174
assert_equal "hello world", request["materialized_view_name"]
174175
assert_equal "hello world", request["app_profile_id"]
176+
assert_equal Gapic::Protobuf.coerce({}, to: ::Google::Cloud::Bigtable::V2::RowRange), request["row_range"]
175177
refute_nil options
176178
end
177179

@@ -182,7 +184,7 @@ def test_sample_row_keys
182184
end
183185

184186
# Use hash object
185-
client.sample_row_keys({ table_name: table_name, authorized_view_name: authorized_view_name, materialized_view_name: materialized_view_name, app_profile_id: app_profile_id }) do |response, operation|
187+
client.sample_row_keys({ table_name: table_name, authorized_view_name: authorized_view_name, materialized_view_name: materialized_view_name, app_profile_id: app_profile_id, row_range: row_range }) do |response, operation|
186188
assert_kind_of Enumerable, response
187189
response.to_a.each do |r|
188190
assert_kind_of ::Google::Cloud::Bigtable::V2::SampleRowKeysResponse, r
@@ -191,7 +193,7 @@ def test_sample_row_keys
191193
end
192194

193195
# Use named arguments
194-
client.sample_row_keys table_name: table_name, authorized_view_name: authorized_view_name, materialized_view_name: materialized_view_name, app_profile_id: app_profile_id do |response, operation|
196+
client.sample_row_keys table_name: table_name, authorized_view_name: authorized_view_name, materialized_view_name: materialized_view_name, app_profile_id: app_profile_id, row_range: row_range do |response, operation|
195197
assert_kind_of Enumerable, response
196198
response.to_a.each do |r|
197199
assert_kind_of ::Google::Cloud::Bigtable::V2::SampleRowKeysResponse, r
@@ -200,7 +202,7 @@ def test_sample_row_keys
200202
end
201203

202204
# Use protobuf object
203-
client.sample_row_keys ::Google::Cloud::Bigtable::V2::SampleRowKeysRequest.new(table_name: table_name, authorized_view_name: authorized_view_name, materialized_view_name: materialized_view_name, app_profile_id: app_profile_id) do |response, operation|
205+
client.sample_row_keys ::Google::Cloud::Bigtable::V2::SampleRowKeysRequest.new(table_name: table_name, authorized_view_name: authorized_view_name, materialized_view_name: materialized_view_name, app_profile_id: app_profile_id, row_range: row_range) do |response, operation|
204206
assert_kind_of Enumerable, response
205207
response.to_a.each do |r|
206208
assert_kind_of ::Google::Cloud::Bigtable::V2::SampleRowKeysResponse, r
@@ -209,7 +211,7 @@ def test_sample_row_keys
209211
end
210212

211213
# Use hash object with options
212-
client.sample_row_keys({ table_name: table_name, authorized_view_name: authorized_view_name, materialized_view_name: materialized_view_name, app_profile_id: app_profile_id }, grpc_options) do |response, operation|
214+
client.sample_row_keys({ table_name: table_name, authorized_view_name: authorized_view_name, materialized_view_name: materialized_view_name, app_profile_id: app_profile_id, row_range: row_range }, grpc_options) do |response, operation|
213215
assert_kind_of Enumerable, response
214216
response.to_a.each do |r|
215217
assert_kind_of ::Google::Cloud::Bigtable::V2::SampleRowKeysResponse, r
@@ -218,7 +220,7 @@ def test_sample_row_keys
218220
end
219221

220222
# Use protobuf object with options
221-
client.sample_row_keys(::Google::Cloud::Bigtable::V2::SampleRowKeysRequest.new(table_name: table_name, authorized_view_name: authorized_view_name, materialized_view_name: materialized_view_name, app_profile_id: app_profile_id), grpc_options) do |response, operation|
223+
client.sample_row_keys(::Google::Cloud::Bigtable::V2::SampleRowKeysRequest.new(table_name: table_name, authorized_view_name: authorized_view_name, materialized_view_name: materialized_view_name, app_profile_id: app_profile_id, row_range: row_range), grpc_options) do |response, operation|
222224
assert_kind_of Enumerable, response
223225
response.to_a.each do |r|
224226
assert_kind_of ::Google::Cloud::Bigtable::V2::SampleRowKeysResponse, r

0 commit comments

Comments
 (0)