Row Data#
Container for Google Cloud Bigtable Cells and Streaming Row Contents.
-
class
google.cloud.bigtable.row_data.
Cell
(value, timestamp_micros, labels=None)[source]# Bases:
object
Representation of a Google Cloud Bigtable Cell.
- Parameters
-
google.cloud.bigtable.row_data.
DEFAULT_RETRY_READ_ROWS
= <google.api_core.retry.Retry object># The default retry strategy to be used on retry-able errors.
Used by
_read_next_response()
.
-
exception
google.cloud.bigtable.row_data.
InvalidChunk
[source]# Bases:
RuntimeError
Exception raised to to invalid chunk data from back-end.
-
exception
google.cloud.bigtable.row_data.
InvalidReadRowsResponse
[source]# Bases:
RuntimeError
Exception raised to to invalid response data from back-end.
-
class
google.cloud.bigtable.row_data.
PartialCellData
(row_key, family_name, qualifier, timestamp_micros, labels=(), value=b'')[source]# Bases:
object
Representation of partial cell in a Google Cloud Bigtable Table.
These are expected to be updated directly from a
_generated.bigtable_service_messages_pb2.ReadRowsResponse
- Parameters
row_key (bytes) – The key for the row holding the (partial) cell.
family_name (str) – The family name of the (partial) cell.
qualifier (bytes) – The column qualifier of the (partial) cell.
timestamp_micros (int) – The timestamp (in microsecods) of the (partial) cell.
labels (list of str) – labels assigned to the (partial) cell
value (bytes) – The (accumulated) value of the (partial) cell.
-
class
google.cloud.bigtable.row_data.
PartialRowData
(row_key)[source]# Bases:
object
Representation of partial row in a Google Cloud Bigtable Table.
These are expected to be updated directly from a
_generated.bigtable_service_messages_pb2.ReadRowsResponse
- Parameters
row_key (bytes) – The key for the row holding the (partial) data.
-
cell_value
(column_family_id, column, index=0)[source]# Get a single cell value stored on this instance.
For example:
from google.cloud.bigtable import Client client = Client(admin=True) instance = client.instance(INSTANCE_ID) table = instance.table(TABLE_ID) row_key = "row_key_1" row_data = table.read_row(row_key) cell_value = row_data.cell_value(COLUMN_FAMILY_ID, COL_NAME1)
- Parameters
- Returns
The cell value stored in the specified column and specified index.
- Return type
Cell value
- Raises
KeyError – If
column_family_id
is not among the cells stored in this row.KeyError – If
column
is not among the cells stored in this row for the givencolumn_family_id
.IndexError – If
index
cannot be found within the cells stored in this row for the givencolumn_family_id
,column
pair.
-
cell_values
(column_family_id, column, max_count=None)[source]# Get a time series of cells stored on this instance.
For example:
from google.cloud.bigtable import Client client = Client(admin=True) instance = client.instance(INSTANCE_ID) table = instance.table(TABLE_ID) row_key = "row_key_1" row_data = table.read_row(row_key) cell_values = row_data.cell_values(COLUMN_FAMILY_ID, COL_NAME1)
- Parameters
- Returns
- cell.value, cell.timestamp_micros
for each cell in the list of cells
- Return type
A generator which provides
- Raises
-
property
cells
# Property returning all the cells accumulated on this partial row.
For example:
from google.cloud.bigtable import Client client = Client(admin=True) instance = client.instance(INSTANCE_ID) table = instance.table(TABLE_ID) row_key = "row_key_1" row_data = table.read_row(row_key) cells = row_data.cells
-
find_cells
(column_family_id, column)[source]# Get a time series of cells stored on this instance.
For example:
from google.cloud.bigtable import Client client = Client(admin=True) instance = client.instance(INSTANCE_ID) table = instance.table(TABLE_ID) row_key = "row_key_1" row = table.read_row(row_key) cells = row.find_cells(COLUMN_FAMILY_ID, COL_NAME2)
- Parameters
- Returns
The cells stored in the specified column.
- Return type
List[Cell]
- Raises
-
property
row_key
# Getter for the current (partial) row’s key.
- Return type
- Returns
The current (partial) row’s key.
-
class
google.cloud.bigtable.row_data.
PartialRowsData
(read_method, request, retry=<google.api_core.retry.Retry object>)[source]# Bases:
object
Convenience wrapper for consuming a
ReadRows
streaming response.- Parameters
read_method (
client._table_data_client.read_rows
) –ReadRows
method.request (
data_messages_v2_pb2.ReadRowsRequest
) – TheReadRowsRequest
message used to create a ReadRowsResponse iterator. If the iterator fails, a new iterator is created, allowing the scan to continue from the point just beyond the last successfully read row, identified by self.last_scanned_row_key. The retry happens inside of the Retry class, using a predicate for the expected exceptions during iteration.retry (
Retry
) – (Optional) Retry delay and deadline arguments. To override, the default valueDEFAULT_RETRY_READ_ROWS
can be used and modified with thewith_delay()
method or thewith_deadline()
method.
-
consume_all
(max_loops=None)[source]# Consume the streamed responses until there are no more.
Warning
This method will be removed in future releases. Please use this class as a generator instead.
- Parameters
max_loops (int) – (Optional) Maximum number of times to try to consume an additional
ReadRowsResponse
. You can use this to avoid long wait times.