Rows and Cells

class google.cloud.bigtable.data.row.Cell(value: bytes, row_key: bytes, family: str, qualifier: bytes | str, timestamp_micros: int, labels: Optional[list[str]] = None)

Bases: object

Model class for cell data

Does not represent all data contained in the cell, only data returned by a query. Expected to be read-only to users, and written by backend

  • Parameters

    • value – the byte string value of the cell

    • row_key – the row key of the cell

    • family – the family associated with the cell

    • qualifier – the column qualifier associated with the cell

    • timestamp_micros – the timestamp of the cell in microseconds

    • labels – the list of labels associated with the cell

_eq_(other)

Implements == operator

  • Parameters

    other – Cell to compare with

  • Returns

    True if cells are equal, False otherwise

  • Return type

    bool

_hash_()

Implements hash() function to fingerprint cell

  • Returns

    hash value of the cell

  • Return type

    int

_int_()

Allows casting cell to int Interprets value as a 64-bit big-endian signed integer, as expected by ReadModifyWrite increment rule

  • Returns

    Value of the cell as a 64-bit big-endian signed integer

  • Return type

    int

_lt_(other)

Implements < operator

  • Parameters

    other – Cell to compare with

  • Returns

    True if this cell is less than the other cell, False otherwise

  • Return type

    bool

  • Raises

    NotImplementedError – If other is not a Cell

_ne_(other)

Implements != operator

  • Parameters

    other – Cell to compare with

  • Returns

    True if cells are not equal, False otherwise

  • Return type

    bool

_repr_()

Returns a string representation of the cell

  • Returns

    String representation of the cell

  • Return type

    str

_str_()

Allows casting cell to str Prints encoded byte string, same as printing value directly.

  • Returns

    Encoded byte string of the value

  • Return type

    str

class google.cloud.bigtable.data.row.Row(key: bytes, cells: list[google.cloud.bigtable.data.row.Cell])

Bases: object

Model class for row data returned from server

Does not represent all data contained in the row, only data returned by a query. Expected to be read-only to users, and written by backend

Can be indexed by family and qualifier to get cells in the row:

cells = row["family", "qualifier"]
  • Parameters

    • key – Row key

    • cells – List of cells in the row

Row objects are not intended to be created by users. They are returned by the Bigtable backend.

_contains_(item)

Implements in operator

Works for both cells in the internal list, and family or (family, qualifier) pairs associated with the cells

  • Parameters

    item – item to check for in the row

  • Returns

    True if item is in the row, False otherwise

  • Return type

    bool

_eq_(other)

Implements == operator

  • Returns

    True if rows are equal, False otherwise

  • Return type

    bool

_getitem_(index: str | tuple[str, bytes | str])

_getitem_(index: int)

_getitem_(index: slice)

Implements [] indexing

Supports indexing by family, (family, qualifier) pair, numerical index, and index slicing

_iter_()

Allow iterating over all cells in the row

  • Returns

    Iterator over the cells in the row

  • Return type

    Iterator

_len_()

Returns the number of cells in the row

  • Returns

    Number of cells in the row

  • Return type

    int

_ne_(other)

Implements != operator

  • Returns

    True if rows are not equal, False otherwise

  • Return type

    bool

_str_()

Human-readable string representation:

{
  (family='fam', qualifier=b'col'): [b'value', (+1 more),],
  (family='fam', qualifier=b'col2'): [b'other'],
}
  • Returns

    Human-readable string representation of the row

  • Return type

    str

get_cells(family: Optional[str] = None, qualifier: Optional[Union[str, bytes]] = None)

Returns cells sorted in Bigtable native order:

* Family lexicographically ascending


* Qualifier ascending


* Timestamp in reverse chronological order

If family or qualifier not passed, will include all

Can also be accessed through indexing::

cells = row[“family”, “qualifier”]
cells = row[“family”]
  • Parameters

    • family – family to filter cells by

    • qualifier – qualifier to filter cells by

  • Returns

    List of cells in the row matching the filter

  • Return type

    list[Cell]

  • Raises

    ValueError – If family or qualifier is not found in the row