google-cloud-bigtable 0.6.1 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/AUTHENTICATION.md +4 -26
  3. data/CHANGELOG.md +85 -0
  4. data/CONTRIBUTING.md +1 -1
  5. data/OVERVIEW.md +388 -19
  6. data/lib/google-cloud-bigtable.rb +19 -22
  7. data/lib/google/bigtable/admin/v2/bigtable_table_admin_services_pb.rb +1 -1
  8. data/lib/google/bigtable/v2/bigtable_pb.rb +3 -0
  9. data/lib/google/bigtable/v2/bigtable_services_pb.rb +1 -1
  10. data/lib/google/cloud/bigtable.rb +11 -17
  11. data/lib/google/cloud/bigtable/admin.rb +1 -1
  12. data/lib/google/cloud/bigtable/admin/v2.rb +1 -1
  13. data/lib/google/cloud/bigtable/admin/v2/bigtable_table_admin_client.rb +1 -1
  14. data/lib/google/cloud/bigtable/admin/v2/doc/google/iam/v1/policy.rb +42 -21
  15. data/lib/google/cloud/bigtable/app_profile.rb +162 -96
  16. data/lib/google/cloud/bigtable/app_profile/job.rb +5 -8
  17. data/lib/google/cloud/bigtable/app_profile/list.rb +18 -12
  18. data/lib/google/cloud/bigtable/chunk_processor.rb +24 -36
  19. data/lib/google/cloud/bigtable/cluster.rb +45 -18
  20. data/lib/google/cloud/bigtable/cluster/job.rb +3 -7
  21. data/lib/google/cloud/bigtable/cluster/list.rb +22 -20
  22. data/lib/google/cloud/bigtable/column_family.rb +18 -231
  23. data/lib/google/cloud/bigtable/column_family_map.rb +426 -0
  24. data/lib/google/cloud/bigtable/column_range.rb +15 -7
  25. data/lib/google/cloud/bigtable/convert.rb +12 -4
  26. data/lib/google/cloud/bigtable/errors.rb +4 -1
  27. data/lib/google/cloud/bigtable/gc_rule.rb +188 -69
  28. data/lib/google/cloud/bigtable/instance.rb +209 -189
  29. data/lib/google/cloud/bigtable/instance/cluster_map.rb +17 -13
  30. data/lib/google/cloud/bigtable/instance/job.rb +6 -5
  31. data/lib/google/cloud/bigtable/instance/list.rb +18 -13
  32. data/lib/google/cloud/bigtable/longrunning_job.rb +7 -1
  33. data/lib/google/cloud/bigtable/mutation_entry.rb +36 -39
  34. data/lib/google/cloud/bigtable/mutation_operations.rb +90 -73
  35. data/lib/google/cloud/bigtable/policy.rb +9 -5
  36. data/lib/google/cloud/bigtable/project.rb +87 -196
  37. data/lib/google/cloud/bigtable/read_modify_write_rule.rb +15 -10
  38. data/lib/google/cloud/bigtable/read_operations.rb +42 -59
  39. data/lib/google/cloud/bigtable/routing_policy.rb +172 -0
  40. data/lib/google/cloud/bigtable/row.rb +32 -21
  41. data/lib/google/cloud/bigtable/row_filter.rb +80 -35
  42. data/lib/google/cloud/bigtable/row_filter/chain_filter.rb +119 -68
  43. data/lib/google/cloud/bigtable/row_filter/condition_filter.rb +8 -2
  44. data/lib/google/cloud/bigtable/row_filter/interleave_filter.rb +117 -66
  45. data/lib/google/cloud/bigtable/row_filter/simple_filter.rb +24 -9
  46. data/lib/google/cloud/bigtable/row_range.rb +5 -0
  47. data/lib/google/cloud/bigtable/rows_mutator.rb +14 -21
  48. data/lib/google/cloud/bigtable/rows_reader.rb +23 -18
  49. data/lib/google/cloud/bigtable/sample_row_key.rb +6 -3
  50. data/lib/google/cloud/bigtable/service.rb +200 -253
  51. data/lib/google/cloud/bigtable/status.rb +76 -0
  52. data/lib/google/cloud/bigtable/table.rb +158 -262
  53. data/lib/google/cloud/bigtable/table/cluster_state.rb +17 -6
  54. data/lib/google/cloud/bigtable/table/list.rb +16 -9
  55. data/lib/google/cloud/bigtable/v2.rb +1 -1
  56. data/lib/google/cloud/bigtable/v2/bigtable_client.rb +12 -12
  57. data/lib/google/cloud/bigtable/v2/doc/google/bigtable/v2/bigtable.rb +16 -13
  58. data/lib/google/cloud/bigtable/value_range.rb +19 -13
  59. data/lib/google/cloud/bigtable/version.rb +1 -1
  60. metadata +67 -25
  61. data/lib/google/cloud/bigtable/table/column_family_map.rb +0 -70
