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
- 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
- Parameters
other – the object to compare to
- Returns
True if the objects are equal, False otherwise
- Return type
- 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
- 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
- property filter: RowFilter | None¶
Return the RowFilter applied to this query
- Returns
the RowFilter applied to this query
- Return type
RowFilter | None
- property limit: int | None¶
Return the maximum number of rows to return by this query
None or 0 means no limit
- Returns
the maximum number of rows to return by this query
- Return type
int | None
- property row_ranges: list[google.cloud.bigtable.data.read_rows_query.RowRange]¶
Return the row ranges in 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
- Parameters
shard_keys – a list of row keys that define the boundaries of segments.
- Returns
a ShardedQuery that can be used in sharded_read_rows calls
- Return type
ShardedQuery
- 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
ValueError – if end_is_inclusive is set when the corresponding key is None
ValueError – if 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.
- Returns
True if the RowRange is not empty, False otherwise
- Return type
- __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”
- Returns
The string representation of the range
- Return type
- property end_is_inclusive: bool¶
Indicates if the range is inclusive of the end key.
If the range is unbounded on the right, this will return True.
- Returns
Whether the range is inclusive of the end key.
- Return type
- property end_key: bytes | None¶
Returns the end key of the range. If None, the range is unbounded on the right.
- Returns
The end key of the range, or None if the range is unbounded on the right.
- Return type
bytes | None