Row Data#

Container for Google Cloud Bigtable Cells and Streaming Row Contents.

class google.cloud.bigtable.row_data.Cell(value, timestamp, labels=())[source]#

Bases: object

Representation of a Google Cloud Bigtable Cell.

Parameters:
  • value (bytes) – The value stored in the cell.
  • timestamp (datetime.datetime) – The timestamp when the cell was stored.
  • labels (list) – (Optional) List of strings. Labels applied to the cell.
classmethod from_pb(cell_pb)[source]#

Create a new cell from a Cell protobuf.

Parameters:cell_pb (_generated.data_pb2.Cell) – The protobuf to convert.
Return type:Cell
Returns:The cell corresponding to the protobuf.
exception google.cloud.bigtable.row_data.InvalidChunk[source]#

Bases: exceptions.RuntimeError

Exception raised to to invalid chunk data from back-end.

exception google.cloud.bigtable.row_data.InvalidReadRowsResponse[source]#

Bases: exceptions.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='')[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.
append_value(value)[source]#

Append bytes from a new chunk to value.

Parameters:value (bytes) – bytes to append
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.
cells#

Property returning all the cells accumulated on this partial row.

Return type:dict
Returns:Dictionary of the Cell objects accumulated. This dictionary has two-levels of keys (first for column families and second for column names/qualifiers within a family). For a given column, a list of Cell objects is stored.
row_key#

Getter for the current (partial) row’s key.

Return type:bytes
Returns:The current (partial) row’s key.
to_dict()[source]#

Convert the cells to a dictionary.

This is intended to be used with HappyBase, so the column family and column qualiers are combined (with :).

Return type:dict
Returns:Dictionary containing all the data in the cells of this row.
class google.cloud.bigtable.row_data.PartialRowsData(response_iterator)[source]#

Bases: object

Convenience wrapper for consuming a ReadRows streaming response.

Parameters:response_iterator (GrpcRendezvous) – A streaming iterator returned from a ReadRows request.
cancel()[source]#

Cancels the iterator, closing the stream.

consume_all(max_loops=None)[source]#

Consume the streamed responses until there are no more.

This simply calls consume_next() until there are no more to consume.

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.
consume_next()[source]#

Consume the next ReadRowsResponse from the stream.

Parse the response and its chunks into a new/existing row in _rows

rows#

Property returning all rows accumulated from the stream.

Return type:dict
Returns:row_key -> PartialRowData.
state#

State machine state.

Return type:str
Returns:name of state corresponding to currrent row / chunk processing.