@@ -19,6 +19,7 @@ module Google
19
19
  module Cloud
20
20
  module Bigtable
21
21
  module RowFilter
22
+ ##
22
23
  # # ConditionFilter
23
24
  #
24
25
  # A RowFilter that evaluates one of two possible RowFilters, depending on
@@ -51,7 +52,8 @@ module Google
51
52
  @grpc.predicate_filter = predicate.to_grpc
52
53
  end
53
54
 
54
- # Set a true filter on predicate-filter match.
55
+ ##
56
+ # Sets a true filter on predicate-filter match.
55
57
  #
56
58
  # The filter to apply to the input row if `predicate_filter` returns any
57
59
  # results. If not provided, no results will be returned in the true case.
@@ -60,6 +62,7 @@ module Google
60
62
  # @return [Google::Cloud::Bigtable::RowFilter::ConditionFilter]
61
63
  #
62
64
  # @example
65
+ # require "google/cloud/bigtable"
63
66
  # predicate = Google::Cloud::Bigtable::RowFilter.key("user-*")
64
67
  #
65
68
  # label = Google::Cloud::Bigtable::RowFilter.label("user")
@@ -72,6 +75,7 @@ module Google
72
75
  self
73
76
  end
74
77
 
78
+ ##
75
79
  # Set otherwise(false) filter.
76
80
  #
77
81
  # The filter to apply to the input row if `predicate_filter` does not
@@ -82,6 +86,8 @@ module Google
82
86
  # @return [Google::Cloud::Bigtable::RowFilter::ConditionFilter]
83
87
  #
84
88
  # @example
89
+ # require "google/cloud/bigtable"
90
+ #
85
91
  # predicate = Google::Cloud::Bigtable::RowFilter.key("user-*")
86
92
  #
87
93
  # label = Google::Cloud::Bigtable::RowFilter.label("user")
@@ -99,7 +105,7 @@ module Google
99
105
  # @return [Google::Bigtable::V2::RowFilter]
100
106
  #
101
107
  def to_grpc
102
- Google::Bigtable::V2::RowFilter.new(condition: @grpc)
108
+ Google::Bigtable::V2::RowFilter.new condition: @grpc
103
109
  end
104
110
  end
105
111
  end
@@ -19,6 +19,7 @@ module Google
19
19
  module Cloud
20
20
  module Bigtable
21
21
  module RowFilter
22
+ ##
22
23
  # # InterleaveFilter
23
24
  #
24
25
  # A RowFilter that sends each row to each of several component
@@ -51,6 +52,7 @@ module Google
51
52
  # All interleaved filters are executed atomically.
52
53
  #
53
54
  # @example Create an interleave filter with a simple filter.
55
+ # require "google/cloud/bigtable"
54
56
  #
55
57
  # interleave = Google::Cloud::Bigtable::RowFilter.interleave
56
58
  #
@@ -59,24 +61,28 @@ module Google
59
61
  # interleave.sink
60
62
  #
61
63
  # # OR
62
- # interleave.key("user-*).sink
64
+ # interleave.key("user-*").sink
63
65
  #
64
66
  # @example Create a complex interleave filter.
67
+ # require "google/cloud/bigtable"
65
68
  #
