google-cloud-bigtable 2.6.0 → 2.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/AUTHENTICATION.md +10 -27
- data/CHANGELOG.md +72 -0
- data/CONTRIBUTING.md +328 -115
- data/EMULATOR.md +1 -1
- data/LOGGING.md +1 -1
- data/OVERVIEW.md +1 -1
- data/lib/google/cloud/bigtable/app_profile/job.rb +4 -4
- data/lib/google/cloud/bigtable/app_profile/list.rb +5 -7
- data/lib/google/cloud/bigtable/app_profile.rb +20 -21
- data/lib/google/cloud/bigtable/backup/job.rb +8 -8
- data/lib/google/cloud/bigtable/backup/list.rb +9 -11
- data/lib/google/cloud/bigtable/backup.rb +103 -36
- data/lib/google/cloud/bigtable/chunk_processor.rb +5 -5
- data/lib/google/cloud/bigtable/cluster/job.rb +2 -2
- data/lib/google/cloud/bigtable/cluster.rb +15 -15
- data/lib/google/cloud/bigtable/column_family.rb +2 -2
- data/lib/google/cloud/bigtable/column_family_map.rb +18 -21
- data/lib/google/cloud/bigtable/column_range.rb +7 -7
- data/lib/google/cloud/bigtable/convert.rb +34 -0
- data/lib/google/cloud/bigtable/encryption_info.rb +4 -4
- data/lib/google/cloud/bigtable/gc_rule.rb +20 -20
- data/lib/google/cloud/bigtable/instance/cluster_map.rb +7 -7
- data/lib/google/cloud/bigtable/instance/job.rb +4 -4
- data/lib/google/cloud/bigtable/instance.rb +49 -52
- data/lib/google/cloud/bigtable/mutation_entry.rb +21 -21
- data/lib/google/cloud/bigtable/mutation_operations.rb +34 -34
- data/lib/google/cloud/bigtable/policy.rb +4 -4
- data/lib/google/cloud/bigtable/project.rb +84 -26
- data/lib/google/cloud/bigtable/read_operations.rb +40 -33
- data/lib/google/cloud/bigtable/routing_policy.rb +6 -6
- data/lib/google/cloud/bigtable/row_filter/chain_filter.rb +30 -29
- data/lib/google/cloud/bigtable/row_filter/condition_filter.rb +6 -6
- data/lib/google/cloud/bigtable/row_filter/interleave_filter.rb +27 -26
- data/lib/google/cloud/bigtable/row_filter.rb +28 -28
- data/lib/google/cloud/bigtable/row_range.rb +18 -18
- data/lib/google/cloud/bigtable/rows_reader.rb +77 -32
- data/lib/google/cloud/bigtable/sample_row_key.rb +1 -1
- data/lib/google/cloud/bigtable/service.rb +69 -29
- data/lib/google/cloud/bigtable/status.rb +2 -2
- data/lib/google/cloud/bigtable/table/cluster_state.rb +1 -1
- data/lib/google/cloud/bigtable/table/list.rb +2 -2
- data/lib/google/cloud/bigtable/table/restore_job.rb +12 -12
- data/lib/google/cloud/bigtable/table.rb +42 -40
- data/lib/google/cloud/bigtable/value_range.rb +18 -18
- data/lib/google/cloud/bigtable/version.rb +1 -1
- data/lib/google/cloud/bigtable.rb +28 -7
- data/lib/google-cloud-bigtable.rb +6 -2
- metadata +15 -113
|
@@ -57,7 +57,7 @@ module Google
|
|
|
57
57
|
# interleave = Google::Cloud::Bigtable::RowFilter.interleave
|
|
58
58
|
#
|
|
59
59
|
# # Add filters to interleave filter
|
|
60
|
-
# interleave.key
|
|
60
|
+
# interleave.key "user-*"
|
|
61
61
|
# interleave.sink
|
|
62
62
|
#
|
|
63
63
|
# # OR
|
|
@@ -104,7 +104,7 @@ module Google
|
|
|
104
104
|
# # Add filters to chain filter
|
|
105
105
|
# chain.key("user-*").cells_per_row(5)
|
|
106
106
|
#
|
|
107
|
-
# filter = Google::Cloud::Bigtable::RowFilter.interleave.chain
|
|
107
|
+
# filter = Google::Cloud::Bigtable::RowFilter.interleave.chain chain
|
|
108
108
|
#
|
|
109
109
|
def chain filter
|
|
110
110
|
raise RowFilterError, "Filter type must be ChainFilter" unless filter.instance_of? ChainFilter
|
|
@@ -155,7 +155,7 @@ module Google
|
|
|
155
155
|
# # Add filters to an interleave filter.
|
|
156
156
|
# interleave.key("user-*").cells_per_column(3)
|
|
157
157
|
#
|
|
158
|
-
# filter = Google::Cloud::Bigtable::RowFilter.interleave.interleave
|
|
158
|
+
# filter = Google::Cloud::Bigtable::RowFilter.interleave.interleave interleave
|
|
159
159
|
#
|
|
160
160
|
def interleave filter
|
|
161
161
|
raise RowFilterError, "Filter type must be InterleaveFilter" unless filter.instance_of? InterleaveFilter
|
|
@@ -182,15 +182,16 @@ module Google
|
|
|
182
182
|
# @example
|
|
183
183
|
# require "google/cloud/bigtable"
|
|
184
184
|
#
|
|
185
|
-
# predicate = Google::Cloud::Bigtable::RowFilter.key
|
|
185
|
+
# predicate = Google::Cloud::Bigtable::RowFilter.key "user-*"
|
|
186
186
|
#
|
|
187
|
-
# label = Google::Cloud::Bigtable::RowFilter.label
|
|
187
|
+
# label = Google::Cloud::Bigtable::RowFilter.label "user"
|
|
188
188
|
# strip_value = Google::Cloud::Bigtable::RowFilter.strip_value
|
|
189
189
|
#
|
|
190
|
-
# condition_filter = Google::Cloud::Bigtable::RowFilter.
|
|
191
|
-
#
|
|
190
|
+
# condition_filter = Google::Cloud::Bigtable::RowFilter.condition(predicate)
|
|
191
|
+
# .on_match(label)
|
|
192
|
+
# .otherwise(strip_value)
|
|
192
193
|
#
|
|
193
|
-
# filter = Google::Cloud::Bigtable::RowFilter.interleave.condition
|
|
194
|
+
# filter = Google::Cloud::Bigtable::RowFilter.interleave.condition condition_filter
|
|
194
195
|
#
|
|
195
196
|
def condition filter
|
|
196
197
|
raise RowFilterError, "Filter type must be ConditionFilter" unless filter.instance_of? ConditionFilter
|
|
@@ -288,7 +289,7 @@ module Google
|
|
|
288
289
|
# @example
|
|
289
290
|
# require "google/cloud/bigtable"
|
|
290
291
|
#
|
|
291
|
-
# filter = Google::Cloud::Bigtable::RowFilter.interleave.key
|
|
292
|
+
# filter = Google::Cloud::Bigtable::RowFilter.interleave.key "user-*"
|
|
292
293
|
#
|
|
293
294
|
def key regex
|
|
294
295
|
add RowFilter.key(regex)
|
|
@@ -308,7 +309,7 @@ module Google
|
|
|
308
309
|
# @example
|
|
309
310
|
# require "google/cloud/bigtable"
|
|
310
311
|
#
|
|
311
|
-
# filter = Google::Cloud::Bigtable::RowFilter.interleave.sample
|
|
312
|
+
# filter = Google::Cloud::Bigtable::RowFilter.interleave.sample 0.5
|
|
312
313
|
#
|
|
313
314
|
def sample probability
|
|
314
315
|
add RowFilter.sample(probability)
|
|
@@ -334,7 +335,7 @@ module Google
|
|
|
334
335
|
# @example
|
|
335
336
|
# require "google/cloud/bigtable"
|
|
336
337
|
#
|
|
337
|
-
# filter = Google::Cloud::Bigtable::RowFilter.interleave.family
|
|
338
|
+
# filter = Google::Cloud::Bigtable::RowFilter.interleave.family "cf-*"
|
|
338
339
|
#
|
|
339
340
|
def family regex
|
|
340
341
|
add RowFilter.family(regex)
|
|
@@ -360,7 +361,7 @@ module Google
|
|
|
360
361
|
# @example
|
|
361
362
|
# require "google/cloud/bigtable"
|
|
362
363
|
#
|
|
363
|
-
# filter = Google::Cloud::Bigtable::RowFilter.interleave.qualifier
|
|
364
|
+
# filter = Google::Cloud::Bigtable::RowFilter.interleave.qualifier "user-name*"
|
|
364
365
|
#
|
|
365
366
|
def qualifier regex
|
|
366
367
|
add RowFilter.qualifier(regex)
|
|
@@ -385,7 +386,7 @@ module Google
|
|
|
385
386
|
# @example
|
|
386
387
|
# require "google/cloud/bigtable"
|
|
387
388
|
#
|
|
388
|
-
# filter = Google::Cloud::Bigtable::RowFilter.interleave.value
|
|
389
|
+
# filter = Google::Cloud::Bigtable::RowFilter.interleave.value "abc*"
|
|
389
390
|
#
|
|
390
391
|
def value regex
|
|
391
392
|
add RowFilter.value(regex)
|
|
@@ -414,7 +415,7 @@ module Google
|
|
|
414
415
|
# @example
|
|
415
416
|
# require "google/cloud/bigtable"
|
|
416
417
|
#
|
|
417
|
-
# filter = Google::Cloud::Bigtable::RowFilter.interleave.label
|
|
418
|
+
# filter = Google::Cloud::Bigtable::RowFilter.interleave.label "user-detail"
|
|
418
419
|
#
|
|
419
420
|
def label value
|
|
420
421
|
add RowFilter.label(value)
|
|
@@ -434,7 +435,7 @@ module Google
|
|
|
434
435
|
# @example
|
|
435
436
|
# require "google/cloud/bigtable"
|
|
436
437
|
#
|
|
437
|
-
# filter = Google::Cloud::Bigtable::RowFilter.interleave.cells_per_row_offset
|
|
438
|
+
# filter = Google::Cloud::Bigtable::RowFilter.interleave.cells_per_row_offset 3
|
|
438
439
|
#
|
|
439
440
|
def cells_per_row_offset offset
|
|
440
441
|
add RowFilter.cells_per_row_offset(offset)
|
|
@@ -454,7 +455,7 @@ module Google
|
|
|
454
455
|
# @example
|
|
455
456
|
# require "google/cloud/bigtable"
|
|
456
457
|
#
|
|
457
|
-
# filter = Google::Cloud::Bigtable::RowFilter.interleave.cells_per_row
|
|
458
|
+
# filter = Google::Cloud::Bigtable::RowFilter.interleave.cells_per_row 5
|
|
458
459
|
#
|
|
459
460
|
def cells_per_row limit
|
|
460
461
|
add RowFilter.cells_per_row(limit)
|
|
@@ -477,7 +478,7 @@ module Google
|
|
|
477
478
|
# @example
|
|
478
479
|
# require "google/cloud/bigtable"
|
|
479
480
|
#
|
|
480
|
-
# filter = Google::Cloud::Bigtable::RowFilter.interleave.cells_per_column
|
|
481
|
+
# filter = Google::Cloud::Bigtable::RowFilter.interleave.cells_per_column 5
|
|
481
482
|
#
|
|
482
483
|
def cells_per_column limit
|
|
483
484
|
add RowFilter.cells_per_column(limit)
|
|
@@ -499,11 +500,11 @@ module Google
|
|
|
499
500
|
# @example
|
|
500
501
|
# require "google/cloud/bigtable"
|
|
501
502
|
#
|
|
502
|
-
# timestamp_micros = (Time.now.to_f *
|
|
503
|
-
# from = timestamp_micros -
|
|
503
|
+
# timestamp_micros = (Time.now.to_f * 1_000_000).round(-3)
|
|
504
|
+
# from = timestamp_micros - 300_000_000
|
|
504
505
|
# to = timestamp_micros
|
|
505
506
|
#
|
|
506
|
-
# filter = Google::Cloud::Bigtable::RowFilter.interleave.timestamp_range
|
|
507
|
+
# filter = Google::Cloud::Bigtable::RowFilter.interleave.timestamp_range from: from, to: to
|
|
507
508
|
#
|
|
508
509
|
def timestamp_range from: nil, to: nil
|
|
509
510
|
add RowFilter.timestamp_range(from: from, to: to)
|
|
@@ -529,19 +530,19 @@ module Google
|
|
|
529
530
|
# require "google/cloud/bigtable"
|
|
530
531
|
#
|
|
531
532
|
# bigtable = Google::Cloud::Bigtable.new
|
|
532
|
-
# table = bigtable.table
|
|
533
|
+
# table = bigtable.table "my-instance", "my-table"
|
|
533
534
|
#
|
|
534
535
|
# range = table.new_value_range.from("value-001").to("value-005")
|
|
535
|
-
# filter = Google::Cloud::Bigtable::RowFilter.interleave.value_range
|
|
536
|
+
# filter = Google::Cloud::Bigtable::RowFilter.interleave.value_range range
|
|
536
537
|
#
|
|
537
538
|
# @example Start exlusive to infinite end range.
|
|
538
539
|
# require "google/cloud/bigtable"
|
|
539
540
|
#
|
|
540
541
|
# bigtable = Google::Cloud::Bigtable.new
|
|
541
|
-
# table = bigtable.table
|
|
542
|
+
# table = bigtable.table "my-instance", "my-table"
|
|
542
543
|
#
|
|
543
|
-
# range = table.new_value_range.from
|
|
544
|
-
# filter = Google::Cloud::Bigtable::RowFilter.interleave.value_range
|
|
544
|
+
# range = table.new_value_range.from "value-001", inclusive: false
|
|
545
|
+
# filter = Google::Cloud::Bigtable::RowFilter.interleave.value_range range
|
|
545
546
|
#
|
|
546
547
|
def value_range range
|
|
547
548
|
add RowFilter.value_range(range)
|
|
@@ -561,7 +562,7 @@ module Google
|
|
|
561
562
|
#
|
|
562
563
|
# range = Google::Cloud::Bigtable::ColumnRange.new("cf").from("field0").to("field5")
|
|
563
564
|
#
|
|
564
|
-
# filter = Google::Cloud::Bigtable::RowFilter.interleave.column_range
|
|
565
|
+
# filter = Google::Cloud::Bigtable::RowFilter.interleave.column_range range
|
|
565
566
|
#
|
|
566
567
|
def column_range range
|
|
567
568
|
add RowFilter.column_range(range)
|
|
@@ -127,10 +127,10 @@ module Google
|
|
|
127
127
|
# Google::Cloud::Bigtable::RowFilter.pass
|
|
128
128
|
#
|
|
129
129
|
# # Key regex filter
|
|
130
|
-
# Google::Cloud::Bigtable::RowFilter.key
|
|
130
|
+
# Google::Cloud::Bigtable::RowFilter.key "user-*"
|
|
131
131
|
#
|
|
132
132
|
# # Cell limit filter
|
|
133
|
-
# Google::Cloud::Bigtable::RowFilter.cells_per_row
|
|
133
|
+
# Google::Cloud::Bigtable::RowFilter.cells_per_row 10
|
|
134
134
|
#
|
|
135
135
|
module RowFilter
|
|
136
136
|
# @private
|
|
@@ -166,7 +166,7 @@ module Google
|
|
|
166
166
|
# chain = Google::Cloud::Bigtable::RowFilter.chain
|
|
167
167
|
#
|
|
168
168
|
# # Add filters to chain filter
|
|
169
|
-
# chain.key
|
|
169
|
+
# chain.key "user-*"
|
|
170
170
|
# chain.strip_value
|
|
171
171
|
#
|
|
172
172
|
# # OR
|
|
@@ -227,7 +227,7 @@ module Google
|
|
|
227
227
|
# interleave = Google::Cloud::Bigtable::RowFilter.interleave
|
|
228
228
|
#
|
|
229
229
|
# # Add filters to interleave filter
|
|
230
|
-
# interleave.key
|
|
230
|
+
# interleave.key "user-*"
|
|
231
231
|
# interleave.sink
|
|
232
232
|
#
|
|
233
233
|
# # OR
|
|
@@ -267,10 +267,10 @@ module Google
|
|
|
267
267
|
# @example
|
|
268
268
|
# require "google/cloud/bigtable"
|
|
269
269
|
#
|
|
270
|
-
# predicate = Google::Cloud::Bigtable::RowFilter.key
|
|
271
|
-
# condition = Google::Cloud::Bigtable::RowFilter.condition
|
|
270
|
+
# predicate = Google::Cloud::Bigtable::RowFilter.key "user-*"
|
|
271
|
+
# condition = Google::Cloud::Bigtable::RowFilter.condition predicate
|
|
272
272
|
#
|
|
273
|
-
# label = Google::Cloud::Bigtable::RowFilter.label
|
|
273
|
+
# label = Google::Cloud::Bigtable::RowFilter.label "user"
|
|
274
274
|
# strip_value = Google::Cloud::Bigtable::RowFilter.strip_value
|
|
275
275
|
#
|
|
276
276
|
# # On match apply label, else strip cell values
|
|
@@ -366,7 +366,7 @@ module Google
|
|
|
366
366
|
# @example
|
|
367
367
|
# require "google/cloud/bigtable"
|
|
368
368
|
#
|
|
369
|
-
# filter = Google::Cloud::Bigtable::RowFilter.key
|
|
369
|
+
# filter = Google::Cloud::Bigtable::RowFilter.key "user-.*"
|
|
370
370
|
#
|
|
371
371
|
def self.key regex
|
|
372
372
|
SimpleFilter.new.key regex
|
|
@@ -385,7 +385,7 @@ module Google
|
|
|
385
385
|
# @example
|
|
386
386
|
# require "google/cloud/bigtable"
|
|
387
387
|
#
|
|
388
|
-
# filter = Google::Cloud::Bigtable::RowFilter.sample
|
|
388
|
+
# filter = Google::Cloud::Bigtable::RowFilter.sample 0.5
|
|
389
389
|
#
|
|
390
390
|
def self.sample probability
|
|
391
391
|
SimpleFilter.new.sample probability
|
|
@@ -409,7 +409,7 @@ module Google
|
|
|
409
409
|
# @example
|
|
410
410
|
# require "google/cloud/bigtable"
|
|
411
411
|
#
|
|
412
|
-
# filter = Google::Cloud::Bigtable::RowFilter.family
|
|
412
|
+
# filter = Google::Cloud::Bigtable::RowFilter.family "cf-.*"
|
|
413
413
|
#
|
|
414
414
|
def self.family regex
|
|
415
415
|
SimpleFilter.new.family regex
|
|
@@ -433,7 +433,7 @@ module Google
|
|
|
433
433
|
# @example
|
|
434
434
|
# require "google/cloud/bigtable"
|
|
435
435
|
#
|
|
436
|
-
# filter = Google::Cloud::Bigtable::RowFilter.qualifier
|
|
436
|
+
# filter = Google::Cloud::Bigtable::RowFilter.qualifier "user-name.*"
|
|
437
437
|
#
|
|
438
438
|
def self.qualifier regex
|
|
439
439
|
SimpleFilter.new.qualifier regex
|
|
@@ -456,7 +456,7 @@ module Google
|
|
|
456
456
|
# @example
|
|
457
457
|
# require "google/cloud/bigtable"
|
|
458
458
|
#
|
|
459
|
-
# filter = Google::Cloud::Bigtable::RowFilter.value
|
|
459
|
+
# filter = Google::Cloud::Bigtable::RowFilter.value "abc.*"
|
|
460
460
|
#
|
|
461
461
|
def self.value regex
|
|
462
462
|
SimpleFilter.new.value regex
|
|
@@ -485,7 +485,7 @@ module Google
|
|
|
485
485
|
# @example
|
|
486
486
|
# require "google/cloud/bigtable"
|
|
487
487
|
#
|
|
488
|
-
# filter = Google::Cloud::Bigtable::RowFilter.label
|
|
488
|
+
# filter = Google::Cloud::Bigtable::RowFilter.label "user-detail"
|
|
489
489
|
#
|
|
490
490
|
def self.label value
|
|
491
491
|
SimpleFilter.new.label value
|
|
@@ -504,7 +504,7 @@ module Google
|
|
|
504
504
|
# @example
|
|
505
505
|
# require "google/cloud/bigtable"
|
|
506
506
|
#
|
|
507
|
-
# filter = Google::Cloud::Bigtable::RowFilter.cells_per_row_offset
|
|
507
|
+
# filter = Google::Cloud::Bigtable::RowFilter.cells_per_row_offset 3
|
|
508
508
|
#
|
|
509
509
|
def self.cells_per_row_offset offset
|
|
510
510
|
SimpleFilter.new.cells_per_row_offset offset
|
|
@@ -523,7 +523,7 @@ module Google
|
|
|
523
523
|
# @example
|
|
524
524
|
# require "google/cloud/bigtable"
|
|
525
525
|
#
|
|
526
|
-
# filter = Google::Cloud::Bigtable::RowFilter.cells_per_row
|
|
526
|
+
# filter = Google::Cloud::Bigtable::RowFilter.cells_per_row 5
|
|
527
527
|
#
|
|
528
528
|
def self.cells_per_row limit
|
|
529
529
|
SimpleFilter.new.cells_per_row limit
|
|
@@ -542,7 +542,7 @@ module Google
|
|
|
542
542
|
# @example
|
|
543
543
|
# require "google/cloud/bigtable"
|
|
544
544
|
#
|
|
545
|
-
# filter = Google::Cloud::Bigtable::RowFilter.cells_per_column
|
|
545
|
+
# filter = Google::Cloud::Bigtable::RowFilter.cells_per_column 5
|
|
546
546
|
#
|
|
547
547
|
def self.cells_per_column limit
|
|
548
548
|
SimpleFilter.new.cells_per_column limit
|
|
@@ -561,17 +561,17 @@ module Google
|
|
|
561
561
|
# @example
|
|
562
562
|
# require "google/cloud/bigtable"
|
|
563
563
|
#
|
|
564
|
-
# timestamp_micros = (Time.now.to_f *
|
|
565
|
-
# from = timestamp_micros -
|
|
564
|
+
# timestamp_micros = (Time.now.to_f * 1_000_000).round(-3)
|
|
565
|
+
# from = timestamp_micros - 300_000_000
|
|
566
566
|
# to = timestamp_micros
|
|
567
567
|
#
|
|
568
|
-
# filter = Google::Cloud::Bigtable::RowFilter.timestamp_range
|
|
568
|
+
# filter = Google::Cloud::Bigtable::RowFilter.timestamp_range from: from, to: to
|
|
569
569
|
#
|
|
570
570
|
# # From to infinity
|
|
571
|
-
# filter = Google::Cloud::Bigtable::RowFilter.timestamp_range
|
|
571
|
+
# filter = Google::Cloud::Bigtable::RowFilter.timestamp_range from: from
|
|
572
572
|
#
|
|
573
573
|
# # From 0 value to `to`
|
|
574
|
-
# filter = Google::Cloud::Bigtable::RowFilter.timestamp_range
|
|
574
|
+
# filter = Google::Cloud::Bigtable::RowFilter.timestamp_range to: to
|
|
575
575
|
#
|
|
576
576
|
def self.timestamp_range from: nil, to: nil
|
|
577
577
|
SimpleFilter.new.timestamp_range from, to
|
|
@@ -597,19 +597,19 @@ module Google
|
|
|
597
597
|
# require "google/cloud/bigtable"
|
|
598
598
|
#
|
|
599
599
|
# bigtable = Google::Cloud::Bigtable.new
|
|
600
|
-
# table = bigtable.table
|
|
600
|
+
# table = bigtable.table "my-instance", "my-table"
|
|
601
601
|
#
|
|
602
|
-
# range = table.new_value_range.from
|
|
603
|
-
# filter = Google::Cloud::Bigtable::RowFilter.value_range
|
|
602
|
+
# range = table.new_value_range.from "value-001", inclusive: false
|
|
603
|
+
# filter = Google::Cloud::Bigtable::RowFilter.value_range range
|
|
604
604
|
#
|
|
605
605
|
# @example Start exclusive to infinite end range.
|
|
606
606
|
# require "google/cloud/bigtable"
|
|
607
607
|
#
|
|
608
608
|
# bigtable = Google::Cloud::Bigtable.new
|
|
609
|
-
# table = bigtable.table
|
|
609
|
+
# table = bigtable.table "my-instance", "my-table"
|
|
610
610
|
#
|
|
611
|
-
# range = table.new_value_range.from
|
|
612
|
-
# filter = Google::Cloud::Bigtable::RowFilter.value_range
|
|
611
|
+
# range = table.new_value_range.from "value-001", inclusive: false
|
|
612
|
+
# filter = Google::Cloud::Bigtable::RowFilter.value_range range
|
|
613
613
|
#
|
|
614
614
|
def self.value_range range
|
|
615
615
|
SimpleFilter.new.value_range range
|
|
@@ -628,7 +628,7 @@ module Google
|
|
|
628
628
|
#
|
|
629
629
|
# range = Google::Cloud::Bigtable::ColumnRange.new("cf").from("field0").to("field5")
|
|
630
630
|
#
|
|
631
|
-
# filter = Google::Cloud::Bigtable::RowFilter.column_range
|
|
631
|
+
# filter = Google::Cloud::Bigtable::RowFilter.column_range range
|
|
632
632
|
#
|
|
633
633
|
def self.column_range range
|
|
634
634
|
SimpleFilter.new.column_range range
|
|
@@ -30,7 +30,7 @@ module Google
|
|
|
30
30
|
# require "google/cloud/bigtable"
|
|
31
31
|
#
|
|
32
32
|
# bigtable = Google::Cloud::Bigtable.new
|
|
33
|
-
# table = bigtable.table
|
|
33
|
+
# table = bigtable.table "my-instance", "my-table"
|
|
34
34
|
#
|
|
35
35
|
# # Range that includes all row keys including "user-001" to "user-005"
|
|
36
36
|
# table.new_row_range.from("user-001").to("user-005", inclusive: true)
|
|
@@ -39,19 +39,19 @@ module Google
|
|
|
39
39
|
# table.new_row_range.from("user-001").to("user-010")
|
|
40
40
|
#
|
|
41
41
|
# # Range that includes all row keys including "user-001" up until end of the row keys.
|
|
42
|
-
# table.new_row_range.from
|
|
42
|
+
# table.new_row_range.from "user-001"
|
|
43
43
|
#
|
|
44
44
|
# # Range that includes all row keys exclusive "user-001" up until end of the row keys.
|
|
45
|
-
# table.new_row_range.from
|
|
45
|
+
# table.new_row_range.from "user-001", inclusive: false
|
|
46
46
|
#
|
|
47
47
|
# # Range with unbounded from and the exclusive end "user-010"
|
|
48
|
-
# table.new_row_range.to
|
|
48
|
+
# table.new_row_range.to "user-010"
|
|
49
49
|
#
|
|
50
50
|
# # Range that includes all row keys including from and end row keys "user-001", "user-010"
|
|
51
|
-
# table.new_row_range.between
|
|
51
|
+
# table.new_row_range.between "user-001", "user-010"
|
|
52
52
|
#
|
|
53
53
|
# # Range that includes all row keys including "user-001" up until "user-010"
|
|
54
|
-
# table.new_row_range.of
|
|
54
|
+
# table.new_row_range.of "user-001", "user-010"
|
|
55
55
|
#
|
|
56
56
|
class RowRange
|
|
57
57
|
# @private
|
|
@@ -72,17 +72,17 @@ module Google
|
|
|
72
72
|
# require "google/cloud/bigtable"
|
|
73
73
|
#
|
|
74
74
|
# bigtable = Google::Cloud::Bigtable.new
|
|
75
|
-
# table = bigtable.table
|
|
75
|
+
# table = bigtable.table "my-instance", "my-table"
|
|
76
76
|
#
|
|
77
|
-
# range = table.new_row_range.from
|
|
77
|
+
# range = table.new_row_range.from "key-001"
|
|
78
78
|
#
|
|
79
79
|
# @example Exclusive lower bound.
|
|
80
80
|
# require "google/cloud/bigtable"
|
|
81
81
|
#
|
|
82
82
|
# bigtable = Google::Cloud::Bigtable.new
|
|
83
|
-
# table = bigtable.table
|
|
83
|
+
# table = bigtable.table "my-instance", "my-table"
|
|
84
84
|
#
|
|
85
|
-
# range = table.new_row_range.from
|
|
85
|
+
# range = table.new_row_range.from "key-001", inclusive: false
|
|
86
86
|
#
|
|
87
87
|
def from key, inclusive: true
|
|
88
88
|
if inclusive
|
|
@@ -105,17 +105,17 @@ module Google
|
|
|
105
105
|
# require "google/cloud/bigtable"
|
|
106
106
|
#
|
|
107
107
|
# bigtable = Google::Cloud::Bigtable.new
|
|
108
|
-
# table = bigtable.table
|
|
108
|
+
# table = bigtable.table "my-instance", "my-table"
|
|
109
109
|
#
|
|
110
|
-
# range = table.new_row_range.to
|
|
110
|
+
# range = table.new_row_range.to "key-001", inclusive: true
|
|
111
111
|
#
|
|
112
112
|
# @example Exclusive upper bound.
|
|
113
113
|
# require "google/cloud/bigtable"
|
|
114
114
|
#
|
|
115
115
|
# bigtable = Google::Cloud::Bigtable.new
|
|
116
|
-
# table = bigtable.table
|
|
116
|
+
# table = bigtable.table "my-instance", "my-table"
|
|
117
117
|
#
|
|
118
|
-
# range = table.new_row_range.to
|
|
118
|
+
# range = table.new_row_range.to "key-001"
|
|
119
119
|
#
|
|
120
120
|
def to key, inclusive: false
|
|
121
121
|
if inclusive
|
|
@@ -138,9 +138,9 @@ module Google
|
|
|
138
138
|
# require "google/cloud/bigtable"
|
|
139
139
|
#
|
|
140
140
|
# bigtable = Google::Cloud::Bigtable.new
|
|
141
|
-
# table = bigtable.table
|
|
141
|
+
# table = bigtable.table "my-instance", "my-table"
|
|
142
142
|
#
|
|
143
|
-
# range = table.new_row_range.between
|
|
143
|
+
# range = table.new_row_range.between "key-001", "key-010"
|
|
144
144
|
#
|
|
145
145
|
def between from_key, to_key
|
|
146
146
|
from(from_key).to(to_key, inclusive: true)
|
|
@@ -158,9 +158,9 @@ module Google
|
|
|
158
158
|
# require "google/cloud/bigtable"
|
|
159
159
|
#
|
|
160
160
|
# bigtable = Google::Cloud::Bigtable.new
|
|
161
|
-
# table = bigtable.table
|
|
161
|
+
# table = bigtable.table "my-instance", "my-table"
|
|
162
162
|
#
|
|
163
|
-
# range = table.new_row_range.of
|
|
163
|
+
# range = table.new_row_range.of "key-001", "key-010"
|
|
164
164
|
#
|
|
165
165
|
def of from_key, to_key
|
|
166
166
|
from(from_key).to(to_key)
|
|
@@ -75,6 +75,7 @@ module Google
|
|
|
75
75
|
# Array of row or yield block for each processed row.
|
|
76
76
|
#
|
|
77
77
|
def read rows: nil, filter: nil, rows_limit: nil
|
|
78
|
+
@rows_count = 0
|
|
78
79
|
response = @table.service.read_rows(
|
|
79
80
|
@table.instance_id,
|
|
80
81
|
@table.table_id,
|
|
@@ -116,40 +117,54 @@ module Google
|
|
|
116
117
|
# If not specified, reads from all rows.
|
|
117
118
|
# A hash of the same form as `Google::Cloud::Bigtable::V2::RowSet`
|
|
118
119
|
# can also be provided.
|
|
119
|
-
# @return
|
|
120
|
+
# @return ResumptionOption
|
|
120
121
|
#
|
|
121
122
|
def retry_options rows_limit, row_set
|
|
122
|
-
return
|
|
123
|
+
return ResumptionOption.new false, rows_limit, row_set unless last_key
|
|
124
|
+
|
|
125
|
+
# Check if we've already read read rows_limit number of rows.
|
|
126
|
+
# If true, mark ResumptionOption is_complete to true.
|
|
127
|
+
return ResumptionOption.new true, nil, nil if rows_limit && rows_limit == @rows_count
|
|
123
128
|
|
|
124
|
-
#
|
|
129
|
+
# Reduce the limit by the number of already returned responses.
|
|
125
130
|
rows_limit -= @rows_count if rows_limit
|
|
126
131
|
|
|
127
|
-
|
|
132
|
+
reset_row_set rows_limit, row_set
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
##
|
|
136
|
+
# Calculate the new row_set for the retry request
|
|
137
|
+
# @param rows_limit [Integer]
|
|
138
|
+
# the updated rows_limit
|
|
139
|
+
# @param row_set [Google::Cloud::Bigtable::V2::RowSet]
|
|
140
|
+
# original row_set
|
|
141
|
+
# @return ResumptionOption
|
|
142
|
+
def reset_row_set rows_limit, row_set
|
|
143
|
+
# 1. Remove ranges that have already been read, and reduce ranges that
|
|
128
144
|
# include the last read rows
|
|
129
145
|
if last_key
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
if end_key_read? range
|
|
134
|
-
delete_indexes << i
|
|
135
|
-
elsif start_key_read? range
|
|
146
|
+
row_set.row_ranges.reject! { |r| end_key_read? r }
|
|
147
|
+
row_set.row_ranges.each do |range|
|
|
148
|
+
if start_key_read? range
|
|
136
149
|
range.start_key_open = last_key
|
|
137
150
|
end
|
|
138
151
|
end
|
|
139
|
-
|
|
140
|
-
delete_indexes.each { |i| row_set.row_ranges.delete_at i }
|
|
141
|
-
end
|
|
142
|
-
|
|
143
|
-
if row_set.row_ranges.empty?
|
|
144
|
-
row_set.row_ranges <<
|
|
145
|
-
Google::Cloud::Bigtable::V2::RowRange.new(start_key_open: last_key)
|
|
146
152
|
end
|
|
147
153
|
|
|
148
|
-
#
|
|
154
|
+
# 2. Remove all individual keys before and up to the last read key
|
|
149
155
|
row_set.row_keys.select! { |k| k > last_key }
|
|
150
156
|
|
|
157
|
+
# 3. In read_operations, we always add an empty row_range if row_ranges and
|
|
158
|
+
# row_keys are not defined. So if both row_ranges and row_keys are empty,
|
|
159
|
+
# it means that we've already read all the ranges and keys, set ResumptionOption
|
|
160
|
+
# is_complete to true to indicate that this read is successful.
|
|
161
|
+
if last_key && row_set.row_ranges.empty? && row_set.row_keys.empty?
|
|
162
|
+
return ResumptionOption.new true, nil, nil
|
|
163
|
+
end
|
|
164
|
+
|
|
151
165
|
@chunk_processor.reset_to_new_row
|
|
152
|
-
|
|
166
|
+
|
|
167
|
+
ResumptionOption.new false, rows_limit, row_set
|
|
153
168
|
end
|
|
154
169
|
|
|
155
170
|
##
|
|
@@ -170,13 +185,14 @@ module Google
|
|
|
170
185
|
# @return [Boolean]
|
|
171
186
|
#
|
|
172
187
|
def start_key_read? range
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
188
|
+
if !range.start_key_closed.empty?
|
|
189
|
+
last_key >= range.start_key_closed
|
|
190
|
+
elsif !range.start_key_open.empty?
|
|
191
|
+
last_key > range.start_key_closed
|
|
192
|
+
else
|
|
193
|
+
# start is unbounded
|
|
194
|
+
true
|
|
195
|
+
end
|
|
180
196
|
end
|
|
181
197
|
|
|
182
198
|
##
|
|
@@ -186,13 +202,42 @@ module Google
|
|
|
186
202
|
# @return [Boolean]
|
|
187
203
|
#
|
|
188
204
|
def end_key_read? range
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
205
|
+
if !range.end_key_closed.empty?
|
|
206
|
+
range.end_key_closed <= last_key
|
|
207
|
+
elsif !range.end_key_open.empty?
|
|
208
|
+
range.end_key_open <= last_key
|
|
209
|
+
else
|
|
210
|
+
# end is unbounded
|
|
211
|
+
false
|
|
212
|
+
end
|
|
213
|
+
end
|
|
214
|
+
end
|
|
194
215
|
|
|
195
|
-
|
|
216
|
+
# @private
|
|
217
|
+
# ResumptionOption
|
|
218
|
+
# Helper class returned by retry_options
|
|
219
|
+
class ResumptionOption
|
|
220
|
+
# @private
|
|
221
|
+
# Creates a ResumptionOption instance
|
|
222
|
+
# @param is_complete [Boolean]
|
|
223
|
+
# marks if the current read is complete
|
|
224
|
+
# @param rows_limit [Integer]
|
|
225
|
+
# limit of the retry request
|
|
226
|
+
# @param row_set [Google::Cloud::Bigtable::V2::RowSet]
|
|
227
|
+
# row_set of the retry request
|
|
228
|
+
def initialize is_complete, rows_limit, row_set
|
|
229
|
+
@is_complete = is_complete
|
|
230
|
+
@rows_limit = rows_limit
|
|
231
|
+
@row_set = row_set
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
attr_reader :rows_limit
|
|
235
|
+
attr_reader :row_set
|
|
236
|
+
|
|
237
|
+
##
|
|
238
|
+
# returns if this operation should be retried
|
|
239
|
+
def complete?
|
|
240
|
+
@is_complete
|
|
196
241
|
end
|
|
197
242
|
end
|
|
198
243
|
end
|