1313# See the License for the specific language governing permissions and
1414# limitations under the License.
1515
16- # [START bigtable_filters_print]
17- import datetime
18-
19- from google .cloud import bigtable
20- import google .cloud .bigtable .row_filters as row_filters
21-
22- # Write your code here.
23- # [START_EXCLUDE]
24-
2516
2617# [START bigtable_filters_limit_row_sample]
2718def filter_limit_row_sample (project_id , instance_id , table_id ):
19+ from google .cloud import bigtable
20+ from google .cloud .bigtable import row_filters
21+
2822 client = bigtable .Client (project = project_id , admin = True )
2923 instance = client .instance (instance_id )
3024 table = instance .table (table_id )
@@ -37,6 +31,9 @@ def filter_limit_row_sample(project_id, instance_id, table_id):
3731# [END bigtable_filters_limit_row_sample]
3832# [START bigtable_filters_limit_row_regex]
3933def filter_limit_row_regex (project_id , instance_id , table_id ):
34+ from google .cloud import bigtable
35+ from google .cloud .bigtable import row_filters
36+
4037 client = bigtable .Client (project = project_id , admin = True )
4138 instance = client .instance (instance_id )
4239 table = instance .table (table_id )
@@ -51,6 +48,9 @@ def filter_limit_row_regex(project_id, instance_id, table_id):
5148# [END bigtable_filters_limit_row_regex]
5249# [START bigtable_filters_limit_cells_per_col]
5350def filter_limit_cells_per_col (project_id , instance_id , table_id ):
51+ from google .cloud import bigtable
52+ from google .cloud .bigtable import row_filters
53+
5454 client = bigtable .Client (project = project_id , admin = True )
5555 instance = client .instance (instance_id )
5656 table = instance .table (table_id )
@@ -63,6 +63,9 @@ def filter_limit_cells_per_col(project_id, instance_id, table_id):
6363# [END bigtable_filters_limit_cells_per_col]
6464# [START bigtable_filters_limit_cells_per_row]
6565def filter_limit_cells_per_row (project_id , instance_id , table_id ):
66+ from google .cloud import bigtable
67+ from google .cloud .bigtable import row_filters
68+
6669 client = bigtable .Client (project = project_id , admin = True )
6770 instance = client .instance (instance_id )
6871 table = instance .table (table_id )
@@ -75,6 +78,9 @@ def filter_limit_cells_per_row(project_id, instance_id, table_id):
7578# [END bigtable_filters_limit_cells_per_row]
7679# [START bigtable_filters_limit_cells_per_row_offset]
7780def filter_limit_cells_per_row_offset (project_id , instance_id , table_id ):
81+ from google .cloud import bigtable
82+ from google .cloud .bigtable import row_filters
83+
7884 client = bigtable .Client (project = project_id , admin = True )
7985 instance = client .instance (instance_id )
8086 table = instance .table (table_id )
@@ -87,6 +93,9 @@ def filter_limit_cells_per_row_offset(project_id, instance_id, table_id):
8793# [END bigtable_filters_limit_cells_per_row_offset]
8894# [START bigtable_filters_limit_col_family_regex]
8995def filter_limit_col_family_regex (project_id , instance_id , table_id ):
96+ from google .cloud import bigtable
97+ from google .cloud .bigtable import row_filters
98+
9099 client = bigtable .Client (project = project_id , admin = True )
91100 instance = client .instance (instance_id )
92101 table = instance .table (table_id )
@@ -101,6 +110,9 @@ def filter_limit_col_family_regex(project_id, instance_id, table_id):
101110# [END bigtable_filters_limit_col_family_regex]
102111# [START bigtable_filters_limit_col_qualifier_regex]
103112def filter_limit_col_qualifier_regex (project_id , instance_id , table_id ):
113+ from google .cloud import bigtable
114+ from google .cloud .bigtable import row_filters
115+
104116 client = bigtable .Client (project = project_id , admin = True )
105117 instance = client .instance (instance_id )
106118 table = instance .table (table_id )
@@ -115,6 +127,9 @@ def filter_limit_col_qualifier_regex(project_id, instance_id, table_id):
115127# [END bigtable_filters_limit_col_qualifier_regex]
116128# [START bigtable_filters_limit_col_range]
117129def filter_limit_col_range (project_id , instance_id , table_id ):
130+ from google .cloud import bigtable
131+ from google .cloud .bigtable import row_filters
132+
118133 client = bigtable .Client (project = project_id , admin = True )
119134 instance = client .instance (instance_id )
120135 table = instance .table (table_id )
@@ -131,6 +146,9 @@ def filter_limit_col_range(project_id, instance_id, table_id):
131146# [END bigtable_filters_limit_col_range]
132147# [START bigtable_filters_limit_value_range]
133148def filter_limit_value_range (project_id , instance_id , table_id ):
149+ from google .cloud import bigtable
150+ from google .cloud .bigtable import row_filters
151+
134152 client = bigtable .Client (project = project_id , admin = True )
135153 instance = client .instance (instance_id )
136154 table = instance .table (table_id )
@@ -148,6 +166,9 @@ def filter_limit_value_range(project_id, instance_id, table_id):
148166
149167
150168def filter_limit_value_regex (project_id , instance_id , table_id ):
169+ from google .cloud import bigtable
170+ from google .cloud .bigtable import row_filters
171+
151172 client = bigtable .Client (project = project_id , admin = True )
152173 instance = client .instance (instance_id )
153174 table = instance .table (table_id )
@@ -162,6 +183,10 @@ def filter_limit_value_regex(project_id, instance_id, table_id):
162183# [END bigtable_filters_limit_value_regex]
163184# [START bigtable_filters_limit_timestamp_range]
164185def filter_limit_timestamp_range (project_id , instance_id , table_id ):
186+ from google .cloud import bigtable
187+ from google .cloud .bigtable import row_filters
188+ import datetime
189+
165190 client = bigtable .Client (project = project_id , admin = True )
166191 instance = client .instance (instance_id )
167192 table = instance .table (table_id )
@@ -178,6 +203,9 @@ def filter_limit_timestamp_range(project_id, instance_id, table_id):
178203# [END bigtable_filters_limit_timestamp_range]
179204# [START bigtable_filters_limit_block_all]
180205def filter_limit_block_all (project_id , instance_id , table_id ):
206+ from google .cloud import bigtable
207+ from google .cloud .bigtable import row_filters
208+
181209 client = bigtable .Client (project = project_id , admin = True )
182210 instance = client .instance (instance_id )
183211 table = instance .table (table_id )
@@ -190,6 +218,9 @@ def filter_limit_block_all(project_id, instance_id, table_id):
190218# [END bigtable_filters_limit_block_all]
191219# [START bigtable_filters_limit_pass_all]
192220def filter_limit_pass_all (project_id , instance_id , table_id ):
221+ from google .cloud import bigtable
222+ from google .cloud .bigtable import row_filters
223+
193224 client = bigtable .Client (project = project_id , admin = True )
194225 instance = client .instance (instance_id )
195226 table = instance .table (table_id )
@@ -202,6 +233,9 @@ def filter_limit_pass_all(project_id, instance_id, table_id):
202233# [END bigtable_filters_limit_pass_all]
203234# [START bigtable_filters_modify_strip_value]
204235def filter_modify_strip_value (project_id , instance_id , table_id ):
236+ from google .cloud import bigtable
237+ from google .cloud .bigtable import row_filters
238+
205239 client = bigtable .Client (project = project_id , admin = True )
206240 instance = client .instance (instance_id )
207241 table = instance .table (table_id )
@@ -214,6 +248,9 @@ def filter_modify_strip_value(project_id, instance_id, table_id):
214248# [END bigtable_filters_modify_strip_value]
215249# [START bigtable_filters_modify_apply_label]
216250def filter_modify_apply_label (project_id , instance_id , table_id ):
251+ from google .cloud import bigtable
252+ from google .cloud .bigtable import row_filters
253+
217254 client = bigtable .Client (project = project_id , admin = True )
218255 instance = client .instance (instance_id )
219256 table = instance .table (table_id )
@@ -226,6 +263,9 @@ def filter_modify_apply_label(project_id, instance_id, table_id):
226263# [END bigtable_filters_modify_apply_label]
227264# [START bigtable_filters_composing_chain]
228265def filter_composing_chain (project_id , instance_id , table_id ):
266+ from google .cloud import bigtable
267+ from google .cloud .bigtable import row_filters
268+
229269 client = bigtable .Client (project = project_id , admin = True )
230270 instance = client .instance (instance_id )
231271 table = instance .table (table_id )
@@ -245,6 +285,9 @@ def filter_composing_chain(project_id, instance_id, table_id):
245285# [END bigtable_filters_composing_chain]
246286# [START bigtable_filters_composing_interleave]
247287def filter_composing_interleave (project_id , instance_id , table_id ):
288+ from google .cloud import bigtable
289+ from google .cloud .bigtable import row_filters
290+
248291 client = bigtable .Client (project = project_id , admin = True )
249292 instance = client .instance (instance_id )
250293 table = instance .table (table_id )
@@ -264,6 +307,9 @@ def filter_composing_interleave(project_id, instance_id, table_id):
264307# [END bigtable_filters_composing_interleave]
265308# [START bigtable_filters_composing_condition]
266309def filter_composing_condition (project_id , instance_id , table_id ):
310+ from google .cloud import bigtable
311+ from google .cloud .bigtable import row_filters
312+
267313 client = bigtable .Client (project = project_id , admin = True )
268314 instance = client .instance (instance_id )
269315 table = instance .table (table_id )
@@ -285,9 +331,8 @@ def filter_composing_condition(project_id, instance_id, table_id):
285331
286332
287333# [END bigtable_filters_composing_condition]
288- # [END_EXCLUDE]
289-
290334
335+ # [START bigtable_filters_print]
291336def print_row (row ):
292337 print ("Reading data for {}:" .format (row .row_key .decode ("utf-8" )))
293338 for cf , cols in sorted (row .cells .items ()):
0 commit comments