66
- # interleave = Google::Cloud::Bigtable::RowFilter.interleave
69
+ # interleave = Google::Cloud::Bigtable::RowFilter.interleave
67
70
  #
68
- # chain_1 = Google::Cloud::Bigtable::RowFilter.chain
69
- # chain_1.label("users").qualifier("name").cells_per_row(5)
71
+ # chain_1 = Google::Cloud::Bigtable::RowFilter.chain
72
+ # chain_1.label("users").qualifier("name").cells_per_row(5)
70
73
  #
71
- # # Add to main chain filter
72
- # interleave.chain(chain_1).value("xyz*).key("user-*")
74
+ # # Add to main chain filter
75
+ # interleave.chain(chain_1).value("xyz*").key("user-*")
73
76
  #
74
77
  class InterleaveFilter
78
+ # @private
79
+ # Creates an instance of an interleave filter.
75
80
  def initialize
76
- @grpc = Google::Bigtable::V2::RowFilter::Interleave.new
81
+ @filters = []
77
82
  end
78
83
 
79
- # Adds a chain filter instance.
84
+ ##
85
+ # Adds a chain filter.
80
86
  #
81
87
  # A Chain RowFilter that sends rows through several RowFilters in sequence.
82
88
  #
@@ -91,6 +97,7 @@ module Google
91
97
  # `self` instance of interleave filter.
92
98
  #
93
99
  # @example Create a chain filter and add an interleave filter.
100
+ # require "google/cloud/bigtable"
94
101
  #
95
102
  # chain = Google::Cloud::Bigtable::RowFilter.chain
96
103
  #
@@ -100,12 +107,11 @@ module Google
100
107
  # filter = Google::Cloud::Bigtable::RowFilter.interleave.chain(chain)
101
108
  #
102
109
  def chain filter
103
- unless filter.instance_of?(ChainFilter)
104
- raise RowFilterError, "Filter type must be ChainFilter"
105
- end
106
- add(filter)
110
+ raise RowFilterError, "Filter type must be ChainFilter" unless filter.instance_of? ChainFilter
111
+ add filter
107
112
  end
108
113
 
114
+ ##
109
115
  # Adds an interleave filter.
110
116
  #
111
117
  # A RowFilter that sends each row to each of several component
@@ -142,6 +148,7 @@ module Google
142
148
  # `self` instance of interleave filter.
143
149
  #
144
150
  # @example Add an interleave filter to a chain filter.
151
+ # require "google/cloud/bigtable"
145
152
  #
146
153
  # interleave = Google::Cloud::Bigtable::RowFilter.interleave
147
154
  #
@@ -151,13 +158,12 @@ module Google
151
158
  # filter = Google::Cloud::Bigtable::RowFilter.interleave.interleave(interleave)
152
159
  #
153
160
  def interleave filter
154
- unless filter.instance_of?(InterleaveFilter)
155
- raise RowFilterError, "Filter type must be InterleaveFilter"
156
- end
157
- add(filter)
161
+ raise RowFilterError, "Filter type must be InterleaveFilter" unless filter.instance_of? InterleaveFilter
162
+ add filter
158
163
  end
159
164
 
160
- # Adds a condition filter instance.
165
+ ##
166
+ # Adds a condition filter.
161
167
  #
162
168
  # A RowFilter that evaluates one of two possible RowFilters, depending on
163
169
  # whether or not a predicate RowFilter outputs any cells from the input row.
@@ -174,24 +180,25 @@ module Google
174
180
  # `self` instance of interleave filter.
175
181
  #
176
182
  # @example
183
+ # require "google/cloud/bigtable"
177
184
  #
178
185
  # predicate = Google::Cloud::Bigtable::RowFilter.key("user-*")
179
186
  #
180
187
  # label = Google::Cloud::Bigtable::RowFilter.label("user")
181
188
  # strip_value = Google::Cloud::Bigtable::RowFilter.strip_value
182
189
  #
183
- # condition_filter = Google::Cloud::Bigtable::RowFilter.condition(predicate).on_match(label).otherwise(strip_value)
190
+ # condition_filter = Google::Cloud::Bigtable::RowFilter.
191
+ # condition(predicate).on_match(label).otherwise(strip_value)
184
192
  #
