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
|
@@ -46,7 +46,7 @@ module Google
|
|
|
46
46
|
#
|
|
47
47
|
# bigtable = Google::Cloud::Bigtable.new
|
|
48
48
|
#
|
|
49
|
-
# instance = bigtable.instance
|
|
49
|
+
# instance = bigtable.instance "my-instance"
|
|
50
50
|
# clusters = bigtable.clusters # All clusters in the project
|
|
51
51
|
#
|
|
52
52
|
class Project
|
|
@@ -117,7 +117,7 @@ module Google
|
|
|
117
117
|
#
|
|
118
118
|
# bigtable = Google::Cloud::Bigtable.new
|
|
119
119
|
#
|
|
120
|
-
# instance = bigtable.instance
|
|
120
|
+
# instance = bigtable.instance "my-instance"
|
|
121
121
|
#
|
|
122
122
|
# if instance
|
|
123
123
|
# puts instance.instance_id
|
|
@@ -181,9 +181,9 @@ module Google
|
|
|
181
181
|
# "my-instance",
|
|
182
182
|
# display_name: "Instance for user data",
|
|
183
183
|
# type: :DEVELOPMENT,
|
|
184
|
-
# labels: { "env" => "dev"}
|
|
184
|
+
# labels: { "env" => "dev" }
|
|
185
185
|
# ) do |clusters|
|
|
186
|
-
# clusters.add
|
|
186
|
+
# clusters.add "test-cluster", "us-east1-b" # nodes not allowed
|
|
187
187
|
# end
|
|
188
188
|
#
|
|
189
189
|
# job.done? #=> false
|
|
@@ -206,9 +206,9 @@ module Google
|
|
|
206
206
|
# job = bigtable.create_instance(
|
|
207
207
|
# "my-instance",
|
|
208
208
|
# display_name: "Instance for user data",
|
|
209
|
-
# labels: { "env" => "dev"}
|
|
209
|
+
# labels: { "env" => "dev" }
|
|
210
210
|
# ) do |clusters|
|
|
211
|
-
# clusters.add
|
|
211
|
+
# clusters.add "test-cluster", "us-east1-b", nodes: 3, storage_type: :SSD
|
|
212
212
|
# end
|
|
213
213
|
#
|
|
214
214
|
# job.done? #=> false
|
|
@@ -224,9 +224,9 @@ module Google
|
|
|
224
224
|
# end
|
|
225
225
|
#
|
|
226
226
|
def create_instance instance_id, display_name: nil, type: nil, labels: nil, clusters: nil
|
|
227
|
-
labels =
|
|
227
|
+
labels = labels.to_h { |k, v| [String(k), String(v)] } if labels
|
|
228
228
|
|
|
229
|
-
instance_attrs = { display_name: display_name, type: type, labels: labels }.
|
|
229
|
+
instance_attrs = { display_name: display_name, type: type, labels: labels }.compact
|
|
230
230
|
instance = Google::Cloud::Bigtable::Admin::V2::Instance.new instance_attrs
|
|
231
231
|
clusters ||= Instance::ClusterMap.new
|
|
232
232
|
yield clusters if block_given?
|
|
@@ -314,14 +314,14 @@ module Google
|
|
|
314
314
|
#
|
|
315
315
|
# bigtable = Google::Cloud::Bigtable.new
|
|
316
316
|
#
|
|
317
|
-
# table = bigtable.table
|
|
317
|
+
# table = bigtable.table "my-instance", "my-table"
|
|
318
318
|
#
|
|
319
319
|
# @example Retrieve a table with a schema-only view.
|
|
320
320
|
# require "google/cloud/bigtable"
|
|
321
321
|
#
|
|
322
322
|
# bigtable = Google::Cloud::Bigtable.new
|
|
323
323
|
#
|
|
324
|
-
# table = bigtable.table
|
|
324
|
+
# table = bigtable.table "my-instance", "my-table", perform_lookup: true
|
|
325
325
|
# if table
|
|
326
326
|
# puts table.name
|
|
327
327
|
# puts table.column_families
|
|
@@ -332,7 +332,7 @@ module Google
|
|
|
332
332
|
#
|
|
333
333
|
# bigtable = Google::Cloud::Bigtable.new
|
|
334
334
|
#
|
|
335
|
-
# table = bigtable.table
|
|
335
|
+
# table = bigtable.table "my-instance", "my-table", view: :FULL, perform_lookup: true
|
|
336
336
|
# if table
|
|
337
337
|
# puts table.name
|
|
338
338
|
# puts table.column_families
|
|
@@ -343,15 +343,12 @@ module Google
|
|
|
343
343
|
ensure_service!
|
|
344
344
|
|
|
345
345
|
view ||= :SCHEMA_VIEW
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
table.app_profile_id = app_profile_id
|
|
354
|
-
table
|
|
346
|
+
if perform_lookup
|
|
347
|
+
grpc = service.get_table instance_id, table_id, view: view
|
|
348
|
+
Table.from_grpc grpc, service, view: view, app_profile_id: app_profile_id
|
|
349
|
+
else
|
|
350
|
+
Table.from_path service.table_path(instance_id, table_id), service, app_profile_id: app_profile_id
|
|
351
|
+
end
|
|
355
352
|
rescue Google::Cloud::NotFoundError
|
|
356
353
|
nil
|
|
357
354
|
end
|
|
@@ -402,7 +399,7 @@ module Google
|
|
|
402
399
|
#
|
|
403
400
|
# bigtable = Google::Cloud::Bigtable.new
|
|
404
401
|
#
|
|
405
|
-
# table = bigtable.create_table
|
|
402
|
+
# table = bigtable.create_table "my-instance", "my-table"
|
|
406
403
|
# puts table.name
|
|
407
404
|
#
|
|
408
405
|
# @example Create a table with initial splits and column families.
|
|
@@ -411,15 +408,15 @@ module Google
|
|
|
411
408
|
# bigtable = Google::Cloud::Bigtable.new
|
|
412
409
|
#
|
|
413
410
|
# initial_splits = ["user-00001", "user-100000", "others"]
|
|
414
|
-
# table = bigtable.create_table
|
|
415
|
-
# cfm.add
|
|
416
|
-
# cfm.add
|
|
411
|
+
# table = bigtable.create_table "my-instance", "my-table", initial_splits: initial_splits do |cfm|
|
|
412
|
+
# cfm.add "cf1", gc_rule: Google::Cloud::Bigtable::GcRule.max_versions(5)
|
|
413
|
+
# cfm.add "cf2", gc_rule: Google::Cloud::Bigtable::GcRule.max_age(600)
|
|
417
414
|
#
|
|
418
415
|
# gc_rule = Google::Cloud::Bigtable::GcRule.union(
|
|
419
416
|
# Google::Cloud::Bigtable::GcRule.max_age(1800),
|
|
420
417
|
# Google::Cloud::Bigtable::GcRule.max_versions(3)
|
|
421
418
|
# )
|
|
422
|
-
# cfm.add
|
|
419
|
+
# cfm.add "cf3", gc_rule: gc_rule
|
|
423
420
|
# end
|
|
424
421
|
#
|
|
425
422
|
# puts table
|
|
@@ -450,13 +447,74 @@ module Google
|
|
|
450
447
|
#
|
|
451
448
|
# bigtable = Google::Cloud::Bigtable.new
|
|
452
449
|
#
|
|
453
|
-
# bigtable.delete_table
|
|
450
|
+
# bigtable.delete_table "my-instance", "my-table"
|
|
454
451
|
#
|
|
455
452
|
def delete_table instance_id, table_id
|
|
456
453
|
service.delete_table instance_id, table_id
|
|
457
454
|
true
|
|
458
455
|
end
|
|
459
456
|
|
|
457
|
+
##
|
|
458
|
+
# Creates a copy of the backup at the desired location. Copy of the backup won't be created
|
|
459
|
+
# if the backup is already a copied one.
|
|
460
|
+
#
|
|
461
|
+
# @param dest_project_id [String] Existing project ID. Copy of the backup
|
|
462
|
+
# will be created in this project. Required.
|
|
463
|
+
# @param dest_instance_id [Instance, String] Existing instance ID. Copy
|
|
464
|
+
# of the backup will be created in this instance. Required.
|
|
465
|
+
# @param dest_cluster_id [String] Existing cluster ID. Copy of the backup
|
|
466
|
+
# will be created in this cluster. Required.
|
|
467
|
+
# @param new_backup_id [String] The id of the copy of the backup to be created. This string must
|
|
468
|
+
# be between 1 and 50 characters in length and match the regex
|
|
469
|
+
# `[_a-zA-Z0-9][-_.a-zA-Z0-9]*`. Required.
|
|
470
|
+
# @param source_instance_id [String] Existing instance ID. Backup will be copied from this instance. Required.
|
|
471
|
+
# @param source_cluster_id [String] Existing cluster ID. Backup will be copied from this cluster. Required.
|
|
472
|
+
# @param source_backup_id [Instance, String] Existing backup ID. This backup will be copied. Required.
|
|
473
|
+
# @param expire_time [Time] The expiration time of the copy of the backup, with microseconds
|
|
474
|
+
# granularity that must be at least 6 hours and at most 30 days from the time the request
|
|
475
|
+
# is received. Once the `expire_time` has passed, Cloud Bigtable will delete the backup
|
|
476
|
+
# and free the resources used by the backup. Required.
|
|
477
|
+
#
|
|
478
|
+
# @return [Google::Cloud::Bigtable::Backup::Job] The job representing the long-running, asynchronous
|
|
479
|
+
# processing of a copy backup operation.
|
|
480
|
+
#
|
|
481
|
+
# @example Create a copy of the specified backup at a specific location
|
|
482
|
+
# require "google/cloud/bigtable"
|
|
483
|
+
#
|
|
484
|
+
# bigtable = Google::Cloud::Bigtable.new
|
|
485
|
+
#
|
|
486
|
+
# job = bigtable.copy_backup dest_project_id:"my-project-2",
|
|
487
|
+
# dest_instance_id:"my-instance-2",
|
|
488
|
+
# dest_cluster_id:"my-cluster-2",
|
|
489
|
+
# new_backup_id:"my-backup-2",
|
|
490
|
+
# source_instance_id:"my-instance",
|
|
491
|
+
# source_cluster_id:"my-cluster",
|
|
492
|
+
# source_backup_id:"my-backup",
|
|
493
|
+
# expire_time: Time.now + 60 * 60 * 7
|
|
494
|
+
#
|
|
495
|
+
# job.wait_until_done!
|
|
496
|
+
# job.done? #=> true
|
|
497
|
+
#
|
|
498
|
+
# if job.error?
|
|
499
|
+
# status = job.error
|
|
500
|
+
# else
|
|
501
|
+
# backup = job.backup
|
|
502
|
+
# end
|
|
503
|
+
#
|
|
504
|
+
def copy_backup dest_project_id:, dest_instance_id:, dest_cluster_id:, new_backup_id:,
|
|
505
|
+
source_instance_id:, source_cluster_id:, source_backup_id:, expire_time:
|
|
506
|
+
ensure_service!
|
|
507
|
+
grpc = service.copy_backup project_id: dest_project_id,
|
|
508
|
+
instance_id: dest_instance_id,
|
|
509
|
+
cluster_id: dest_cluster_id,
|
|
510
|
+
backup_id: new_backup_id,
|
|
511
|
+
source_backup: service.backup_path(source_instance_id,
|
|
512
|
+
source_cluster_id,
|
|
513
|
+
source_backup_id),
|
|
514
|
+
expire_time: expire_time
|
|
515
|
+
Backup::Job.from_grpc grpc, service
|
|
516
|
+
end
|
|
517
|
+
|
|
460
518
|
protected
|
|
461
519
|
|
|
462
520
|
# @private
|
|
@@ -50,7 +50,7 @@ module Google
|
|
|
50
50
|
# require "google/cloud/bigtable"
|
|
51
51
|
#
|
|
52
52
|
# bigtable = Google::Cloud::Bigtable.new
|
|
53
|
-
# table = bigtable.table
|
|
53
|
+
# table = bigtable.table "my-instance", "my-table"
|
|
54
54
|
#
|
|
55
55
|
# table.sample_row_keys.each do |sample_row_key|
|
|
56
56
|
# p sample_row_key.key # user00116
|
|
@@ -90,7 +90,7 @@ module Google
|
|
|
90
90
|
# require "google/cloud/bigtable"
|
|
91
91
|
#
|
|
92
92
|
# bigtable = Google::Cloud::Bigtable.new
|
|
93
|
-
# table = bigtable.table
|
|
93
|
+
# table = bigtable.table "my-instance", "my-table"
|
|
94
94
|
#
|
|
95
95
|
# table.read_rows(limit: 10).each do |row|
|
|
96
96
|
# puts row
|
|
@@ -100,7 +100,7 @@ module Google
|
|
|
100
100
|
# require "google/cloud/bigtable"
|
|
101
101
|
#
|
|
102
102
|
# bigtable = Google::Cloud::Bigtable.new
|
|
103
|
-
# table = bigtable.table
|
|
103
|
+
# table = bigtable.table "my-instance", "my-table"
|
|
104
104
|
#
|
|
105
105
|
# table.read_rows(keys: ["user-1", "user-2"]).each do |row|
|
|
106
106
|
# puts row
|
|
@@ -110,9 +110,9 @@ module Google
|
|
|
110
110
|
# require "google/cloud/bigtable"
|
|
111
111
|
#
|
|
112
112
|
# bigtable = Google::Cloud::Bigtable.new
|
|
113
|
-
# table = bigtable.table
|
|
113
|
+
# table = bigtable.table "my-instance", "my-table"
|
|
114
114
|
#
|
|
115
|
-
# range = table.new_row_range.between
|
|
115
|
+
# range = table.new_row_range.between "user-1", "user-100"
|
|
116
116
|
#
|
|
117
117
|
# table.read_rows(ranges: range).each do |row|
|
|
118
118
|
# puts row
|
|
@@ -122,11 +122,11 @@ module Google
|
|
|
122
122
|
# require "google/cloud/bigtable"
|
|
123
123
|
#
|
|
124
124
|
# bigtable = Google::Cloud::Bigtable.new
|
|
125
|
-
# table = bigtable.table
|
|
125
|
+
# table = bigtable.table "my-instance", "my-table"
|
|
126
126
|
#
|
|
127
|
-
# filter = table.filter.key
|
|
127
|
+
# filter = table.filter.key "user-*"
|
|
128
128
|
# # OR
|
|
129
|
-
# # filter = Google::Cloud::Bigtable::RowFilter.key
|
|
129
|
+
# # filter = Google::Cloud::Bigtable::RowFilter.key "user-*"
|
|
130
130
|
#
|
|
131
131
|
# table.read_rows(filter: filter).each do |row|
|
|
132
132
|
# puts row
|
|
@@ -136,11 +136,11 @@ module Google
|
|
|
136
136
|
# require "google/cloud/bigtable"
|
|
137
137
|
#
|
|
138
138
|
# bigtable = Google::Cloud::Bigtable.new
|
|
139
|
-
# table = bigtable.table
|
|
139
|
+
# table = bigtable.table "my-instance", "my-table"
|
|
140
140
|
#
|
|
141
|
-
# filter = table.filter.key
|
|
141
|
+
# filter = table.filter.key "user-*"
|
|
142
142
|
# # OR
|
|
143
|
-
# # filter = Google::Cloud::Bigtable::RowFilter.key
|
|
143
|
+
# # filter = Google::Cloud::Bigtable::RowFilter.key "user-*"
|
|
144
144
|
#
|
|
145
145
|
# table.read_rows(filter: filter, limit: 10).each do |row|
|
|
146
146
|
# puts row
|
|
@@ -159,8 +159,10 @@ module Google
|
|
|
159
159
|
rescue *RowsReader::RETRYABLE_ERRORS => e
|
|
160
160
|
rows_reader.retry_count += 1
|
|
161
161
|
raise Google::Cloud::Error.from_error(e) unless rows_reader.retryable?
|
|
162
|
-
|
|
163
|
-
|
|
162
|
+
resumption_option = rows_reader.retry_options limit, row_set
|
|
163
|
+
rows_limit = resumption_option.rows_limit
|
|
164
|
+
row_set = resumption_option.row_set
|
|
165
|
+
retry unless resumption_option.complete?
|
|
164
166
|
end
|
|
165
167
|
end
|
|
166
168
|
|
|
@@ -176,19 +178,19 @@ module Google
|
|
|
176
178
|
# require "google/cloud/bigtable"
|
|
177
179
|
#
|
|
178
180
|
# bigtable = Google::Cloud::Bigtable.new
|
|
179
|
-
# table = bigtable.table
|
|
181
|
+
# table = bigtable.table "my-instance", "my-table"
|
|
180
182
|
#
|
|
181
|
-
# row = table.read_row
|
|
183
|
+
# row = table.read_row "user-1"
|
|
182
184
|
#
|
|
183
185
|
# @example Read row with filter.
|
|
184
186
|
# require "google/cloud/bigtable"
|
|
185
187
|
#
|
|
186
188
|
# bigtable = Google::Cloud::Bigtable.new
|
|
187
|
-
# table = bigtable.table
|
|
189
|
+
# table = bigtable.table "my-instance", "my-table"
|
|
188
190
|
#
|
|
189
|
-
# filter = Google::Cloud::Bigtable::RowFilter.cells_per_row
|
|
191
|
+
# filter = Google::Cloud::Bigtable::RowFilter.cells_per_row 3
|
|
190
192
|
#
|
|
191
|
-
# row = table.read_row
|
|
193
|
+
# row = table.read_row "user-1", filter: filter
|
|
192
194
|
#
|
|
193
195
|
def read_row key, filter: nil
|
|
194
196
|
read_rows(keys: [key], filter: filter).first
|
|
@@ -203,11 +205,11 @@ module Google
|
|
|
203
205
|
# require "google/cloud/bigtable"
|
|
204
206
|
#
|
|
205
207
|
# bigtable = Google::Cloud::Bigtable.new
|
|
206
|
-
# table = bigtable.table
|
|
208
|
+
# table = bigtable.table "my-instance", "my-table"
|
|
207
209
|
#
|
|
208
210
|
# range = table.new_value_range
|
|
209
|
-
# range.from
|
|
210
|
-
# range.to
|
|
211
|
+
# range.from "abc"
|
|
212
|
+
# range.to "xyz"
|
|
211
213
|
#
|
|
212
214
|
# # OR
|
|
213
215
|
# range = table.new_value_range.from("abc").to("xyz")
|
|
@@ -216,7 +218,7 @@ module Google
|
|
|
216
218
|
# require "google/cloud/bigtable"
|
|
217
219
|
#
|
|
218
220
|
# bigtable = Google::Cloud::Bigtable.new
|
|
219
|
-
# table = bigtable.table
|
|
221
|
+
# table = bigtable.table "my-instance", "my-table"
|
|
220
222
|
#
|
|
221
223
|
# range = table.new_value_range.from("abc", inclusive: false).to("xyz")
|
|
222
224
|
#
|
|
@@ -234,11 +236,11 @@ module Google
|
|
|
234
236
|
# require "google/cloud/bigtable"
|
|
235
237
|
#
|
|
236
238
|
# bigtable = Google::Cloud::Bigtable.new
|
|
237
|
-
# table = bigtable.table
|
|
239
|
+
# table = bigtable.table "my-instance", "my-table"
|
|
238
240
|
#
|
|
239
|
-
# range = table.new_column_range
|
|
240
|
-
# range.from
|
|
241
|
-
# range.to
|
|
241
|
+
# range = table.new_column_range "test-family"
|
|
242
|
+
# range.from "abc"
|
|
243
|
+
# range.to "xyz"
|
|
242
244
|
#
|
|
243
245
|
# # OR
|
|
244
246
|
# range = table.new_column_range("test-family").from("key-1").to("key-5")
|
|
@@ -247,7 +249,7 @@ module Google
|
|
|
247
249
|
# require "google/cloud/bigtable"
|
|
248
250
|
#
|
|
249
251
|
# bigtable = Google::Cloud::Bigtable.new
|
|
250
|
-
# table = bigtable.table
|
|
252
|
+
# table = bigtable.table "my-instance", "my-table"
|
|
251
253
|
#
|
|
252
254
|
# range = table.new_column_range("test-family").from("key-1", inclusive: false).to("key-5")
|
|
253
255
|
#
|
|
@@ -264,11 +266,11 @@ module Google
|
|
|
264
266
|
# require "google/cloud/bigtable"
|
|
265
267
|
#
|
|
266
268
|
# bigtable = Google::Cloud::Bigtable.new
|
|
267
|
-
# table = bigtable.table
|
|
269
|
+
# table = bigtable.table "my-instance", "my-table"
|
|
268
270
|
#
|
|
269
271
|
# range = table.new_row_range
|
|
270
|
-
# range.from
|
|
271
|
-
# range.to
|
|
272
|
+
# range.from "abc"
|
|
273
|
+
# range.to "xyz"
|
|
272
274
|
#
|
|
273
275
|
# # OR
|
|
274
276
|
# range = table.new_row_range.from("key-1").to("key-5")
|
|
@@ -277,7 +279,7 @@ module Google
|
|
|
277
279
|
# require "google/cloud/bigtable"
|
|
278
280
|
#
|
|
279
281
|
# bigtable = Google::Cloud::Bigtable.new
|
|
280
|
-
# table = bigtable.table
|
|
282
|
+
# table = bigtable.table "my-instance", "my-table"
|
|
281
283
|
#
|
|
282
284
|
# range = table.new_row_range.from("key-1", inclusive: false).to("key-5")
|
|
283
285
|
#
|
|
@@ -294,9 +296,9 @@ module Google
|
|
|
294
296
|
# require "google/cloud/bigtable"
|
|
295
297
|
#
|
|
296
298
|
# bigtable = Google::Cloud::Bigtable.new
|
|
297
|
-
# table = bigtable.table
|
|
299
|
+
# table = bigtable.table "my-instance", "my-table"
|
|
298
300
|
#
|
|
299
|
-
# filter = table.filter.key
|
|
301
|
+
# filter = table.filter.key "user-*"
|
|
300
302
|
#
|
|
301
303
|
def filter
|
|
302
304
|
Google::Cloud::Bigtable::RowFilter
|
|
@@ -320,6 +322,11 @@ module Google
|
|
|
320
322
|
row_set[:row_ranges] = row_ranges.map(&:to_grpc)
|
|
321
323
|
end
|
|
322
324
|
|
|
325
|
+
# Set the row range to full table scan if the row set is empty
|
|
326
|
+
if row_set.empty?
|
|
327
|
+
row_set[:row_ranges] = [Google::Cloud::Bigtable::V2::RowRange.new]
|
|
328
|
+
end
|
|
329
|
+
|
|
323
330
|
Google::Cloud::Bigtable::V2::RowSet.new row_set
|
|
324
331
|
end
|
|
325
332
|
end
|
|
@@ -38,10 +38,10 @@ module Google
|
|
|
38
38
|
#
|
|
39
39
|
# bigtable = Google::Cloud::Bigtable.new
|
|
40
40
|
#
|
|
41
|
-
# instance = bigtable.instance
|
|
41
|
+
# instance = bigtable.instance "my-instance"
|
|
42
42
|
#
|
|
43
43
|
# routing_policy = Google::Cloud::Bigtable::AppProfile.single_cluster_routing(
|
|
44
|
-
# "my-
|
|
44
|
+
# "my-cluster",
|
|
45
45
|
# allow_transactional_writes: true
|
|
46
46
|
# )
|
|
47
47
|
#
|
|
@@ -57,7 +57,7 @@ module Google
|
|
|
57
57
|
#
|
|
58
58
|
# bigtable = Google::Cloud::Bigtable.new
|
|
59
59
|
#
|
|
60
|
-
# instance = bigtable.instance
|
|
60
|
+
# instance = bigtable.instance "my-instance"
|
|
61
61
|
#
|
|
62
62
|
# routing_policy = Google::Cloud::Bigtable::AppProfile.multi_cluster_routing
|
|
63
63
|
#
|
|
@@ -85,7 +85,7 @@ module Google
|
|
|
85
85
|
#
|
|
86
86
|
# bigtable = Google::Cloud::Bigtable.new
|
|
87
87
|
#
|
|
88
|
-
# instance = bigtable.instance
|
|
88
|
+
# instance = bigtable.instance "my-instance"
|
|
89
89
|
#
|
|
90
90
|
# routing_policy = Google::Cloud::Bigtable::AppProfile.multi_cluster_routing
|
|
91
91
|
#
|
|
@@ -116,10 +116,10 @@ module Google
|
|
|
116
116
|
#
|
|
117
117
|
# bigtable = Google::Cloud::Bigtable.new
|
|
118
118
|
#
|
|
119
|
-
# instance = bigtable.instance
|
|
119
|
+
# instance = bigtable.instance "my-instance"
|
|
120
120
|
#
|
|
121
121
|
# routing_policy = Google::Cloud::Bigtable::AppProfile.single_cluster_routing(
|
|
122
|
-
# "my-
|
|
122
|
+
# "my-cluster",
|
|
123
123
|
# allow_transactional_writes: true
|
|
124
124
|
# )
|
|
125
125
|
#
|
|
@@ -35,7 +35,7 @@ module Google
|
|
|
35
35
|
#
|
|
36
36
|
# chain = Google::Cloud::Bigtable::RowFilter.chain
|
|
37
37
|
# # Add filters to chain filter
|
|
38
|
-
# chain.key("user-*").label
|
|
38
|
+
# chain.key("user-*").label "users"
|
|
39
39
|
#
|
|
40
40
|
class ChainFilter
|
|
41
41
|
# @private
|
|
@@ -65,13 +65,13 @@ module Google
|
|
|
65
65
|
# chain_1 = Google::Cloud::Bigtable::RowFilter.chain
|
|
66
66
|
#
|
|
67
67
|
# # Add filters to chain filter
|
|
68
|
-
# chain_1.key("user-*").cells_per_row
|
|
68
|
+
# chain_1.key("user-*").cells_per_row 5
|
|
69
69
|
#
|
|
70
70
|
# filter = Google::Cloud::Bigtable::RowFilter.chain
|
|
71
|
-
# filter.chain
|
|
71
|
+
# filter.chain chain_1
|
|
72
72
|
#
|
|
73
73
|
# # OR
|
|
74
|
-
# filter = Google::Cloud::Bigtable::RowFilter.chain.chain
|
|
74
|
+
# filter = Google::Cloud::Bigtable::RowFilter.chain.chain chain_1
|
|
75
75
|
#
|
|
76
76
|
def chain filter
|
|
77
77
|
raise RowFilterError, "Filter type must be ChainFilter" unless filter.instance_of? ChainFilter
|
|
@@ -124,7 +124,7 @@ module Google
|
|
|
124
124
|
# # Add filters to interleave filter
|
|
125
125
|
# interleave.key("user-*").cells_per_column(3)
|
|
126
126
|
#
|
|
127
|
-
# chain = Google::Cloud::Bigtable::RowFilter.chain.interleave
|
|
127
|
+
# chain = Google::Cloud::Bigtable::RowFilter.chain.interleave interleave
|
|
128
128
|
#
|
|
129
129
|
def interleave filter
|
|
130
130
|
raise RowFilterError, "Filter type must be InterleaveFilter" unless filter.instance_of? InterleaveFilter
|
|
@@ -151,15 +151,16 @@ module Google
|
|
|
151
151
|
# @example
|
|
152
152
|
# require "google/cloud/bigtable"
|
|
153
153
|
#
|
|
154
|
-
# predicate = Google::Cloud::Bigtable::RowFilter.key
|
|
154
|
+
# predicate = Google::Cloud::Bigtable::RowFilter.key "user-*"
|
|
155
155
|
#
|
|
156
|
-
# label = Google::Cloud::Bigtable::RowFilter.label
|
|
156
|
+
# label = Google::Cloud::Bigtable::RowFilter.label "user"
|
|
157
157
|
# strip_value = Google::Cloud::Bigtable::RowFilter.strip_value
|
|
158
158
|
#
|
|
159
|
-
# condition_filter = Google::Cloud::Bigtable::RowFilter.
|
|
160
|
-
#
|
|
159
|
+
# condition_filter = Google::Cloud::Bigtable::RowFilter.condition(predicate)
|
|
160
|
+
# .on_match(label)
|
|
161
|
+
# .otherwise(strip_value)
|
|
161
162
|
#
|
|
162
|
-
# filter = Google::Cloud::Bigtable::RowFilter.chain.condition
|
|
163
|
+
# filter = Google::Cloud::Bigtable::RowFilter.chain.condition condition_filter
|
|
163
164
|
#
|
|
164
165
|
def condition filter
|
|
165
166
|
raise RowFilterError, "Filter type must be ConditionFilter" unless filter.instance_of? ConditionFilter
|
|
@@ -257,7 +258,7 @@ module Google
|
|
|
257
258
|
# @example
|
|
258
259
|
# require "google/cloud/bigtable"
|
|
259
260
|
#
|
|
260
|
-
# filter = Google::Cloud::Bigtable::RowFilter.chain.key
|
|
261
|
+
# filter = Google::Cloud::Bigtable::RowFilter.chain.key "user-*"
|
|
261
262
|
#
|
|
262
263
|
def key regex
|
|
263
264
|
add RowFilter.key(regex)
|
|
@@ -277,7 +278,7 @@ module Google
|
|
|
277
278
|
# @example
|
|
278
279
|
# require "google/cloud/bigtable"
|
|
279
280
|
#
|
|
280
|
-
# filter = Google::Cloud::Bigtable::RowFilter.chain.sample
|
|
281
|
+
# filter = Google::Cloud::Bigtable::RowFilter.chain.sample 0.5
|
|
281
282
|
#
|
|
282
283
|
def sample probability
|
|
283
284
|
add RowFilter.sample(probability)
|
|
@@ -303,7 +304,7 @@ module Google
|
|
|
303
304
|
# @example
|
|
304
305
|
# require "google/cloud/bigtable"
|
|
305
306
|
#
|
|
306
|
-
# filter = Google::Cloud::Bigtable::RowFilter.chain.family
|
|
307
|
+
# filter = Google::Cloud::Bigtable::RowFilter.chain.family "cf-*"
|
|
307
308
|
#
|
|
308
309
|
def family regex
|
|
309
310
|
add RowFilter.family(regex)
|
|
@@ -329,7 +330,7 @@ module Google
|
|
|
329
330
|
# @example
|
|
330
331
|
# require "google/cloud/bigtable"
|
|
331
332
|
#
|
|
332
|
-
# filter = Google::Cloud::Bigtable::RowFilter.chain.qualifier
|
|
333
|
+
# filter = Google::Cloud::Bigtable::RowFilter.chain.qualifier "user-name*"
|
|
333
334
|
#
|
|
334
335
|
def qualifier regex
|
|
335
336
|
add RowFilter.qualifier(regex)
|
|
@@ -354,7 +355,7 @@ module Google
|
|
|
354
355
|
# @example
|
|
355
356
|
# require "google/cloud/bigtable"
|
|
356
357
|
#
|
|
357
|
-
# filter = Google::Cloud::Bigtable::RowFilter.chain.value
|
|
358
|
+
# filter = Google::Cloud::Bigtable::RowFilter.chain.value "abc*"
|
|
358
359
|
#
|
|
359
360
|
def value regex
|
|
360
361
|
add RowFilter.value(regex)
|
|
@@ -383,7 +384,7 @@ module Google
|
|
|
383
384
|
# @example
|
|
384
385
|
# require "google/cloud/bigtable"
|
|
385
386
|
#
|
|
386
|
-
# filter = Google::Cloud::Bigtable::RowFilter.chain.label
|
|
387
|
+
# filter = Google::Cloud::Bigtable::RowFilter.chain.label "user-detail"
|
|
387
388
|
#
|
|
388
389
|
def label value
|
|
389
390
|
add RowFilter.label(value)
|
|
@@ -403,7 +404,7 @@ module Google
|
|
|
403
404
|
# @example
|
|
404
405
|
# require "google/cloud/bigtable"
|
|
405
406
|
#
|
|
406
|
-
# filter = Google::Cloud::Bigtable::RowFilter.chain.cells_per_row_offset
|
|
407
|
+
# filter = Google::Cloud::Bigtable::RowFilter.chain.cells_per_row_offset 3
|
|
407
408
|
#
|
|
408
409
|
def cells_per_row_offset offset
|
|
409
410
|
add RowFilter.cells_per_row_offset(offset)
|
|
@@ -423,7 +424,7 @@ module Google
|
|
|
423
424
|
# @example
|
|
424
425
|
# require "google/cloud/bigtable"
|
|
425
426
|
#
|
|
426
|
-
# filter = Google::Cloud::Bigtable::RowFilter.chain.cells_per_row
|
|
427
|
+
# filter = Google::Cloud::Bigtable::RowFilter.chain.cells_per_row 5
|
|
427
428
|
#
|
|
428
429
|
def cells_per_row limit
|
|
429
430
|
add RowFilter.cells_per_row(limit)
|
|
@@ -446,7 +447,7 @@ module Google
|
|
|
446
447
|
# @example
|
|
447
448
|
# require "google/cloud/bigtable"
|
|
448
449
|
#
|
|
449
|
-
# filter = Google::Cloud::Bigtable::RowFilter.chain.cells_per_column
|
|
450
|
+
# filter = Google::Cloud::Bigtable::RowFilter.chain.cells_per_column 5
|
|
450
451
|
#
|
|
451
452
|
def cells_per_column limit
|
|
452
453
|
add RowFilter.cells_per_column(limit)
|
|
@@ -468,11 +469,11 @@ module Google
|
|
|
468
469
|
# @example
|
|
469
470
|
# require "google/cloud/bigtable"
|
|
470
471
|
#
|
|
471
|
-
# timestamp_micros = (Time.now.to_f *
|
|
472
|
-
# from = timestamp_micros -
|
|
472
|
+
# timestamp_micros = (Time.now.to_f * 1_000_000).round(-3)
|
|
473
|
+
# from = timestamp_micros - 300_000_000
|
|
473
474
|
# to = timestamp_micros
|
|
474
475
|
#
|
|
475
|
-
# filter = Google::Cloud::Bigtable::RowFilter.chain.timestamp_range
|
|
476
|
+
# filter = Google::Cloud::Bigtable::RowFilter.chain.timestamp_range from: from, to: to
|
|
476
477
|
#
|
|
477
478
|
def timestamp_range from: nil, to: nil
|
|
478
479
|
add RowFilter.timestamp_range(from: from, to: to)
|
|
@@ -498,19 +499,19 @@ module Google
|
|
|
498
499
|
# require "google/cloud/bigtable"
|
|
499
500
|
#
|
|
500
501
|
# bigtable = Google::Cloud::Bigtable.new
|
|
501
|
-
# table = bigtable.table
|
|
502
|
+
# table = bigtable.table "my-instance", "my-table"
|
|
502
503
|
#
|
|
503
504
|
# range = table.new_value_range.from("value-001").to("value-005")
|
|
504
|
-
# filter = Google::Cloud::Bigtable::RowFilter.chain.value_range
|
|
505
|
+
# filter = Google::Cloud::Bigtable::RowFilter.chain.value_range range
|
|
505
506
|
#
|
|
506
507
|
# @example Start exclusive to infinite end range.
|
|
507
508
|
# require "google/cloud/bigtable"
|
|
508
509
|
#
|
|
509
510
|
# bigtable = Google::Cloud::Bigtable.new
|
|
510
|
-
# table = bigtable.table
|
|
511
|
+
# table = bigtable.table "my-instance", "my-table"
|
|
511
512
|
#
|
|
512
|
-
# range = table.new_value_range.from
|
|
513
|
-
# filter = Google::Cloud::Bigtable::RowFilter.chain.value_range
|
|
513
|
+
# range = table.new_value_range.from "value-001", inclusive: false
|
|
514
|
+
# filter = Google::Cloud::Bigtable::RowFilter.chain.value_range range
|
|
514
515
|
#
|
|
515
516
|
def value_range range
|
|
516
517
|
add RowFilter.value_range(range)
|
|
@@ -528,9 +529,9 @@ module Google
|
|
|
528
529
|
# @example
|
|
529
530
|
# require "google/cloud/bigtable"
|
|
530
531
|
#
|
|
531
|
-
# range = Google::Cloud::Bigtable::ColumnRange.new("cf").from("field0").to(
|
|
532
|
+
# range = Google::Cloud::Bigtable::ColumnRange.new("cf").from("field0").to("field5")
|
|
532
533
|
#
|
|
533
|
-
# filter = Google::Cloud::Bigtable::RowFilter.chain.column_range
|
|
534
|
+
# filter = Google::Cloud::Bigtable::RowFilter.chain.column_range range
|
|
534
535
|
#
|
|
535
536
|
def column_range range
|
|
536
537
|
add RowFilter.column_range(range)
|
|
@@ -34,9 +34,9 @@ module Google
|
|
|
34
34
|
# evaluated on the input row. Otherwise, `false_filter` will be evaluated.
|
|
35
35
|
#
|
|
36
36
|
# @example
|
|
37
|
-
# predicate = Google::Cloud::Bigtable::RowFilter.key
|
|
37
|
+
# predicate = Google::Cloud::Bigtable::RowFilter.key "user-*"
|
|
38
38
|
#
|
|
39
|
-
# label = Google::Cloud::Bigtable::RowFilter.label
|
|
39
|
+
# label = Google::Cloud::Bigtable::RowFilter.label "user"
|
|
40
40
|
# strip_value = Google::Cloud::Bigtable::RowFilter.strip_value
|
|
41
41
|
#
|
|
42
42
|
# Google::Cloud::Bigtable::RowFilter.condition(predicate).on_match(label).otherwise(strip_value)
|
|
@@ -63,9 +63,9 @@ module Google
|
|
|
63
63
|
#
|
|
64
64
|
# @example
|
|
65
65
|
# require "google/cloud/bigtable"
|
|
66
|
-
# predicate = Google::Cloud::Bigtable::RowFilter.key
|
|
66
|
+
# predicate = Google::Cloud::Bigtable::RowFilter.key "user-*"
|
|
67
67
|
#
|
|
68
|
-
# label = Google::Cloud::Bigtable::RowFilter.label
|
|
68
|
+
# label = Google::Cloud::Bigtable::RowFilter.label "user"
|
|
69
69
|
# strip_value = Google::Cloud::Bigtable::RowFilter.strip_value
|
|
70
70
|
#
|
|
71
71
|
# Google::Cloud::Bigtable::RowFilter.condition(predicate).on_match(label).otherwise(strip_value)
|
|
@@ -88,9 +88,9 @@ module Google
|
|
|
88
88
|
# @example
|
|
89
89
|
# require "google/cloud/bigtable"
|
|
90
90
|
#
|
|
91
|
-
# predicate = Google::Cloud::Bigtable::RowFilter.key
|
|
91
|
+
# predicate = Google::Cloud::Bigtable::RowFilter.key "user-*"
|
|
92
92
|
#
|
|
93
|
-
# label = Google::Cloud::Bigtable::RowFilter.label
|
|
93
|
+
# label = Google::Cloud::Bigtable::RowFilter.label "user"
|
|
94
94
|
# strip_value = Google::Cloud::Bigtable::RowFilter.strip_value
|
|
95
95
|
#
|
|
96
96
|
# Google::Cloud::Bigtable::RowFilter.condition(predicate).on_match(label).otherwise(strip_value)
|