google-cloud-bigtable 0.6.2 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +36 -0
- data/CONTRIBUTING.md +1 -1
- data/lib/google-cloud-bigtable.rb +19 -21
- data/lib/google/cloud/bigtable.rb +11 -17
- data/lib/google/cloud/bigtable/app_profile.rb +148 -82
- data/lib/google/cloud/bigtable/app_profile/job.rb +5 -8
- data/lib/google/cloud/bigtable/app_profile/list.rb +11 -5
- data/lib/google/cloud/bigtable/chunk_processor.rb +23 -35
- data/lib/google/cloud/bigtable/cluster.rb +38 -11
- data/lib/google/cloud/bigtable/cluster/job.rb +3 -7
- data/lib/google/cloud/bigtable/cluster/list.rb +20 -18
- data/lib/google/cloud/bigtable/column_family.rb +22 -229
- data/lib/google/cloud/bigtable/column_family_map.rb +426 -0
- data/lib/google/cloud/bigtable/column_range.rb +9 -1
- data/lib/google/cloud/bigtable/convert.rb +12 -4
- data/lib/google/cloud/bigtable/errors.rb +4 -1
- data/lib/google/cloud/bigtable/gc_rule.rb +184 -65
- data/lib/google/cloud/bigtable/instance.rb +136 -126
- data/lib/google/cloud/bigtable/instance/cluster_map.rb +9 -7
- data/lib/google/cloud/bigtable/instance/job.rb +4 -3
- data/lib/google/cloud/bigtable/instance/list.rb +14 -9
- data/lib/google/cloud/bigtable/longrunning_job.rb +6 -0
- data/lib/google/cloud/bigtable/mutation_entry.rb +19 -23
- data/lib/google/cloud/bigtable/mutation_operations.rb +82 -29
- data/lib/google/cloud/bigtable/policy.rb +9 -5
- data/lib/google/cloud/bigtable/project.rb +62 -140
- data/lib/google/cloud/bigtable/read_modify_write_rule.rb +9 -4
- data/lib/google/cloud/bigtable/read_operations.rb +28 -41
- data/lib/google/cloud/bigtable/routing_policy.rb +171 -0
- data/lib/google/cloud/bigtable/row.rb +18 -7
- data/lib/google/cloud/bigtable/row_filter.rb +49 -20
- data/lib/google/cloud/bigtable/row_filter/chain_filter.rb +71 -43
- data/lib/google/cloud/bigtable/row_filter/condition_filter.rb +4 -1
- data/lib/google/cloud/bigtable/row_filter/interleave_filter.rb +74 -43
- data/lib/google/cloud/bigtable/row_filter/simple_filter.rb +22 -7
- data/lib/google/cloud/bigtable/row_range.rb +5 -0
- data/lib/google/cloud/bigtable/rows_mutator.rb +14 -17
- data/lib/google/cloud/bigtable/rows_reader.rb +18 -14
- data/lib/google/cloud/bigtable/sample_row_key.rb +5 -2
- data/lib/google/cloud/bigtable/service.rb +161 -242
- data/lib/google/cloud/bigtable/status.rb +76 -0
- data/lib/google/cloud/bigtable/table.rb +141 -236
- data/lib/google/cloud/bigtable/table/cluster_state.rb +7 -1
- data/lib/google/cloud/bigtable/table/list.rb +14 -7
- data/lib/google/cloud/bigtable/value_range.rb +5 -0
- data/lib/google/cloud/bigtable/version.rb +1 -1
- metadata +27 -25
- data/lib/google/cloud/bigtable/table/column_family_map.rb +0 -70
@@ -26,6 +26,7 @@ require "google/cloud/bigtable/row_filter/condition_filter"
|
|
26
26
|
module Google
|
27
27
|
module Cloud
|
28
28
|
module Bigtable
|
29
|
+
##
|
29
30
|
# # RowFilter
|
30
31
|
#
|
31
32
|
# Takes a row as input and produces an alternate view of the row based on
|
@@ -145,6 +146,7 @@ module Google
|
|
145
146
|
|
146
147
|
private_constant :PASS, :BLOCK, :SINK, :STRIP_VALUE
|
147
148
|
|
149
|
+
##
|
148
150
|
# Creates a chain filter instance.
|
149
151
|
#
|
150
152
|
# A chain RowFilter that sends rows through several RowFilters in sequence.
|
@@ -166,7 +168,7 @@ module Google
|
|
166
168
|
# chain.strip_value
|
167
169
|
#
|
168
170
|
# # OR
|
169
|
-
# chain.key("user-*).strip_value
|
171
|
+
# chain.key("user-*").strip_value
|
170
172
|
#
|
171
173
|
# @example Create complex chain filter.
|
172
174
|
#
|
@@ -176,12 +178,13 @@ module Google
|
|
176
178
|
# chain_1.label("users").qualifier("name").cells_per_row(5)
|
177
179
|
#
|
178
180
|
# # Add to main chain filter
|
179
|
-
# chain.chain(chain_1).value("xyz*).key("user-*")
|
181
|
+
# chain.chain(chain_1).value("xyz*").key("user-*")
|
180
182
|
#
|
181
183
|
def self.chain
|
182
184
|
ChainFilter.new
|
183
185
|
end
|
184
186
|
|
187
|
+
##
|
185
188
|
# Creates an interleave filter.
|
186
189
|
#
|
187
190
|
# A RowFilter that sends each row to each of several component
|
@@ -224,7 +227,7 @@ module Google
|
|
224
227
|
# interleave.sink
|
225
228
|
#
|
226
229
|
# # OR
|
227
|
-
# interleave.key("user-*).sink
|
230
|
+
# interleave.key("user-*").sink
|
228
231
|
#
|
229
232
|
# @example Create complex interleave filter.
|
230
233
|
#
|
@@ -234,12 +237,13 @@ module Google
|
|
234
237
|
# chain_1.label("users").qualifier("name").cells_per_row(5)
|
235
238
|
#
|
236
239
|
# # Add to main chain filter
|
237
|
-
# interleave.chain(chain_1).value("xyz*).key("user-*")
|
240
|
+
# interleave.chain(chain_1).value("xyz*").key("user-*")
|
238
241
|
#
|
239
242
|
def self.interleave
|
240
243
|
InterleaveFilter.new
|
241
244
|
end
|
242
245
|
|
246
|
+
##
|
243
247
|
# Creates a condition filter instance.
|
244
248
|
#
|
245
249
|
# A RowFilter that evaluates one of two possible RowFilters, depending on
|
@@ -267,9 +271,10 @@ module Google
|
|
267
271
|
# condition.on_match(label).otherwise(strip_value)
|
268
272
|
#
|
269
273
|
def self.condition predicate
|
270
|
-
ConditionFilter.new
|
274
|
+
ConditionFilter.new predicate
|
271
275
|
end
|
272
276
|
|
277
|
+
##
|
273
278
|
# Creates a pass filter instance.
|
274
279
|
#
|
275
280
|
# Matches all cells, regardless of input. Functionally equivalent to
|
@@ -285,6 +290,7 @@ module Google
|
|
285
290
|
PASS
|
286
291
|
end
|
287
292
|
|
293
|
+
##
|
288
294
|
# Creates a block-all filter instance.
|
289
295
|
#
|
290
296
|
# Does not match any cells, regardless of input. Useful for temporarily
|
@@ -300,6 +306,7 @@ module Google
|
|
300
306
|
BLOCK
|
301
307
|
end
|
302
308
|
|
309
|
+
##
|
303
310
|
# Creates a sink filter instance.
|
304
311
|
#
|
305
312
|
# Outputs all cells directly to the output of the read rather than to any
|
@@ -315,6 +322,7 @@ module Google
|
|
315
322
|
SINK
|
316
323
|
end
|
317
324
|
|
325
|
+
##
|
318
326
|
# Creates a strip value filter instance.
|
319
327
|
#
|
320
328
|
# Replaces each cell's value with an empty string.
|
@@ -329,6 +337,7 @@ module Google
|
|
329
337
|
STRIP_VALUE
|
330
338
|
end
|
331
339
|
|
340
|
+
##
|
332
341
|
# Creates a key filter instance to match a row key using a regular expression.
|
333
342
|
#
|
334
343
|
# Matches only cells from rows whose row keys satisfy the given RE2 regex. In
|
@@ -350,9 +359,10 @@ module Google
|
|
350
359
|
# filter = Google::Cloud::Bigtable::RowFilter.key("user-.*")
|
351
360
|
#
|
352
361
|
def self.key regex
|
353
|
-
SimpleFilter.new.key
|
362
|
+
SimpleFilter.new.key regex
|
354
363
|
end
|
355
364
|
|
365
|
+
##
|
356
366
|
# Creates a sample probability filter instance.
|
357
367
|
#
|
358
368
|
# Matches all cells from a row with probability p, and matches no cells
|
@@ -367,9 +377,10 @@ module Google
|
|
367
377
|
# filter = Google::Cloud::Bigtable::RowFilter.sample(0.5)
|
368
378
|
#
|
369
379
|
def self.sample probability
|
370
|
-
SimpleFilter.new.sample
|
380
|
+
SimpleFilter.new.sample probability
|
371
381
|
end
|
372
382
|
|
383
|
+
##
|
373
384
|
# Creates a family name match filter using a regular expression.
|
374
385
|
#
|
375
386
|
# Matches only cells from columns whose families satisfy the given RE2
|
@@ -390,9 +401,10 @@ module Google
|
|
390
401
|
# filter = Google::Cloud::Bigtable::RowFilter.family("cf-.*")
|
391
402
|
#
|
392
403
|
def self.family regex
|
393
|
-
SimpleFilter.new.family
|
404
|
+
SimpleFilter.new.family regex
|
394
405
|
end
|
395
406
|
|
407
|
+
##
|
396
408
|
# Creates a column qualifier match filter using a regular expression.
|
397
409
|
#
|
398
410
|
# Matches only cells from columns whose qualifiers satisfy the given RE2
|
@@ -413,9 +425,10 @@ module Google
|
|
413
425
|
# filter = Google::Cloud::Bigtable::RowFilter.qualifier("user-name.*")
|
414
426
|
#
|
415
427
|
def self.qualifier regex
|
416
|
-
SimpleFilter.new.qualifier
|
428
|
+
SimpleFilter.new.qualifier regex
|
417
429
|
end
|
418
430
|
|
431
|
+
##
|
419
432
|
# Creates a value match filter using a regular expression.
|
420
433
|
#
|
421
434
|
# Matches only cells with values that satisfy the given regular expression.
|
@@ -435,9 +448,10 @@ module Google
|
|
435
448
|
# filter = Google::Cloud::Bigtable::RowFilter.value("abc.*")
|
436
449
|
#
|
437
450
|
def self.value regex
|
438
|
-
SimpleFilter.new.value
|
451
|
+
SimpleFilter.new.value regex
|
439
452
|
end
|
440
453
|
|
454
|
+
##
|
441
455
|
# Creates a label filter instance to apply a label based on the result of
|
442
456
|
# read rows.
|
443
457
|
#
|
@@ -462,9 +476,10 @@ module Google
|
|
462
476
|
# filter = Google::Cloud::Bigtable::RowFilter.label("user-detail")
|
463
477
|
#
|
464
478
|
def self.label value
|
465
|
-
SimpleFilter.new.label
|
479
|
+
SimpleFilter.new.label value
|
466
480
|
end
|
467
481
|
|
482
|
+
##
|
468
483
|
# Creates a cell-per-row-offset filter instance to skip first N cells.
|
469
484
|
#
|
470
485
|
# Skips the first N cells of each row, matching all subsequent cells.
|
@@ -479,9 +494,10 @@ module Google
|
|
479
494
|
# filter = Google::Cloud::Bigtable::RowFilter.cells_per_row_offset(3)
|
480
495
|
#
|
481
496
|
def self.cells_per_row_offset offset
|
482
|
-
SimpleFilter.new.cells_per_row_offset
|
497
|
+
SimpleFilter.new.cells_per_row_offset offset
|
483
498
|
end
|
484
499
|
|
500
|
+
##
|
485
501
|
# Create a cells-per-row limit filter instance.
|
486
502
|
#
|
487
503
|
# Matches only the first N cells of each row.
|
@@ -496,9 +512,10 @@ module Google
|
|
496
512
|
# filter = Google::Cloud::Bigtable::RowFilter.cells_per_row(5)
|
497
513
|
#
|
498
514
|
def self.cells_per_row limit
|
499
|
-
SimpleFilter.new.cells_per_row
|
515
|
+
SimpleFilter.new.cells_per_row limit
|
500
516
|
end
|
501
517
|
|
518
|
+
##
|
502
519
|
# Creates cells-per-column filter instance.
|
503
520
|
#
|
504
521
|
# Matches only the most recent N cells within each column.
|
@@ -513,9 +530,10 @@ module Google
|
|
513
530
|
# filter = Google::Cloud::Bigtable::RowFilter.cells_per_column(5)
|
514
531
|
#
|
515
532
|
def self.cells_per_column limit
|
516
|
-
SimpleFilter.new.cells_per_column
|
533
|
+
SimpleFilter.new.cells_per_column limit
|
517
534
|
end
|
518
535
|
|
536
|
+
##
|
519
537
|
# Creates a timestamp-range filter instance.
|
520
538
|
#
|
521
539
|
# Matches only cells with timestamps within the given range.
|
@@ -540,9 +558,10 @@ module Google
|
|
540
558
|
# filter = Google::Cloud::Bigtable::RowFilter.timestamp_range(to: to)
|
541
559
|
#
|
542
560
|
def self.timestamp_range from: nil, to: nil
|
543
|
-
SimpleFilter.new.timestamp_range
|
561
|
+
SimpleFilter.new.timestamp_range from, to
|
544
562
|
end
|
545
563
|
|
564
|
+
##
|
546
565
|
# Creates a value-range filter instance.
|
547
566
|
#
|
548
567
|
# Matches only cells with values that fall within the given range.
|
@@ -559,19 +578,28 @@ module Google
|
|
559
578
|
# @return [Google::Cloud::Bigtable::RowFilter::SimpleFilter]
|
560
579
|
#
|
561
580
|
# @example Start to end range
|
581
|
+
# require "google/cloud/bigtable"
|
562
582
|
#
|
563
|
-
#
|
583
|
+
# bigtable = Google::Cloud::Bigtable.new
|
584
|
+
# table = bigtable.table("my-instance", "my-table")
|
585
|
+
#
|
586
|
+
# range = table.new_value_range.from("value-001", inclusive: false)
|
564
587
|
# filter = Google::Cloud::Bigtable::RowFilter.value_range(range)
|
565
588
|
#
|
566
589
|
# @example Start exlusive to infinite end range
|
590
|
+
# require "google/cloud/bigtable"
|
591
|
+
#
|
592
|
+
# bigtable = Google::Cloud::Bigtable.new
|
593
|
+
# table = bigtable.table("my-instance", "my-table")
|
567
594
|
#
|
568
|
-
# range =
|
595
|
+
# range = table.new_value_range.from("value-001", inclusive: false)
|
569
596
|
# filter = Google::Cloud::Bigtable::RowFilter.value_range(range)
|
570
597
|
#
|
571
598
|
def self.value_range range
|
572
|
-
SimpleFilter.new.value_range
|
599
|
+
SimpleFilter.new.value_range range
|
573
600
|
end
|
574
601
|
|
602
|
+
##
|
575
603
|
# Creates a column-range filter instance.
|
576
604
|
#
|
577
605
|
# Matches only cells from columns within the given range.
|
@@ -580,13 +608,14 @@ module Google
|
|
580
608
|
# @return [Google::Cloud::Bigtable::RowFilter::SimpleFilter]
|
581
609
|
#
|
582
610
|
# @example
|
611
|
+
# require "google/cloud/bigtable"
|
583
612
|
#
|
584
|
-
# range = Google::Cloud::Bigtable::ColumnRange.new(cf).from("field0").to("field5")
|
613
|
+
# range = Google::Cloud::Bigtable::ColumnRange.new("cf").from("field0").to("field5")
|
585
614
|
#
|
586
615
|
# filter = Google::Cloud::Bigtable::RowFilter.column_range(range)
|
587
616
|
#
|
588
617
|
def self.column_range range
|
589
|
-
SimpleFilter.new.column_range
|
618
|
+
SimpleFilter.new.column_range range
|
590
619
|
end
|
591
620
|
end
|
592
621
|
end
|
@@ -19,6 +19,7 @@ module Google
|
|
19
19
|
module Cloud
|
20
20
|
module Bigtable
|
21
21
|
module RowFilter
|
22
|
+
##
|
22
23
|
# # ChainFilter
|
23
24
|
#
|
24
25
|
# A RowFilter that sends rows through several RowFilters in sequence.
|
@@ -37,9 +38,10 @@ module Google
|
|
37
38
|
# @private
|
38
39
|
# Creates an instance of a chain filter.
|
39
40
|
def initialize
|
40
|
-
@
|
41
|
+
@filters = []
|
41
42
|
end
|
42
43
|
|
44
|
+
##
|
43
45
|
# Adds a chain filter instance.
|
44
46
|
#
|
45
47
|
# A Chain RowFilter that sends rows through several RowFilters in sequence.
|
@@ -66,12 +68,11 @@ module Google
|
|
66
68
|
# filter = Google::Cloud::Bigtable::RowFilter.chain.chain(chain_1)
|
67
69
|
#
|
68
70
|
def chain filter
|
69
|
-
unless filter.instance_of?
|
70
|
-
|
71
|
-
end
|
72
|
-
add(filter)
|
71
|
+
raise RowFilterError, "Filter type must be ChainFilter" unless filter.instance_of? ChainFilter
|
72
|
+
add filter
|
73
73
|
end
|
74
74
|
|
75
|
+
##
|
75
76
|
# Add interleave filter.
|
76
77
|
#
|
77
78
|
# A RowFilter that sends each row to each of several component
|
@@ -119,12 +120,11 @@ module Google
|
|
119
120
|
# chain = Google::Cloud::Bigtable::RowFilter.chain.interleave(interleave)
|
120
121
|
#
|
121
122
|
def interleave filter
|
122
|
-
unless filter.instance_of?
|
123
|
-
|
124
|
-
end
|
125
|
-
add(filter)
|
123
|
+
raise RowFilterError, "Filter type must be InterleaveFilter" unless filter.instance_of? InterleaveFilter
|
124
|
+
add filter
|
126
125
|
end
|
127
126
|
|
127
|
+
##
|
128
128
|
# Adds a condition filter instance.
|
129
129
|
#
|
130
130
|
# A RowFilter that evaluates one of two possible RowFilters, depending on
|
@@ -148,17 +148,17 @@ module Google
|
|
148
148
|
# label = Google::Cloud::Bigtable::RowFilter.label("user")
|
149
149
|
# strip_value = Google::Cloud::Bigtable::RowFilter.strip_value
|
150
150
|
#
|
151
|
-
# condition_filter = Google::Cloud::Bigtable::RowFilter.
|
151
|
+
# condition_filter = Google::Cloud::Bigtable::RowFilter.
|
152
|
+
# condition(predicate).on_match(label).otherwise(strip_value)
|
152
153
|
#
|
153
154
|
# filter = Google::Cloud::Bigtable::RowFilter.chain.condition(condition_filter)
|
154
155
|
#
|
155
156
|
def condition filter
|
156
|
-
unless filter.instance_of?
|
157
|
-
|
158
|
-
end
|
159
|
-
add(filter)
|
157
|
+
raise RowFilterError, "Filter type must be ConditionFilter" unless filter.instance_of? ConditionFilter
|
158
|
+
add filter
|
160
159
|
end
|
161
160
|
|
161
|
+
##
|
162
162
|
# Adds a pass filter instance.
|
163
163
|
#
|
164
164
|
# Matches all cells, regardless of input. Functionally equivalent to
|
@@ -172,9 +172,10 @@ module Google
|
|
172
172
|
# filter = Google::Cloud::Bigtable::RowFilter.chain.pass
|
173
173
|
#
|
174
174
|
def pass
|
175
|
-
add
|
175
|
+
add RowFilter.pass
|
176
176
|
end
|
177
177
|
|
178
|
+
##
|
178
179
|
# Adds a block-all filter instance.
|
179
180
|
#
|
180
181
|
# Does not match any cells, regardless of input. Useful for temporarily
|
@@ -188,9 +189,10 @@ module Google
|
|
188
189
|
# filter = Google::Cloud::Bigtable::RowFilter.chain.block
|
189
190
|
#
|
190
191
|
def block
|
191
|
-
add
|
192
|
+
add RowFilter.block
|
192
193
|
end
|
193
194
|
|
195
|
+
##
|
194
196
|
# Adds a sink filter instance.
|
195
197
|
#
|
196
198
|
# Outputs all cells directly to the output of the read rather than to any parent filter.
|
@@ -203,9 +205,10 @@ module Google
|
|
203
205
|
# filter = Google::Cloud::Bigtable::RowFilter.chain.sink
|
204
206
|
#
|
205
207
|
def sink
|
206
|
-
add
|
208
|
+
add RowFilter.sink
|
207
209
|
end
|
208
210
|
|
211
|
+
##
|
209
212
|
# Adds a strip-value filter instance.
|
210
213
|
#
|
211
214
|
# Replaces each cell's value with an empty string.
|
@@ -218,9 +221,10 @@ module Google
|
|
218
221
|
# filter = Google::Cloud::Bigtable::RowFilter.chain.strip_value
|
219
222
|
#
|
220
223
|
def strip_value
|
221
|
-
add
|
224
|
+
add RowFilter.strip_value
|
222
225
|
end
|
223
226
|
|
227
|
+
##
|
224
228
|
# Adds a key-filter instance to match keys using a regular expression.
|
225
229
|
#
|
226
230
|
# Matches only cells from rows whose keys satisfy the given RE2 regex. In
|
@@ -243,9 +247,10 @@ module Google
|
|
243
247
|
# filter = Google::Cloud::Bigtable::RowFilter.chain.key("user-*")
|
244
248
|
#
|
245
249
|
def key regex
|
246
|
-
add
|
250
|
+
add RowFilter.key(regex)
|
247
251
|
end
|
248
252
|
|
253
|
+
##
|
249
254
|
# Adds a sample-probability filter instance.
|
250
255
|
#
|
251
256
|
# Matches all cells from a row with probability p, and matches no cells
|
@@ -261,9 +266,10 @@ module Google
|
|
261
266
|
# filter = Google::Cloud::Bigtable::RowFilter.chain.sample(0.5)
|
262
267
|
#
|
263
268
|
def sample probability
|
264
|
-
add
|
269
|
+
add RowFilter.sample(probability)
|
265
270
|
end
|
266
271
|
|
272
|
+
##
|
267
273
|
# Adds a family-name-match filter using a regular expression.
|
268
274
|
#
|
269
275
|
# Matches only cells from columns whose families satisfy the given RE2
|
@@ -285,9 +291,10 @@ module Google
|
|
285
291
|
# filter = Google::Cloud::Bigtable::RowFilter.chain.family("cf-*")
|
286
292
|
#
|
287
293
|
def family regex
|
288
|
-
add
|
294
|
+
add RowFilter.family(regex)
|
289
295
|
end
|
290
296
|
|
297
|
+
##
|
291
298
|
# Add a column-qualifier-match filter using a regular expression.
|
292
299
|
#
|
293
300
|
# Matches only cells from columns whose qualifiers satisfy the given RE2
|
@@ -309,9 +316,10 @@ module Google
|
|
309
316
|
# filter = Google::Cloud::Bigtable::RowFilter.chain.qualifier("user-name*")
|
310
317
|
#
|
311
318
|
def qualifier regex
|
312
|
-
add
|
319
|
+
add RowFilter.qualifier(regex)
|
313
320
|
end
|
314
321
|
|
322
|
+
##
|
315
323
|
# Adds a value-match filter using a regular expression.
|
316
324
|
#
|
317
325
|
# Matches only cells with values that satisfy the given regular expression.
|
@@ -332,9 +340,10 @@ module Google
|
|
332
340
|
# filter = Google::Cloud::Bigtable::RowFilter.chain.value("abc*")
|
333
341
|
#
|
334
342
|
def value regex
|
335
|
-
add
|
343
|
+
add RowFilter.value(regex)
|
336
344
|
end
|
337
345
|
|
346
|
+
##
|
338
347
|
# Adds a label filter instance to apply a label based on the result of read rows.
|
339
348
|
#
|
340
349
|
# Applies the given label to all cells in the output row. This allows
|
@@ -359,9 +368,10 @@ module Google
|
|
359
368
|
# filter = Google::Cloud::Bigtable::RowFilter.chain.label("user-detail")
|
360
369
|
#
|
361
370
|
def label value
|
362
|
-
add
|
371
|
+
add RowFilter.label(value)
|
363
372
|
end
|
364
373
|
|
374
|
+
##
|
365
375
|
# Adds a cell-per-row-offset filter instance to skip the first N cells.
|
366
376
|
#
|
367
377
|
# Skips the first N cells of each row, matching all subsequent cells.
|
@@ -377,9 +387,10 @@ module Google
|
|
377
387
|
# filter = Google::Cloud::Bigtable::RowFilter.chain.cells_per_row_offset(3)
|
378
388
|
#
|
379
389
|
def cells_per_row_offset offset
|
380
|
-
add
|
390
|
+
add RowFilter.cells_per_row_offset(offset)
|
381
391
|
end
|
382
392
|
|
393
|
+
##
|
383
394
|
# Adds a cells-per-row-limit filter instance.
|
384
395
|
#
|
385
396
|
# Matches only the first N cells of each row.
|
@@ -395,9 +406,10 @@ module Google
|
|
395
406
|
# filter = Google::Cloud::Bigtable::RowFilter.chain.cells_per_row(5)
|
396
407
|
#
|
397
408
|
def cells_per_row limit
|
398
|
-
add
|
409
|
+
add RowFilter.cells_per_row(limit)
|
399
410
|
end
|
400
411
|
|
412
|
+
##
|
401
413
|
# Adds a cells-per-column filter instance.
|
402
414
|
#
|
403
415
|
# Matches only the most recent N cells within each column. For example,
|
@@ -416,9 +428,10 @@ module Google
|
|
416
428
|
# filter = Google::Cloud::Bigtable::RowFilter.chain.cells_per_column(5)
|
417
429
|
#
|
418
430
|
def cells_per_column limit
|
419
|
-
add
|
431
|
+
add RowFilter.cells_per_column(limit)
|
420
432
|
end
|
421
433
|
|
434
|
+
##
|
422
435
|
# Adds a timestamp-range filter instance.
|
423
436
|
#
|
424
437
|
# Matches only cells with timestamps within the given range.
|
@@ -440,9 +453,10 @@ module Google
|
|
440
453
|
# filter = Google::Cloud::Bigtable::RowFilter.chain.timestamp_range(from: from, to: to)
|
441
454
|
#
|
442
455
|
def timestamp_range from: nil, to: nil
|
443
|
-
add
|
456
|
+
add RowFilter.timestamp_range(from: from, to: to)
|
444
457
|
end
|
445
458
|
|
459
|
+
##
|
446
460
|
# Adds a value-range filter instance.
|
447
461
|
#
|
448
462
|
# Matches only cells with values that fall within the given range.
|
@@ -451,26 +465,36 @@ module Google
|
|
451
465
|
# option inclusive/exclusive options
|
452
466
|
#
|
453
467
|
# * The value at which to start the range. If neither field is set, interpreted as an empty string, inclusive.
|
454
|
-
# * The value at which to end the range. If neither field is set, interpreted as the infinite string,
|
468
|
+
# * The value at which to end the range. If neither field is set, interpreted as the infinite string,
|
469
|
+
# exclusive.
|
455
470
|
#
|
456
471
|
# @param range [Google::Cloud::Bigtable::ValueRange]
|
457
472
|
# @return [Google::Cloud::Bigtable::RowFilter::ChainFilter]
|
458
473
|
# `self` instance of chain filter.
|
459
474
|
#
|
460
475
|
# @example Start to end range
|
476
|
+
# require "google/cloud/bigtable"
|
461
477
|
#
|
462
|
-
#
|
478
|
+
# bigtable = Google::Cloud::Bigtable.new
|
479
|
+
# table = bigtable.table("my-instance", "my-table")
|
480
|
+
#
|
481
|
+
# range = table.new_value_range.from("value-001").to("value-005")
|
463
482
|
# filter = Google::Cloud::Bigtable::RowFilter.chain.value_range(range)
|
464
483
|
#
|
465
|
-
# @example Start
|
484
|
+
# @example Start exclusive to infinite end range
|
485
|
+
# require "google/cloud/bigtable"
|
486
|
+
#
|
487
|
+
# bigtable = Google::Cloud::Bigtable.new
|
488
|
+
# table = bigtable.table("my-instance", "my-table")
|
466
489
|
#
|
467
|
-
# range =
|
490
|
+
# range = table.new_value_range.from("value-001", inclusive: false)
|
468
491
|
# filter = Google::Cloud::Bigtable::RowFilter.chain.value_range(range)
|
469
492
|
#
|
470
493
|
def value_range range
|
471
|
-
add
|
494
|
+
add RowFilter.value_range(range)
|
472
495
|
end
|
473
496
|
|
497
|
+
##
|
474
498
|
# Adds a column-range filter instance.
|
475
499
|
#
|
476
500
|
# Matches only cells from columns within the given range.
|
@@ -480,16 +504,18 @@ module Google
|
|
480
504
|
# `self` instance of chain filter.
|
481
505
|
#
|
482
506
|
# @example
|
507
|
+
# require "google/cloud/bigtable"
|
483
508
|
#
|
484
|
-
# range = Google::Cloud::Bigtable::ColumnRange.new(cf).from("field0").to('field5')
|
509
|
+
# range = Google::Cloud::Bigtable::ColumnRange.new("cf").from("field0").to('field5')
|
485
510
|
#
|
486
511
|
# filter = Google::Cloud::Bigtable::RowFilter.chain.column_range(range)
|
487
512
|
#
|
488
513
|
def column_range range
|
489
|
-
add
|
514
|
+
add RowFilter.column_range(range)
|
490
515
|
end
|
491
516
|
|
492
|
-
|
517
|
+
##
|
518
|
+
# Gets the number of filters in the chain.
|
493
519
|
#
|
494
520
|
# @return [Integer]
|
495
521
|
#
|
@@ -499,15 +525,16 @@ module Google
|
|
499
525
|
# filter.length # 2
|
500
526
|
#
|
501
527
|
def length
|
502
|
-
@
|
528
|
+
@filters.length
|
503
529
|
end
|
504
530
|
|
505
|
-
|
531
|
+
##
|
532
|
+
# Returns a frozen copy of the filters array.
|
506
533
|
#
|
507
|
-
# @return [Array<
|
534
|
+
# @return [Array<SimpleFilter|ChainFilter|InterleaveFilter|ConditionFilter>]
|
508
535
|
#
|
509
536
|
def filters
|
510
|
-
@
|
537
|
+
@filters.dup.freeze
|
511
538
|
end
|
512
539
|
|
513
540
|
# @private
|
@@ -517,10 +544,11 @@ module Google
|
|
517
544
|
# @return [Google::Bigtable::V2::RowFilter]
|
518
545
|
#
|
519
546
|
def to_grpc
|
520
|
-
Google::Bigtable::V2::RowFilter.new(
|
547
|
+
Google::Bigtable::V2::RowFilter.new(
|
548
|
+
chain: Google::Bigtable::V2::RowFilter::Chain.new(filters: @filters.map(&:to_grpc))
|
549
|
+
)
|
521
550
|
end
|
522
551
|
|
523
|
-
|
524
552
|
private
|
525
553
|
|
526
554
|
# @private
|
@@ -529,7 +557,7 @@ module Google
|
|
529
557
|
# @param filter [SimpleFilter, ChainFilter, InterleaveFilter, ConditionFilter]
|
530
558
|
#
|
531
559
|
def add filter
|
532
|
-
@
|
560
|
+
@filters << filter
|
533
561
|
self
|
534
562
|
end
|
535
563
|
end
|