185
193
  # filter = Google::Cloud::Bigtable::RowFilter.interleave.condition(condition_filter)
186
194
  #
187
195
  def condition filter
188
- unless filter.instance_of?(ConditionFilter)
189
- raise RowFilterError, "Filter type must be ConditionFilter"
190
- end
191
- add(filter)
196
+ raise RowFilterError, "Filter type must be ConditionFilter" unless filter.instance_of? ConditionFilter
197
+ add filter
192
198
  end
193
199
 
194
- # Adds a pass filter instance.
200
+ ##
201
+ # Adds a pass filter.
195
202
  #
196
203
  # Matches all cells, regardless of input. Functionally equivalent to
197
204
  # leaving `filter` unset, but included for completeness.
@@ -200,14 +207,16 @@ module Google
200
207
  # `self` instance of interleave filter.
201
208
  #
202
209
  # @example
210
+ # require "google/cloud/bigtable"
203
211
  #
204
212
  # filter = Google::Cloud::Bigtable::RowFilter.interleave.pass
205
213
  #
206
214
  def pass
207
- add(RowFilter.pass)
215
+ add RowFilter.pass
208
216
  end
209
217
 
210
- # Adds a block-all filter instance.
218
+ ##
219
+ # Adds a block-all filter.
211
220
  #
212
221
  # Does not match any cells, regardless of input. Useful for temporarily
213
222
  # disabling just part of a filter.
@@ -216,14 +225,16 @@ module Google
216
225
  # `self` instance of interleave filter.
217
226
  #
218
227
  # @example
228
+ # require "google/cloud/bigtable"
219
229
  #
220
230
  # filter = Google::Cloud::Bigtable::RowFilter.interleave.block
221
231
  #
222
232
  def block
223
- add(RowFilter.block)
233
+ add RowFilter.block
224
234
  end
225
235
 
226
- # Adds a sink filter instance.
236
+ ##
237
+ # Adds a sink filter.
227
238
  #
228
239
  # Outputs all cells directly to the output of the read rather than to any parent filter.
229
240
  #
@@ -231,14 +242,16 @@ module Google
231
242
  # `self` instance of interleave filter.
232
243
  #
233
244
  # @example
245
+ # require "google/cloud/bigtable"
234
246
  #
235
247
  # filter = Google::Cloud::Bigtable::RowFilter.interleave.sink
236
248
  #
237
249
  def sink
238
- add(RowFilter.sink)
250
+ add RowFilter.sink
239
251
  end
240
252
 
241
- # Adds a strip-value filter instance.
253
+ ##
254
+ # Adds a strip-value filter.
242
255
  #
243
256
  # Replaces each cell's value with an empty string.
244
257
  #
@@ -246,13 +259,15 @@ module Google
246
259
  # `self` instance of interleave filter.
247
260
  #
248
261
  # @example
262
+ # require "google/cloud/bigtable"
249
263
  #
250
264
  # filter = Google::Cloud::Bigtable::RowFilter.interleave.strip_value
251
265
  #
252
266
  def strip_value
253
- add(RowFilter.strip_value)
267
+ add RowFilter.strip_value
254
268
  end
255
269
 
270
+ ##
256
271
  # Adds a row-key filter instance to match key using a regular expression.
257
272
  #
258
273
  # Matches only cells from rows whose keys satisfy the given RE2 regex. In
@@ -271,31 +286,35 @@ module Google
271
286
  # `self` instance of interleave filter.
272
287
  #
273
288
  # @example
289
+ # require "google/cloud/bigtable"
274
290
  #
275
291
  # filter = Google::Cloud::Bigtable::RowFilter.interleave.key("user-*")
276
292
  #
277
293
  def key regex
278
- add(RowFilter.key(regex))
294
+ add RowFilter.key(regex)
279
295
  end
280
296
 
281
- # Adds a sample-probability filter instance.
297
+ ##
298
+ # Adds a sample-probability filter.
282
299
  #
283
300
  # Matches all cells from a row with probability p, and matches no cells
