As of January 1, 2020 this library no longer supports Python 2 on the latest released version. Library versions released prior to that date will continue to be available. For more information please visit Python 2 support on Google Cloud.

Read Rows Query

class google.cloud.bigtable.data.read_rows_query.ReadRowsQuery(row_keys: list[str | bytes] | str | bytes | None = None, row_ranges: list[RowRange] | RowRange | None = None, limit: int | None = None, row_filter: RowFilter | None = None)[source]

Bases: object

Class to encapsulate details of a read row request

Create a new ReadRowsQuery

Parameters
  • row_keys (-) – row keys to include in the query a query can contain multiple keys, but ranges should be preferred

  • row_ranges (-) – ranges of rows to include in the query

  • limit (-) – the maximum number of rows to return. None or 0 means no limit default: None (no limit)

  • row_filter (-) – a RowFilter to apply to the query

__eq__(other)[source]

RowRanges are equal if they have the same row keys, row ranges, filter and limit, or if they both represent a full scan with the same filter and limit

add_key(row_key: str | bytes)[source]

Add a row key to this query

A query can contain multiple keys, but ranges should be preferred

Parameters

row_key (-) – a key to add to this query

Returns

  • a reference to this query for chaining

Raises

- ValueError if an input is not a string or bytes

add_range(row_range: google.cloud.bigtable.data.read_rows_query.RowRange)[source]

Add a range of row keys to this query.

Parameters

row_range (-) – a range of row keys to add to this query

shard(shard_keys: RowKeySamples) ShardedQuery[source]

Split this query into multiple queries that can be evenly distributed across nodes and run in parallel

Returns

  • a ShardedQuery that can be used in sharded_read_rows calls

Raises

- AttributeError if the query contains a limit

class google.cloud.bigtable.data.read_rows_query.RowRange(start_key: str | bytes | None = None, end_key: str | bytes | None = None, start_is_inclusive: bool | None = None, end_is_inclusive: bool | None = None)[source]

Bases: object

Represents a range of keys in a ReadRowsQuery

Parameters
  • start_key (-) – The start key of the range. If empty, the range is unbounded on the left.

  • end_key (-) – The end key of the range. If empty, the range is unbounded on the right.

  • start_is_inclusive (-) – Whether the start key is inclusive. If None, the start key is inclusive.

  • end_is_inclusive (-) – Whether the end key is inclusive. If None, the end key is not inclusive.

Raises

- ValueError – if start_key is greater than end_key, or start_is_inclusive, or end_is_inclusive is set when the corresponding key is None, or start_key or end_key is not a string or bytes.

__bool__() bool[source]

Empty RowRanges (representing a full table scan) are falsy, because they can be substituted with None. Non-empty RowRanges are truthy.

__str__() str[source]

Represent range as a string, e.g. “[b’a’, b’z)” Unbounded start or end keys are represented as “-inf” or “+inf”

property end_is_inclusive: bool

Returns whether the range is inclusive of the end key. Returns True if the range is unbounded on the right.

property end_key: bytes | None

Returns the end key of the range. If None, the range is unbounded on the right.

property start_is_inclusive: bool

Returns whether the range is inclusive of the start key. Returns True if the range is unbounded on the left.

property start_key: bytes | None

Returns the start key of the range. If None, the range is unbounded on the left.