| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 94dcc2d commit a4911fd
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -474,7 +474,11 @@ def _read_next(self): | |||
| 474 | 474 | ||
| 475 | 475 | def _read_next_response(self): | |
| 476 | 476 | """Helper for :meth:`__iter__`.""" | |
| 477 | - return self.retry(self._read_next, on_error=self._on_error)() | ||
| 477 | + resp_protoplus = self.retry(self._read_next, on_error=self._on_error)() | ||
| 478 | + # unwrap the underlying protobuf, there is a significant amount of | ||
| 479 | + # overhead that protoplus imposes for very little gain. The protos | ||
| 480 | + # are not user visible, so we just use the raw protos for merging. | ||
| 481 | + return data_messages_v2_pb2.ReadRowsResponse.pb(resp_protoplus) | ||
| 478 | 482 | ||
| 479 | 483 | def __iter__(self): | |
| 480 | 484 | """Consume the ``ReadRowsResponse`` s from the stream. | |
@@ -543,11 +547,12 @@ def _process_chunk(self, chunk): | |||
| 543 | 547 | def _update_cell(self, chunk): | |
| 544 | 548 | if self._cell is None: | |
| 545 | 549 | qualifier = None | |
| 546 | - if "qualifier" in chunk: | ||
| 547 | - qualifier = chunk.qualifier | ||
| 550 | + if chunk.HasField("qualifier"): | ||
| 551 | + qualifier = chunk.qualifier.value | ||
| 552 | + | ||
| 548 | 553 | family = None | |
| 549 | - if "family_name" in chunk: | ||
| 550 | - family = chunk.family_name | ||
| 554 | + if chunk.HasField("family_name"): | ||
| 555 | + family = chunk.family_name.value | ||
| 551 | 556 | ||
| 552 | 557 | self._cell = PartialCellData( | |
| 553 | 558 | chunk.row_key, | |
@@ -577,8 +582,8 @@ def _validate_chunk_reset_row(self, chunk): | |||
| 577 | 582 | ||
| 578 | 583 | # No reset with other keys | |
| 579 | 584 | _raise_if(chunk.row_key) | |
| 580 | - _raise_if("family_name" in chunk) | ||
| 581 | - _raise_if("qualifier" in chunk) | ||
| 585 | + _raise_if(chunk.HasField("family_name")) | ||
| 586 | + _raise_if(chunk.HasField("qualifier")) | ||
| 582 | 587 | _raise_if(chunk.timestamp_micros) | |
| 583 | 588 | _raise_if(chunk.labels) | |
| 584 | 589 | _raise_if(chunk.value_size) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -637,15 +637,15 @@ def test_partial_rows_data__copy_from_previous_filled(): | |||
| 637 | 637 | ||
| 638 | 638 | def test_partial_rows_data_valid_last_scanned_row_key_on_start(): | |
| 639 | 639 | client = _Client() | |
| 640 | - response = _ReadRowsResponseV2(chunks=(), last_scanned_row_key="2.AFTER") | ||
| 640 | + response = _ReadRowsResponseV2([], last_scanned_row_key=b"2.AFTER") | ||
| 641 | 641 | iterator = _MockCancellableIterator(response) | |
| 642 | 642 | client._data_stub = mock.MagicMock() | |
| 643 | 643 | client._data_stub.read_rows.side_effect = [iterator] | |
| 644 | 644 | request = object() | |
| 645 | 645 | yrd = _make_partial_rows_data(client._data_stub.read_rows, request) | |
| 646 | - yrd.last_scanned_row_key = "1.BEFORE" | ||
| 646 | + yrd.last_scanned_row_key = b"1.BEFORE" | ||
| 647 | 647 | _partial_rows_data_consume_all(yrd) | |
| 648 | - assert yrd.last_scanned_row_key == "2.AFTER" | ||
| 648 | + assert yrd.last_scanned_row_key == b"2.AFTER" | ||
| 649 | 649 | ||
| 650 | 650 | ||
| 651 | 651 | def test_partial_rows_data_invalid_empty_chunk(): | |
@@ -666,6 +666,7 @@ def test_partial_rows_data_invalid_empty_chunk(): | |||
| 666 | 666 | ||
| 667 | 667 | def test_partial_rows_data_state_cell_in_progress(): | |
| 668 | 668 | from google.cloud.bigtable_v2.services.bigtable import BigtableClient | |
| 669 | + from google.cloud.bigtable_v2.types import bigtable as messages_v2_pb2 | ||
| 669 | 670 | ||
| 670 | 671 | LABELS = ["L1", "L2"] | |
| 671 | 672 | ||
@@ -682,6 +683,9 @@ def test_partial_rows_data_state_cell_in_progress(): | |||
| 682 | 683 | value=VALUE, | |
| 683 | 684 | labels=LABELS, | |
| 684 | 685 | ) | |
| 686 | + # _update_cell expects to be called after the protoplus wrapper has been | ||
| 687 | + # shucked | ||
| 688 | + chunk = messages_v2_pb2.ReadRowsResponse.CellChunk.pb(chunk) | ||
| 685 | 689 | yrd._update_cell(chunk) | |
| 686 | 690 | ||
| 687 | 691 | more_cell_data = _ReadRowsResponseCellChunkPB(value=VALUE) | |
@@ -1455,10 +1459,12 @@ def __init__(self, **kw): | |||
| 1455 | 1459 | self.__dict__.update(kw) | |
| 1456 | 1460 | ||
| 1457 | 1461 | ||
| 1458 | - class _ReadRowsResponseV2(object): | ||
| 1459 | - def __init__(self, chunks, last_scanned_row_key=""): | ||
| 1460 | - self.chunks = chunks | ||
| 1461 | - self.last_scanned_row_key = last_scanned_row_key | ||
| 1462 | + def _ReadRowsResponseV2(chunks, last_scanned_row_key=b""): | ||
| 1463 | + from google.cloud.bigtable_v2.types import bigtable as messages_v2_pb2 | ||
| 1464 | + | ||
| 1465 | + return messages_v2_pb2.ReadRowsResponse( | ||
| 1466 | + chunks=chunks, last_scanned_row_key=last_scanned_row_key | ||
| 1467 | + ) | ||
| 1462 | 1468 | ||
| 1463 | 1469 | ||
| 1464 | 1470 | def _generate_cell_chunks(chunk_text_pbs): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2206,10 +2206,12 @@ def next(self): | |||
| 2206 | 2206 | __next__ = next | |
| 2207 | 2207 | ||
| 2208 | 2208 | ||
| 2209 | - class _ReadRowsResponseV2(object): | ||
| 2210 | - def __init__(self, chunks, last_scanned_row_key=""): | ||
| 2211 | - self.chunks = chunks | ||
| 2212 | - self.last_scanned_row_key = last_scanned_row_key | ||
| 2209 | + def _ReadRowsResponseV2(chunks, last_scanned_row_key=b""): | ||
| 2210 | + from google.cloud.bigtable_v2.types import bigtable as messages_v2_pb2 | ||
| 2211 | + | ||
| 2212 | + return messages_v2_pb2.ReadRowsResponse( | ||
| 2213 | + chunks=chunks, last_scanned_row_key=last_scanned_row_key | ||
| 2214 | + ) | ||
| 2213 | 2215 | ||
| 2214 | 2216 | ||
| 2215 | 2217 | def _TablePB(*args, **kw): | |
| Back | FazBrowse Home | New Git URL |
0 commit comments