284
301
  # from the row with probability 1-p.
285
302
  #
286
- # @param probability [Float] Probability value
287
- # Probability must be greather then 0 and less then 1.0
303
+ # @param probability [Float] Probability value.
304
+ # Probability must be greater than 0 and less than 1.0.
288
305
  # @return [Google::Cloud::Bigtable::RowFilter::InterleaveFilter]
289
306
  # `self` instance of interleave filter.
290
307
  #
291
308
  # @example
309
+ # require "google/cloud/bigtable"
292
310
  #
293
311
  # filter = Google::Cloud::Bigtable::RowFilter.interleave.sample(0.5)
294
312
  #
295
313
  def sample probability
296
- add(RowFilter.sample(probability))
314
+ add RowFilter.sample(probability)
297
315
  end
298
316
 
317
+ ##
299
318
  # Adds a family-name-match filter using a regular expression.
300
319
  #
301
320
  # Matches only cells from columns whose families satisfy the given RE2
@@ -313,13 +332,15 @@ module Google
313
332
  # `self` instance of interleave filter.
314
333
  #
315
334
  # @example
335
+ # require "google/cloud/bigtable"
316
336
  #
317
337
  # filter = Google::Cloud::Bigtable::RowFilter.interleave.family("cf-*")
318
338
  #
319
339
  def family regex
320
- add(RowFilter.family(regex))
340
+ add RowFilter.family(regex)
321
341
  end
322
342
 
343
+ ##
323
344
  # Adds a column-qualifier-match filter using a regular expression.
324
345
  #
325
346
  # Matches only cells from columns whose qualifiers satisfy the given RE2
@@ -337,13 +358,15 @@ module Google
337
358
  # `self` instance of interleave filter.
338
359
  #
339
360
  # @example
361
+ # require "google/cloud/bigtable"
340
362
  #
341
363
  # filter = Google::Cloud::Bigtable::RowFilter.interleave.qualifier("user-name*")
342
364
  #
343
365
  def qualifier regex
344
- add(RowFilter.qualifier(regex))
366
+ add RowFilter.qualifier(regex)
345
367
  end
346
368
 
369
+ ##
347
370
  # Adds a value-match filter using a regular expression.
348
371
  #
349
372
  # Matches only cells with values that satisfy the given regular expression.
@@ -360,13 +383,15 @@ module Google
360
383
  # `self` instance of interleave filter.
361
384
  #
362
385
  # @example
386
+ # require "google/cloud/bigtable"
363
387
  #
364
388
  # filter = Google::Cloud::Bigtable::RowFilter.interleave.value("abc*")
365
389
  #
366
390
  def value regex
367
- add(RowFilter.value(regex))
391
+ add RowFilter.value(regex)
368
392
  end
369
393
 
394
+ ##
370
395
  # Adds a label filter instance to apply a label based on the result of read rows.
371
396
  #
372
397
  # Applies the given label to all cells in the output row. This allows
@@ -374,7 +399,7 @@ module Google
374
399
  # the filter.
375
400
  #
376
401
  # Values must be at most 15 characters in length, and match the RE2
377
- # pattern `[a-z0-9\\-]+`
402
+ # pattern `[a-z0-9\\-]+`.
378
403
  #
379
404
  # Due to a technical limitation, it is not possible to apply
380
405
  # multiple labels to a cell. As a result, a Chain may have no more than
@@ -387,13 +412,15 @@ module Google
387
412
  # `self` instance of interleave filter.
388
413
  #
389
414
  # @example
415
+ # require "google/cloud/bigtable"
390
416
  #
391
417
  # filter = Google::Cloud::Bigtable::RowFilter.interleave.label("user-detail")
392
418
  #
393
419
  def label value
394
- add(RowFilter.label(value))
420
+ add RowFilter.label(value)
395
421
  end
396
422
 
423
+ ##
397
424
  # Adds a cell-per-row-offset filter instance to skip the first N cells.
398
425
  #
399
426
  # Skips the first N cells of each row, matching all subsequent cells.
@@ -405,14 +432,16 @@ module Google
405
432
  # `self` instance of interleave filter.
