@@ -24,23 +24,11 @@ Cells vs. Columns vs. Column Families
2424Modifying Data
2525++++++++++++++
2626
27- Since data is stored in cells, which are stored in rows, the
28- :class: ` Row <gcloud.bigtable.row.Row> ` class is the only class used to
29- modify (write, update, delete) data in a
27+ Since data is stored in cells, which are stored in rows, we
28+ use the metaphor of a ** row ** in classes that are used to modify
29+ (write, update, delete) data in a
3030:class: `Table <gcloud.bigtable.table.Table> `.
3131
32- Row Factory
33- -----------
34-
35- To create a :class: `Row <gcloud.bigtable.row.Row> ` object
36-
37- .. code :: python
38-
39- row = table.row(row_key)
40-
41- Unlike the previous string values we've used before, the row key must
42- be ``bytes ``.
43-
4432Direct vs. Conditional vs. Append
4533---------------------------------
4634
@@ -49,43 +37,65 @@ There are three ways to modify data in a table, described by the
4937methods.
5038
5139* The **direct ** way is via `MutateRow `_ which involves simply
52- adding, overwriting or deleting cells.
40+ adding, overwriting or deleting cells. The
41+ :class: `DirectRow <gcloud.bigtable.row.DirectRow> ` class
42+ handles direct mutations.
5343* The **conditional ** way is via `CheckAndMutateRow `_. This method
5444 first checks if some filter is matched in a a given row, then
5545 applies one of two sets of mutations, depending on if a match
5646 occurred or not. (These mutation sets are called the "true
57- mutations" and "false mutations".)
47+ mutations" and "false mutations".) The
48+ :class: `ConditionalRow <gcloud.bigtable.row.ConditionalRow> ` class
49+ handles conditional mutations.
5850* The **append ** way is via `ReadModifyWriteRow `_. This simply
5951 appends (as bytes) or increments (as an integer) data in a presumed
60- existing cell in a row.
52+ existing cell in a row. The
53+ :class: `AppendRow <gcloud.bigtable.row.AppendRow> ` class
54+ handles append mutations.
6155
62- Building Up Mutations
63- ---------------------
56+ Row Factory
57+ -----------
6458
65- In all three cases, a set of mutations (or two sets) are built up
66- on a :class: `Row <gcloud.bigtable.row.Row> ` before they are sent of
67- in a batch via :meth: `commit() <gcloud.bigtable.row.Row.commit> `:
59+ A single factory can be used to create any of the three row types.
60+ To create a :class: `DirectRow <gcloud.bigtable.row.DirectRow> `:
6861
6962.. code :: python
7063
71- row.commit( )
64+ row = table.row(row_key )
7265
73- To send **append ** mutations in batch, use
74- :meth: `commit_modifications() <gcloud.bigtable.row.Row.commit_modifications> `:
66+ Unlike the previous string values we've used before, the row key must
67+ be ``bytes ``.
68+
69+ To create a :class: `ConditionalRow <gcloud.bigtable.row.ConditionalRow> `,
70+ first create a :class: `RowFilter <gcloud.bigtable.row.RowFilter> ` and
71+ then
7572
7673.. code :: python
7774
78- row.commit_modifications( )
75+ cond_row = table.row(row_key, filter_ = filter_ )
7976
80- We have a small set of methods on the :class: `Row <gcloud.bigtable.row.Row> `
81- to build these mutations up.
77+ To create an :class: `AppendRow <gcloud.bigtable.row.AppendRow> `
78+
79+ .. code :: python
80+
81+ append_row = table.row(row_key, append = True )
82+
83+ Building Up Mutations
84+ ---------------------
85+
86+ In all three cases, a set of mutations (or two sets) are built up
87+ on a row before they are sent of in a batch via
88+
89+ .. code :: python
90+
91+ row.commit()
8292
8393 Direct Mutations
8494----------------
8595
8696Direct mutations can be added via one of four methods
8797
88- * :meth: `set_cell() <gcloud.bigtable.row.Row .set_cell> ` allows a
98+ * :meth: `set_cell() <gcloud.bigtable.row.DirectRow .set_cell> ` allows a
8999 single value to be written to a column
90100
91101 .. code :: python
@@ -97,9 +107,9 @@ Direct mutations can be added via one of four methods
97107 Bigtable server will be used when the cell is stored.
98108
99109 The value can either by bytes or an integer (which will be converted to
100- bytes as an unsigned 64-bit integer).
110+ bytes as a signed 64-bit integer).
101111
102- * :meth: `delete_cell() <gcloud.bigtable.row.Row .delete_cell> ` deletes
112+ * :meth: `delete_cell() <gcloud.bigtable.row.DirectRow .delete_cell> ` deletes
103113 all cells (i.e. for all timestamps) in a given column
104114
105115 .. code :: python
@@ -117,8 +127,9 @@ Direct mutations can be added via one of four methods
117127 row.delete_cell(column_family_id, column,
118128 time_range = time_range)
119129
120- * :meth: `delete_cells() <gcloud.bigtable.row.Row.delete_cells> ` does
121- the same thing as :meth: `delete_cell() <gcloud.bigtable.row.Row.delete_cell> `
130+ * :meth: `delete_cells() <gcloud.bigtable.row.DirectRow.delete_cells> ` does
131+ the same thing as
132+ :meth: `delete_cell() <gcloud.bigtable.row.DirectRow.delete_cell> `
122133 but accepts a list of columns in a column family rather than a single one.
123134
124135 .. code :: python
@@ -127,15 +138,16 @@ Direct mutations can be added via one of four methods
127138 time_range = time_range)
128139
129140 In addition, if we want to delete cells from every column in a column family,
130- the special :attr: `ALL_COLUMNS <gcloud.bigtable.row.Row .ALL_COLUMNS> ` value
131- can be used
141+ the special :attr: `ALL_COLUMNS <gcloud.bigtable.row.DirectRow .ALL_COLUMNS> `
142+ value can be used
132143
133144 .. code :: python
134145
135- row.delete_cells(column_family_id, Row .ALL_COLUMNS ,
146+ row.delete_cells(column_family_id, row .ALL_COLUMNS ,
136147 time_range = time_range)
137148
138- * :meth: `delete() <gcloud.bigtable.row.Row.delete> ` will delete the entire row
149+ * :meth: `delete() <gcloud.bigtable.row.DirectRow.delete> ` will delete the
150+ entire row
139151
140152 .. code :: python
141153
@@ -145,57 +157,42 @@ Conditional Mutations
145157---------------------
146158
147159Making **conditional ** modifications is essentially identical
148- to **direct ** modifications, but we need to specify a filter to match
149- against in the row:
160+ to **direct ** modifications: it uses the exact same methods
161+ to accumulate mutations.
150162
151- .. code :: python
152-
153- row = table.row(row_key, filter_ = filter_val)
154-
155- See the :class: `Row <gcloud.bigtable.row.Row> ` class for more information
156- about acceptable values for ``filter_ ``.
157-
158- The only other difference from **direct ** modifications are that each mutation
159- added must specify a ``state ``: will the mutation be applied if the filter
160- matches or if it fails to match.
163+ However, each mutation added must specify a ``state ``: will the mutation be
164+ applied if the filter matches or if it fails to match.
161165
162166For example:
163167
164168.. code :: python
165169
166- row .set_cell(column_family_id, column, value,
167- timestamp = timestamp, state = True )
170+ cond_row .set_cell(column_family_id, column, value,
171+ timestamp = timestamp, state = True )
168172
169173 will add to the set of true mutations.
170174
171- .. note ::
172-
173- If ``state `` is passed when no ``filter_ `` is set on a
174- :class: `Row <gcloud.bigtable.row.Row> `, adding the mutation will fail.
175- Similarly, if no ``state `` is passed when a ``filter_ `` has been set,
176- adding the mutation will fail.
177-
178175Append Mutations
179176----------------
180177
181178Append mutations can be added via one of two methods
182179
183- * :meth: `append_cell_value() <gcloud.bigtable.row.Row .append_cell_value> `
180+ * :meth: `append_cell_value() <gcloud.bigtable.row.AppendRow .append_cell_value> `
184181 appends a bytes value to an existing cell:
185182
186183 .. code :: python
187184
188- row .append_cell_value(column_family_id, column, bytes_value)
185+ append_row .append_cell_value(column_family_id, column, bytes_value)
189186
190- * :meth: `increment_cell_value() <gcloud.bigtable.row.Row .increment_cell_value> `
187+ * :meth: `increment_cell_value() <gcloud.bigtable.row.AppendRow .increment_cell_value> `
191188 increments an integer value in an existing cell:
192189
193190 .. code :: python
194191
195- row .increment_cell_value(column_family_id, column, int_value)
192+ append_row .increment_cell_value(column_family_id, column, int_value)
196193
197194 Since only bytes are stored in a cell, the cell value is decoded as
198- an unsigned 64-bit integer before being incremented. (This happens on
195+ a signed 64-bit integer before being incremented. (This happens on
199196 the Google Cloud Bigtable server, not in the library.)
200197
201198Notice that no timestamp was specified. This is because **append ** mutations
@@ -208,18 +205,10 @@ Starting Fresh
208205--------------
209206
210207If accumulated mutations need to be dropped, use
211- :meth: `clear_mutations() <gcloud.bigtable.row.Row.clear_mutations> `
212-
213- .. code :: python
214-
215- row.clear_mutations()
216-
217- To clear **append ** mutations, use
218- :meth: `clear_modification_rules() <gcloud.bigtable.row.Row.clear_modification_rules> `
219208
220209.. code :: python
221210
222- row.clear_modification_rules ()
211+ row.clear ()
223212
224213 Reading Data
225214++++++++++++
@@ -260,19 +249,20 @@ To make a `ReadRows`_ API request for a single row key, use
260249 >> > cell.timestamp
261250 datetime.datetime(2016 , 2 , 27 , 3 , 41 , 18 , 122823 , tzinfo = < UTC > )
262251
263- Rather than returning a :class: `Row <gcloud.bigtable.row.Row> `, this method
264- returns a :class: `PartialRowData <gcloud.bigtable.row_data.PartialRowData> `
252+ Rather than returning a :class: `DirectRow <gcloud.bigtable.row.DirectRow> `
253+ or similar class, this method returns a
254+ :class: `PartialRowData <gcloud.bigtable.row_data.PartialRowData> `
265255instance. This class is used for reading and parsing data rather than for
266- modifying data (as :class: `Row <gcloud.bigtable.row.Row > ` is).
256+ modifying data (as :class: `DirectRow <gcloud.bigtable.row.DirectRow > ` is).
267257
268- A filter can also be applied to the
258+ A filter can also be applied to the results:
269259
270260.. code :: python
271261
272262 row_data = table.read_row(row_key, filter_ = filter_val)
273263
274264 The allowable ``filter_ `` values are the same as those used for a
275- :class: `Row <gcloud.bigtable.row.Row> ` with ** conditional ** mutations . For
265+ :class: `ConditionalRow <gcloud.bigtable.row.ConditionalRow> ` . For
276266more information, see the
277267:meth: `Table.read_row() <gcloud.bigtable.table.Table.read_row> ` documentation.
278268
0 commit comments