Skip to content

Commit

Permalink
Completing the Data API intro doc.
Browse files Browse the repository at this point in the history
  • Loading branch information
dhermes committed Aug 18, 2015
1 parent f6a255b commit 5a1e13c
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion docs/data-api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,39 @@ documentation for more information on the optional arguments.
Sample Keys in a Table
----------------------

`SampleRowKeys`_
Make a `SampleRowKeys`_ API request with
:meth:`Table.sample_row_keys() <gcloud_bigtable.table.Table.sample_row_keys>`:

.. code:: python
keys_iterator = table.sample_row_keys()
The returned row keys will delimit contiguous sections of the table of
approximately equal size, which can be used to break up the data for
distributed tasks like mapreduces.

As with
:meth:`Table.read_rows() <gcloud_bigtable.table.Table.read_rows>`, the
returned ``keys_iterator`` is connected to a cancellable HTTP/2 stream.

The next key in the result can be accessed via

.. code:: python
next_key = keys_iterator.next()
or all keys can be iterated over via

.. code:: python
for curr_key in keys_iterator:
do_something(curr_key)
Just as with reading, the stream can be canceled:

.. code:: python
keys_iterator.cancel()
.. _ReadRows: https://github.com/GoogleCloudPlatform/cloud-bigtable-client/blob/f4d922bb950f1584b30f9928e84d042ad59f5658/bigtable-protos/src/main/proto/google/bigtable/v1/bigtable_service.proto#L36-L38
.. _SampleRowKeys: https://github.com/GoogleCloudPlatform/cloud-bigtable-client/blob/f4d922bb950f1584b30f9928e84d042ad59f5658/bigtable-protos/src/main/proto/google/bigtable/v1/bigtable_service.proto#L44-L46
Expand Down

0 comments on commit 5a1e13c

Please sign in to comment.