406
433
  #
407
434
  # @example
435
+ # require "google/cloud/bigtable"
408
436
  #
409
437
  # filter = Google::Cloud::Bigtable::RowFilter.interleave.cells_per_row_offset(3)
410
438
  #
411
439
  def cells_per_row_offset offset
412
- add(RowFilter.cells_per_row_offset(offset))
440
+ add RowFilter.cells_per_row_offset(offset)
413
441
  end
414
442
 
415
- # Adds a cells-per-row-limit filter instance.
443
+ ##
444
+ # Adds a cells-per-row-limit filter.
416
445
  #
417
446
  # Matches only the first N cells of each row.
418
447
  # If duplicate cells are present, as is possible when using an interleave,
@@ -423,14 +452,16 @@ module Google
423
452
  # `self` instance of interleave filter.
424
453
  #
425
454
  # @example
455
+ # require "google/cloud/bigtable"
426
456
  #
427
457
  # filter = Google::Cloud::Bigtable::RowFilter.interleave.cells_per_row(5)
428
458
  #
429
459
  def cells_per_row limit
430
- add(RowFilter.cells_per_row(limit))
460
+ add RowFilter.cells_per_row(limit)
431
461
  end
432
462
 
433
- # Adds a cells-per-column filter instance.
463
+ ##
464
+ # Adds a cells-per-column filter.
434
465
  #
435
466
  # Matches only the most recent N cells within each column. For example,
436
467
  # if N=2, this filter would match column `foo:bar` at timestamps 10 and 9,
@@ -444,14 +475,16 @@ module Google
444
475
  # `self` instance of interleave filter.
445
476
  #
446
477
  # @example
478
+ # require "google/cloud/bigtable"
447
479
  #
448
480
  # filter = Google::Cloud::Bigtable::RowFilter.interleave.cells_per_column(5)
449
481
  #
450
482
  def cells_per_column limit
451
- add(RowFilter.cells_per_column(limit))
483
+ add RowFilter.cells_per_column(limit)
452
484
  end
453
485
 
454
- # Adds a timestamp-range filter instance.
486
+ ##
487
+ # Adds a timestamp-range filter.
455
488
  #
456
489
  # Matches only cells with timestamps within the given range.
457
490
  # Specifies a contiguous range of timestamps.
@@ -464,6 +497,7 @@ module Google
464
497
  # `self` instance of interleave filter.
465
498
  #
466
499
  # @example
500
+ # require "google/cloud/bigtable"
467
501
  #
468
502
  # timestamp_micros = (Time.now.to_f * 1000000).round(-3)
469
503
  # from = timestamp_micros - 300000000
@@ -472,10 +506,11 @@ module Google
472
506
  # filter = Google::Cloud::Bigtable::RowFilter.interleave.timestamp_range(from: from, to: to)
473
507
  #
474
508
  def timestamp_range from: nil, to: nil
475
- add(RowFilter.timestamp_range(from: from, to: to))
509
+ add RowFilter.timestamp_range(from: from, to: to)
476
510
  end
477
511
 
478
- # Adds a value-range filter instance.
512
+ ##
513
+ # Adds a value-range filter.
479
514
  #
480
515
  # Matches only cells with values that fall within the given range.
481
516
  #
@@ -483,27 +518,37 @@ module Google
483
518
  # option inclusive/exclusive options.
484
519
  #
485
520
  # * The value at which to start the range. If neither field is set, interpreted as an empty string, inclusive.
486
- # * The value at which to end the range. If neither field is set, interpreted as an infinite string, exclusive.
521
+ # * The value at which to end the range. If neither field is set, interpreted as an infinite string,
522
+ # exclusive.
487
523
  #
488
524
  # @param range [Google::Cloud::Bigtable::ValueRange]
489
525
  # @return [Google::Cloud::Bigtable::RowFilter::InterleaveFilter]
490
526
  # `self` instance of interleave filter.
491
527
  #
492
- # @example Start to end range
528
+ # @example Start to end range.
529
+ # require "google/cloud/bigtable"
493
530
  #
