Class AppendRow (2.11.2)

AppendRow(row_key, table)

Google Cloud Bigtable Row for sending append mutations.

These mutations are intended to augment the value of an existing cell and uses the methods:

  • append_cell_value
  • increment_cell_value

The first works by appending bytes and the second by incrementing an integer (stored in the cell as 8 bytes). In either case, if the cell is empty, assumes the default empty value (empty string for bytes or 0 for integer).

Parameters

NameDescription
row_key bytes

The key for the current row.

table Table

The table that owns the row.

Inheritance

builtins.object > Row > AppendRow

Properties

row_key

Row key.

For example:

.. literalinclude:: snippets_table.py :start-after: [START bigtable_api_row_row_key] :end-before: [END bigtable_api_row_row_key] :dedent: 4

Returns
TypeDescription
bytesThe key for the current row.

table

Row table.

For example:

.. literalinclude:: snippets_table.py :start-after: [START bigtable_api_row_table] :end-before: [END bigtable_api_row_table] :dedent: 4

Returns
TypeDescription
table: Tabletable: The table that owns the row.

Methods

append_cell_value

append_cell_value(column_family_id, column, value)

Appends a value to an existing cell.

.. literalinclude:: snippets_table.py :start-after: [START bigtable_api_row_append_cell_value] :end-before: [END bigtable_api_row_append_cell_value] :dedent: 4

Parameters
NameDescription
column_family_id str

The column family that contains the column. Must be of the form `_a-zA-Z0-9][-_.a-zA-Z0-9]`*.

column bytes

The column within the column family where the cell is located.

value bytes

The value to append to the existing value in the cell. If the targeted cell is unset, it will be treated as containing the empty string.

clear

clear()

Removes all currently accumulated modifications on current row.

For example:

.. literalinclude:: snippets_table.py :start-after: [START bigtable_api_row_clear] :end-before: [END bigtable_api_row_clear] :dedent: 4

commit

commit()

Makes a ReadModifyWriteRow API request.

This commits modifications made by append_cell_value and increment_cell_value. If no modifications were made, makes no API request and just returns {}.

Modifies a row atomically, reading the latest existing timestamp / value from the specified columns and writing a new value by appending / incrementing. The new cell created uses either the current server time or the highest timestamp of a cell in that column (if it exceeds the server time).

After committing the accumulated mutations, resets the local mutations.

For example:

.. literalinclude:: snippets_table.py :start-after: [START bigtable_api_row_commit] :end-before: [END bigtable_api_row_commit] :dedent: 4

Exceptions
TypeDescription
`ValueErro
Returns
TypeDescription
dictThe new contents of all modified cells. Returned as a dictionary of column families, each of which holds a dictionary of columns. Each column contains a list of cells modified. Each cell is represented with a two-tuple with the value (in bytes) and the timestamp for the cell.

increment_cell_value

increment_cell_value(column_family_id, column, int_value)

Increments a value in an existing cell.

Assumes the value in the cell is stored as a 64 bit integer serialized to bytes.

.. literalinclude:: snippets_table.py :start-after: [START bigtable_api_row_increment_cell_value] :end-before: [END bigtable_api_row_increment_cell_value] :dedent: 4

Parameters
NameDescription
column_family_id str

The column family that contains the column. Must be of the form `_a-zA-Z0-9][-_.a-zA-Z0-9]`*.

column bytes

The column within the column family where the cell is located.

int_value int

The value to increment the existing value in the cell by. If the targeted cell is unset, it will be treated as containing a zero. Otherwise, the targeted cell must contain an 8-byte value (interpreted as a 64-bit big-endian signed integer), or the entire request will fail.