Skip to content

Commit

Permalink
Add support for reversed scans
Browse files Browse the repository at this point in the history
  • Loading branch information
ron-gal committed Jan 11, 2024
1 parent 9022f54 commit a968b65
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions google/cloud/bigtable/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,7 @@ def read_rows(
end_inclusive=False,
row_set=None,
retry=DEFAULT_RETRY_READ_ROWS,
reversed=None,
):
"""Read rows from this table.
Expand Down Expand Up @@ -619,6 +620,9 @@ def read_rows(
method or the :meth:`~google.api_core.retry.Retry.with_deadline`
method.
:type reversed: bool
:param reversed: (Optional) Whether records should return in descending lexicographical order. The default is False (ascending).
:rtype: :class:`.PartialRowsData`
:returns: A :class:`.PartialRowsData` a generator for consuming
the streamed results.
Expand All @@ -632,6 +636,7 @@ def read_rows(
end_inclusive=end_inclusive,
app_profile_id=self._app_profile_id,
row_set=row_set,
reversed=reversed,
)
data_client = self._instance._client.table_data_client
return PartialRowsData(data_client.read_rows, request_pb, retry)
Expand Down Expand Up @@ -1265,6 +1270,7 @@ def _create_row_request(
end_inclusive=False,
app_profile_id=None,
row_set=None,
reversed=None,
):
"""Creates a request to read rows in a table.
Expand Down Expand Up @@ -1301,6 +1307,9 @@ def _create_row_request(
:param row_set: (Optional) The row set containing multiple row keys and
row_ranges.
:type: reversed: bool
:param reversed: (Optional) Whether records should return in descending lexicographical order. The default is False (ascending).
:rtype: :class:`data_messages_v2_pb2.ReadRowsRequest`
:returns: The ``ReadRowsRequest`` protobuf corresponding to the inputs.
:raises: :class:`ValueError <exceptions.ValueError>` if both
Expand All @@ -1316,6 +1325,8 @@ def _create_row_request(
request_kwargs["rows_limit"] = limit
if app_profile_id is not None:
request_kwargs["app_profile_id"] = app_profile_id
if reversed is not None:
request_kwargs["reversed"] = reversed

message = data_messages_v2_pb2.ReadRowsRequest(**request_kwargs)

Expand Down

0 comments on commit a968b65

Please sign in to comment.