494
- # range = Google::Cloud::Bigtable::ValueRange.from("abc").to('xyz')
531
+ # bigtable = Google::Cloud::Bigtable.new
532
+ # table = bigtable.table("my-instance", "my-table")
533
+ #
534
+ # range = table.new_value_range.from("value-001").to("value-005")
495
535
  # filter = Google::Cloud::Bigtable::RowFilter.interleave.value_range(range)
496
536
  #
497
- # @example Start exlusive to infinite end range
537
+ # @example Start exlusive to infinite end range.
538
+ # require "google/cloud/bigtable"
539
+ #
540
+ # bigtable = Google::Cloud::Bigtable.new
541
+ # table = bigtable.table("my-instance", "my-table")
498
542
  #
499
- # range = Google::Cloud::Bigtable::ValueRange.from("abc", inclusive: false)
543
+ # range = table.new_value_range.from("value-001", inclusive: false)
500
544
  # filter = Google::Cloud::Bigtable::RowFilter.interleave.value_range(range)
501
545
  #
502
546
  def value_range range
503
- add(RowFilter.value_range(range))
547
+ add RowFilter.value_range(range)
504
548
  end
505
549
 
506
- # Adds a column-range filter instance.
550
+ ##
551
+ # Adds a column-range filter.
507
552
  #
508
553
  # Matches only cells from columns within the given range.
509
554
  #
@@ -512,34 +557,38 @@ module Google
512
557
  # `self` instance of interleave filter.
513
558
  #
514
559
  # @example
560
+ # require "google/cloud/bigtable"
515
561
  #
516
- # range = Google::Cloud::Bigtable::ColumnRange.new(cf).from("field0").to('field5')
562
+ # range = Google::Cloud::Bigtable::ColumnRange.new("cf").from("field0").to("field5")
517
563
  #
518
564
  # filter = Google::Cloud::Bigtable::RowFilter.interleave.column_range(range)
519
565
  #
520
566
  def column_range range
521
- add(RowFilter.column_range(range))
567
+ add RowFilter.column_range(range)
522
568
  end
523
569
 
524
- # Gets the number of filters in chain filters.
570
+ ##
571
+ # Returns the number of filters in the interleave.
525
572
  #
526
573
  # @return [Integer]
527
574
  #
528
575
  # @example
576
+ # require "google/cloud/bigtable"
529
577
  #
530
- # filter = Google::Cloud::Bigtable::RowFilter.interleave.key("user-1*").label("user")
531
- # filter.length # 2
578
+ # filter = Google::Cloud::Bigtable::RowFilter.interleave.key("user-1*").label("user")
579
+ # filter.length # 2
532
580
  #
533
581
  def length
534
- @grpc.filters.length
582
+ @filters.length
535
583
  end
536
584
 
537
- # Gets a list of filters.
585
+ ##
586
+ # Returns a frozen copy of the filters array.
538
587
  #
539
- # @return [Array<Google::Bigtable::V2::RowFilter>]
588
+ # @return [Array<SimpleFilter|ChainFilter|InterleaveFilter|ConditionFilter>]
540
589
  #
541
590
  def filters
542
- @grpc.filters
591
+ @filters.dup.freeze
543
592
  end
544
593
 
545
594
  # @private
@@ -549,7 +598,9 @@ module Google
549
598
  # @return [Google::Bigtable::V2::RowFilter]
550
599
  #
551
600
  def to_grpc
552
- Google::Bigtable::V2::RowFilter.new(interleave: @grpc)
601
+ Google::Bigtable::V2::RowFilter.new(
602
+ interleave: Google::Bigtable::V2::RowFilter::Interleave.new(filters: @filters.map(&:to_grpc))
603
+ )
553
604
  end
554
605
 
555
606
  private
@@ -560,7 +611,7 @@ module Google
560
611
  # @param filter [SimpleFilter, ChainFilter, InterleaveFilter, ConditionFilter]
561
612
  #
562
613
  def add filter
563
- @grpc.filters << filter.to_grpc
614
+ @filters << filter
564
615
  self
565
616
  end
566
617
  end