Class ConditionalRow (1.0.0)

ConditionalRow(row_key, table, filter_)

Google Cloud Bigtable Row for sending mutations conditionally.

Each mutation has an associated state: :data:True or :data:False. When commit-ed, the mutations for the :data:True state will be applied if the filter matches any cells in the row, otherwise the :data:False state will be applied.

A ConditionalRow accumulates mutations in the same way a DirectRow does:

  • set_cell
  • delete
  • delete_cell
  • delete_cells

with the only change the extra state parameter::

row_cond = table.row(b'row-key2', filter_=row_filter) row_cond.set_cell(u'fam', b'col', b'cell-val', state=True) row_cond.delete_cell(u'fam', b'col', state=False)

Parameters

NameDescription
row_key bytes

The key for the current row.

table Table

The table that owns the row.

filter_ .RowFilter

Filter to be used for conditional mutations.

Properties

row_key

Row key.

For example:

.. literalinclude:: snippets_table.py :start-after: [START bigtable_row_row_key] :end-before: [END bigtable_row_row_key]

Returns
TypeDescription
bytesThe key for the current row.

table

Row table.

For example:

.. literalinclude:: snippets_table.py :start-after: [START bigtable_row_table] :end-before: [END bigtable_row_table]

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

Methods

clear

clear()

Removes all currently accumulated mutations on the current row.

For example:

.. literalinclude:: snippets_table.py :start-after: [START bigtable_row_clear] :end-before: [END bigtable_row_clear]

commit

commit()

Makes a CheckAndMutateRow API request.

If no mutations have been created in the row, no request is made.

The mutations will be applied conditionally, based on whether the filter matches any cells in the ConditionalRow or not. (Each method which adds a mutation has a state parameter for this purpose.)

Mutations are applied atomically and in order, meaning that earlier mutations can be masked / negated by later ones. Cells already present in the row are left unchanged unless explicitly changed by a mutation.

After committing the accumulated mutations, resets the local mutations.

For example:

.. literalinclude:: snippets_table.py :start-after: [START bigtable_row_commit] :end-before: [END bigtable_row_commit]

Exceptions
TypeDescription
`ValueErro
Returns
TypeDescription
boolFlag indicating if the filter was matched (which also indicates which set of mutations were applied by the server).

delete

delete(state=True)

Deletes this row from the table.

.. literalinclude:: snippets_table.py :start-after: [START bigtable_row_delete] :end-before: [END bigtable_row_delete]

Parameter
NameDescription
state bool

(Optional) The state that the mutation should be applied in. Defaults to :data:True.

delete_cell

delete_cell(column_family_id, column, time_range=None, state=True)

Deletes cell in this row.

.. literalinclude:: snippets_table.py :start-after: [START bigtable_row_delete_cell] :end-before: [END bigtable_row_delete_cell]

Parameters
NameDescription
column_family_id str

The column family that contains the column or columns with cells being deleted. Must be of the form <code>_a-zA-Z0-9][-_.a-zA-Z0-9]</code>*.

column bytes

The column within the column family that will have a cell deleted.

time_range TimestampRange

(Optional) The range of time within which cells should be deleted.

state bool

(Optional) The state that the mutation should be applied in. Defaults to :data:True.

delete_cells

delete_cells(column_family_id, columns, time_range=None, state=True)

Deletes cells in this row.

.. literalinclude:: snippets_table.py :start-after: [START bigtable_row_delete_cells] :end-before: [END bigtable_row_delete_cells]

Parameters
NameDescription
column_family_id str

The column family that contains the column or columns with cells being deleted. Must be of the form <code>_a-zA-Z0-9][-_.a-zA-Z0-9]</code>*.

columns list of str / unicode , or object

The columns within the column family that will have cells deleted. If ALL_COLUMNS is used then the entire column family will be deleted from the row.

time_range TimestampRange

(Optional) The range of time within which cells should be deleted.

state bool

(Optional) The state that the mutation should be applied in. Defaults to :data:True.

set_cell

set_cell(column_family_id, column, value, timestamp=None, state=True)

Sets a value in this row.

The cell is determined by the row_key of this ConditionalRow and the column. The column must be in an existing .ColumnFamily (as determined by column_family_id).

.. literalinclude:: snippets_table.py :start-after: [START bigtable_row_set_cell] :end-before: [END bigtable_row_set_cell]

Parameters
NameDescription
column_family_id str

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

column bytes

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

value bytes or int

The value to set in the cell. If an integer is used, will be interpreted as a 64-bit big-endian signed integer (8 bytes).

timestamp datetime.datetime

(Optional) The timestamp of the operation.

state bool

(Optional) The state that the mutation should be applied in. Defaults to :data:True.