<commit_before>Data API
========

After creating a :class:`Table <google.cloud.bigtable.table.Table>` and some
column families, you are ready to store and retrieve data.

Cells vs. Columns vs. Column Families
+++++++++++++++++++++++++++++++++++++

* As explained in the :doc:`table overview <table-api>`, tables can
  have many column families.
* As described below, a table can also have many rows which are
  specified by row keys.
* Within a row, data is stored in a cell. A cell simply has a value (as
  bytes) and a timestamp. The number of cells in each row can be
  different, depending on what was stored in each row.
* Each cell lies in a column (**not** a column family). A column is really
  just a more **specific** modifier within a column family. A column
  can be present in every column family, in only one or anywhere in between.
* Within a column family there can be many columns. For example, within
  the column family ``foo`` we could have columns ``bar`` and ``baz``.
  These would typically be represented as ``foo:bar`` and ``foo:baz``.

Modifying Data
++++++++++++++

Since data is stored in cells, which are stored in rows, we
use the metaphor of a **row** in classes that are used to modify
(write, update, delete) data in a
:class:`Table <google.cloud.bigtable.table.Table>`.

Direct vs. Conditional vs. Append
---------------------------------

There are three ways to modify data in a table, described by the
`MutateRow`_, `CheckAndMutateRow`_ and `ReadModifyWriteRow`_ API
methods.

* The **direct** way is via `MutateRow`_ which involves simply
  adding, overwriting or deleting cells. The
  :class:`DirectRow <google.cloud.bigtable.row.DirectRow>` class
  handles direct mutations.
* The **conditional** way is via `CheckAndMutateRow`_. This method
  first checks if some filter is matched in a given row, then
  applies one of two sets of mutations, depending on if a match
  occurred or not. (These mutation sets are called the "true
  mutations" and "false mutations".) The
  :class:`ConditionalRow <google.cloud.bigtable.row.ConditionalRow>` class
  handles conditional mutations.
* The **append** way is via `ReadModifyWriteRow`_. This simply
  appends (as bytes) or increments (as an integer) data in a presumed
  existing cell in a row. The
  :class:`AppendRow <google.cloud.bigtable.row.AppendRow>` class
  handles append mutations.

Row Factory
-----------

A single factory can be used to create any of the three row types.
To create a :class:`DirectRow <google.cloud.bigtable.row.DirectRow>`:

.. code:: python

    row = table.row(row_key)

Unlike the previous string values we've used before, the row key must
be ``bytes``.

To create a :class:`ConditionalRow <google.cloud.bigtable.row.ConditionalRow>`,
first create a :class:`RowFilter <google.cloud.bigtable.row.RowFilter>` and
then

.. code:: python

    cond_row = table.row(row_key, filter_=filter_)

To create an :class:`AppendRow <google.cloud.bigtable.row.AppendRow>`

.. code:: python

    append_row = table.row(row_key, append=True)

Building Up Mutations
---------------------

In all three cases, a set of mutations (or two sets) are built up
on a row before they are sent of in a batch via

.. code:: python

    row.commit()

Direct Mutations
----------------

Direct mutations can be added via one of four methods

* :meth:`set_cell() <google.cloud.bigtable.row.DirectRow.set_cell>` allows a
  single value to be written to a column

  .. code:: python

      row.set_cell(column_family_id, column, value,
                   timestamp=timestamp)

  If the ``timestamp`` is omitted, the current time on the Google Cloud
  Bigtable server will be used when the cell is stored.

  The value can either be bytes or an integer, which will be converted to
  bytes as a signed 64-bit integer.
<commit_msg>Fix misspelling in docs. (#9184)<commit_after>Data API
========

After creating a :class:`Table <google.cloud.bigtable.table.Table>` and some
column families, you are ready to store and retrieve data.

Cells vs. Columns vs. Column Families
+++++++++++++++++++++++++++++++++++++

* As explained in the :doc:`table overview <table-api>`, tables can
  have many column families.
* As described below, a table can also have many rows which are
  specified by row keys.
* Within a row, data is stored in a cell. A cell simply has a value (as
  bytes) and a timestamp. The number of cells in each row can be
  different, depending on what was stored in each row.
* Each cell lies in a column (**not** a column family). A column is really
  just a more **specific** modifier within a column family. A column
  can be present in every column family, in only one or anywhere in between.
* Within a column family there can be many columns. For example, within
  the column family ``foo`` we could have columns ``bar`` and ``baz``.
  These would typically be represented as ``foo:bar`` and ``foo:baz``.

Modifying Data
++++++++++++++

Since data is stored in cells, which are stored in rows, we
use the metaphor of a **row** in classes that are used to modify
(write, update, delete) data in a
:class:`Table <google.cloud.bigtable.table.Table>`.

Direct vs. Conditional vs. Append
---------------------------------

There are three ways to modify data in a table, described by the
`MutateRow`_, `CheckAndMutateRow`_ and `ReadModifyWriteRow`_ API
methods.

* The **direct** way is via `MutateRow`_ which involves simply
  adding, overwriting or deleting cells. The
  :class:`DirectRow <google.cloud.bigtable.row.DirectRow>` class
  handles direct mutations.
* The **conditional** way is via `CheckAndMutateRow`_. This method
  first checks if some filter is matched in a given row, then
  applies one of two sets of mutations, depending on if a match
  occurred or not. (These mutation sets are called the "true
  mutations" and "false mutations".) The
  :class:`ConditionalRow <google.cloud.bigtable.row.ConditionalRow>` class
  handles conditional mutations.
* The **append** way is via `ReadModifyWriteRow`_. This simply
  appends (as bytes) or increments (as an integer) data in a presumed
  existing cell in a row. The
  :class:`AppendRow <google.cloud.bigtable.row.AppendRow>` class
  handles append mutations.

Row Factory
-----------

A single factory can be used to create any of the three row types.
To create a :class:`DirectRow <google.cloud.bigtable.row.DirectRow>`:

.. code:: python

    row = table.row(row_key)

Unlike the previous string values we've used before, the row key must
be ``bytes``.

To create a :class:`ConditionalRow <google.cloud.bigtable.row.ConditionalRow>`,
first create a :class:`RowFilter <google.cloud.bigtable.row.RowFilter>` and
then

.. code:: python

    cond_row = table.row(row_key, filter_=filter_)

To create an :class:`AppendRow <google.cloud.bigtable.row.AppendRow>`

.. code:: python

    append_row = table.row(row_key, append=True)

Building Up Mutations
---------------------

In all three cases, a set of mutations (or two sets) are built up
on a row before they are sent off in a batch via

.. code:: python

    row.commit()

Direct Mutations
----------------

Direct mutations can be added via one of four methods

* :meth:`set_cell() <google.cloud.bigtable.row.DirectRow.set_cell>` allows a
  single value to be written to a column

  .. code:: python

      row.set_cell(column_family_id, column, value,
                   timestamp=timestamp)

  If the ``timestamp`` is omitted, the current time on the Google Cloud
  Bigtable server will be used when the cell is stored.

  The value can either be bytes or an integer, which will be converted to
  bytes as a signed 64-bit integer.

{'fraction_non_alphanumeric': 0.11750850562679926, 'fraction_numerical': 0.0010468463752944255, 'mean_word_length': 3.6603658536585364, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7273874', 'n_tokens_mistral': 2203, 'n_tokens_neox': 2113, 'n_words': 1000}