Row Data

Container for Google Cloud Bigtable Cells and Streaming Row Contents.

class gcloud_bigtable.row_data.Cell(value, timestamp)[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.
classmethod from_pb(cell_pb)[source]

Create a new cell from a Cell protobuf.

Parameters:cell_pb (_generated.bigtable_data_pb2.Cell) – The protobuf to convert.
Return type:Cell
Returns:The cell corresponding to the protobuf.
class gcloud_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.
clear()[source]

Clears all cells that have been added.

committed

Getter for the committed status of the (partial) row.

Return type:bool
Returns:The committed status of the (partial) row.
row_key

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

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

Updates the current row from a ReadRows response.

Parameters:read_rows_response_pb (_generated.bigtable_service_messages_pb2.ReadRowsResponse) – A response streamed back as part of a ReadRows request.
Raises:ValueError if the current partial row has already been committed, if the row key on the response doesn’t match the current one or if there is a chunk encountered with an unexpected ONEOF protobuf property.
class gcloud_bigtable.row_data.PartialRowsData(response_iterator)[source]

Bases: object

Convenience wrapper for consuming a ReadRows streaming response.

Parameters:response_iterator (grpc.framework.alpha._reexport._CancellableIterator) – 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]

Consumes the next ReadRowsResponse from the stream.

Parses the response and stores it as a PartialRowData in a dictionary owned by this object.

Raises:StopIteration if the response iterator has no more responses to stream.
rows

Property returning all rows accumulated from the stream.

Return type:dict
Returns:Dictionary of PartialRowData.