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
|
@@ -44,9 +44,9 @@ module Google
|
|
|
44
44
|
# "my-instance",
|
|
45
45
|
# display_name: "Instance for user data",
|
|
46
46
|
# type: :DEVELOPMENT,
|
|
47
|
-
# labels: { "env" => "dev"}
|
|
47
|
+
# labels: { "env" => "dev" }
|
|
48
48
|
# ) do |clusters|
|
|
49
|
-
# clusters.add
|
|
49
|
+
# clusters.add "test-cluster", "us-east1-b" # nodes not allowed
|
|
50
50
|
# end
|
|
51
51
|
#
|
|
52
52
|
# job.done? #=> false
|
|
@@ -203,7 +203,7 @@ module Google
|
|
|
203
203
|
#
|
|
204
204
|
# bigtable = Google::Cloud::Bigtable.new
|
|
205
205
|
#
|
|
206
|
-
# instance = bigtable.instance
|
|
206
|
+
# instance = bigtable.instance "my-instance"
|
|
207
207
|
#
|
|
208
208
|
# instance.development? # true
|
|
209
209
|
# instance.type = :PRODUCTION
|
|
@@ -245,7 +245,7 @@ module Google
|
|
|
245
245
|
labels ||= {}
|
|
246
246
|
@grpc.labels = Google::Protobuf::Map.new(
|
|
247
247
|
:string, :string,
|
|
248
|
-
|
|
248
|
+
labels.to_h { |k, v| [String(k), String(v)] }
|
|
249
249
|
)
|
|
250
250
|
end
|
|
251
251
|
|
|
@@ -267,7 +267,7 @@ module Google
|
|
|
267
267
|
#
|
|
268
268
|
# bigtable = Google::Cloud::Bigtable.new
|
|
269
269
|
#
|
|
270
|
-
# instance = bigtable.instance
|
|
270
|
+
# instance = bigtable.instance "my-instance"
|
|
271
271
|
# instance.display_name = "My app dev instance" # Set display name
|
|
272
272
|
# instance.labels = { env: "dev", data: "users" }
|
|
273
273
|
# job = instance.save
|
|
@@ -314,7 +314,7 @@ module Google
|
|
|
314
314
|
#
|
|
315
315
|
# bigtable = Google::Cloud::Bigtable.new
|
|
316
316
|
#
|
|
317
|
-
# instance = bigtable.instance
|
|
317
|
+
# instance = bigtable.instance "my-instance"
|
|
318
318
|
# instance.delete
|
|
319
319
|
#
|
|
320
320
|
def delete
|
|
@@ -340,7 +340,7 @@ module Google
|
|
|
340
340
|
#
|
|
341
341
|
# bigtable = Google::Cloud::Bigtable.new
|
|
342
342
|
#
|
|
343
|
-
# instance = bigtable.instance
|
|
343
|
+
# instance = bigtable.instance "my-instance"
|
|
344
344
|
#
|
|
345
345
|
# instance.clusters.all do |cluster|
|
|
346
346
|
# puts cluster.cluster_id
|
|
@@ -366,9 +366,9 @@ module Google
|
|
|
366
366
|
#
|
|
367
367
|
# bigtable = Google::Cloud::Bigtable.new
|
|
368
368
|
#
|
|
369
|
-
# instance = bigtable.instance
|
|
369
|
+
# instance = bigtable.instance "my-instance"
|
|
370
370
|
#
|
|
371
|
-
# cluster = instance.cluster
|
|
371
|
+
# cluster = instance.cluster "my-cluster"
|
|
372
372
|
# puts cluster.cluster_id
|
|
373
373
|
#
|
|
374
374
|
def cluster cluster_id
|
|
@@ -403,7 +403,7 @@ module Google
|
|
|
403
403
|
#
|
|
404
404
|
# bigtable = Google::Cloud::Bigtable.new
|
|
405
405
|
#
|
|
406
|
-
# instance = bigtable.instance
|
|
406
|
+
# instance = bigtable.instance "my-instance"
|
|
407
407
|
# job = instance.create_cluster(
|
|
408
408
|
# "my-new-cluster",
|
|
409
409
|
# "us-east-1b",
|
|
@@ -429,7 +429,7 @@ module Google
|
|
|
429
429
|
serve_nodes: nodes,
|
|
430
430
|
default_storage_type: storage_type,
|
|
431
431
|
location: location
|
|
432
|
-
}.
|
|
432
|
+
}.compact
|
|
433
433
|
|
|
434
434
|
cluster = Google::Cloud::Bigtable::Admin::V2::Cluster.new attrs
|
|
435
435
|
grpc = service.create_cluster instance_id, cluster_id, cluster
|
|
@@ -450,7 +450,7 @@ module Google
|
|
|
450
450
|
#
|
|
451
451
|
# bigtable = Google::Cloud::Bigtable.new
|
|
452
452
|
#
|
|
453
|
-
# instance = bigtable.instance
|
|
453
|
+
# instance = bigtable.instance "my-instance"
|
|
454
454
|
#
|
|
455
455
|
# # Default name-only view
|
|
456
456
|
# instance.tables.all do |table|
|
|
@@ -490,14 +490,14 @@ module Google
|
|
|
490
490
|
#
|
|
491
491
|
# bigtable = Google::Cloud::Bigtable.new
|
|
492
492
|
#
|
|
493
|
-
# instance = bigtable.instance
|
|
493
|
+
# instance = bigtable.instance "my-instance"
|
|
494
494
|
#
|
|
495
|
-
# table = instance.table
|
|
495
|
+
# table = instance.table "my-table", perform_lookup: true
|
|
496
496
|
# puts table.name
|
|
497
497
|
# puts table.column_families
|
|
498
498
|
#
|
|
499
499
|
# # Name-only view
|
|
500
|
-
# table = instance.table
|
|
500
|
+
# table = instance.table "my-table", view: :NAME_ONLY, perform_lookup: true
|
|
501
501
|
# puts table.name
|
|
502
502
|
#
|
|
503
503
|
# @example Mutate rows.
|
|
@@ -505,31 +505,28 @@ module Google
|
|
|
505
505
|
#
|
|
506
506
|
# bigtable = Google::Cloud::Bigtable.new
|
|
507
507
|
#
|
|
508
|
-
# table = bigtable.table
|
|
508
|
+
# table = bigtable.table "my-instance", "my-table"
|
|
509
509
|
#
|
|
510
|
-
# entry = table.new_mutation_entry
|
|
510
|
+
# entry = table.new_mutation_entry "user-1"
|
|
511
511
|
# entry.set_cell(
|
|
512
512
|
# "cf1",
|
|
513
513
|
# "field1",
|
|
514
514
|
# "XYZ",
|
|
515
|
-
# timestamp: (Time.now.to_f *
|
|
516
|
-
# ).delete_cells
|
|
515
|
+
# timestamp: (Time.now.to_f * 1_000_000).round(-3) # microseconds
|
|
516
|
+
# ).delete_cells "cf2", "field02"
|
|
517
517
|
#
|
|
518
|
-
# table.mutate_row
|
|
518
|
+
# table.mutate_row entry
|
|
519
519
|
#
|
|
520
520
|
def table table_id, view: nil, perform_lookup: nil, app_profile_id: nil
|
|
521
521
|
ensure_service!
|
|
522
522
|
|
|
523
523
|
view ||= :SCHEMA_VIEW
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
table.app_profile_id = app_profile_id
|
|
532
|
-
table
|
|
524
|
+
if perform_lookup
|
|
525
|
+
grpc = service.get_table instance_id, table_id, view: view
|
|
526
|
+
Table.from_grpc grpc, service, view: view, app_profile_id: app_profile_id
|
|
527
|
+
else
|
|
528
|
+
Table.from_path service.table_path(instance_id, table_id), service, app_profile_id: app_profile_id
|
|
529
|
+
end
|
|
533
530
|
rescue Google::Cloud::NotFoundError
|
|
534
531
|
nil
|
|
535
532
|
end
|
|
@@ -581,9 +578,9 @@ module Google
|
|
|
581
578
|
#
|
|
582
579
|
# bigtable = Google::Cloud::Bigtable.new
|
|
583
580
|
#
|
|
584
|
-
# instance = bigtable.instance
|
|
581
|
+
# instance = bigtable.instance "my-instance"
|
|
585
582
|
#
|
|
586
|
-
# table = instance.create_table
|
|
583
|
+
# table = instance.create_table "my-table"
|
|
587
584
|
# puts table.name
|
|
588
585
|
#
|
|
589
586
|
# @example Create a table with initial splits and column families.
|
|
@@ -591,18 +588,18 @@ module Google
|
|
|
591
588
|
#
|
|
592
589
|
# bigtable = Google::Cloud::Bigtable.new
|
|
593
590
|
#
|
|
594
|
-
# instance = bigtable.instance
|
|
591
|
+
# instance = bigtable.instance "my-instance"
|
|
595
592
|
#
|
|
596
593
|
# initial_splits = ["user-00001", "user-100000", "others"]
|
|
597
|
-
# table = instance.create_table
|
|
598
|
-
# cfm.add
|
|
599
|
-
# cfm.add
|
|
594
|
+
# table = instance.create_table "my-table", initial_splits: initial_splits do |cfm|
|
|
595
|
+
# cfm.add "cf1", gc_rule: Google::Cloud::Bigtable::GcRule.max_versions(5)
|
|
596
|
+
# cfm.add "cf2", gc_rule: Google::Cloud::Bigtable::GcRule.max_age(600)
|
|
600
597
|
#
|
|
601
598
|
# gc_rule = Google::Cloud::Bigtable::GcRule.union(
|
|
602
|
-
#
|
|
599
|
+
# Google::Cloud::Bigtable::GcRule.max_age(1800),
|
|
603
600
|
# Google::Cloud::Bigtable::GcRule.max_versions(3)
|
|
604
601
|
# )
|
|
605
|
-
# cfm.add
|
|
602
|
+
# cfm.add "cf3", gc_rule: gc_rule
|
|
606
603
|
# end
|
|
607
604
|
#
|
|
608
605
|
# puts table
|
|
@@ -660,10 +657,10 @@ module Google
|
|
|
660
657
|
#
|
|
661
658
|
# bigtable = Google::Cloud::Bigtable.new
|
|
662
659
|
#
|
|
663
|
-
# instance = bigtable.instance
|
|
660
|
+
# instance = bigtable.instance "my-instance"
|
|
664
661
|
#
|
|
665
662
|
# routing_policy = Google::Cloud::Bigtable::AppProfile.single_cluster_routing(
|
|
666
|
-
# "my-
|
|
663
|
+
# "my-cluster",
|
|
667
664
|
# allow_transactional_writes: true
|
|
668
665
|
# )
|
|
669
666
|
#
|
|
@@ -679,7 +676,7 @@ module Google
|
|
|
679
676
|
#
|
|
680
677
|
# bigtable = Google::Cloud::Bigtable.new
|
|
681
678
|
#
|
|
682
|
-
# instance = bigtable.instance
|
|
679
|
+
# instance = bigtable.instance "my-instance"
|
|
683
680
|
#
|
|
684
681
|
# routing_policy = Google::Cloud::Bigtable::AppProfile.multi_cluster_routing
|
|
685
682
|
#
|
|
@@ -695,7 +692,7 @@ module Google
|
|
|
695
692
|
#
|
|
696
693
|
# bigtable = Google::Cloud::Bigtable.new
|
|
697
694
|
#
|
|
698
|
-
# instance = bigtable.instance
|
|
695
|
+
# instance = bigtable.instance "my-instance"
|
|
699
696
|
#
|
|
700
697
|
# routing_policy = Google::Cloud::Bigtable::AppProfile.multi_cluster_routing
|
|
701
698
|
#
|
|
@@ -721,7 +718,7 @@ module Google
|
|
|
721
718
|
single_cluster_routing: single_cluster_routing,
|
|
722
719
|
description: description,
|
|
723
720
|
etag: etag
|
|
724
|
-
}.
|
|
721
|
+
}.compact
|
|
725
722
|
|
|
726
723
|
grpc = service.create_app_profile(
|
|
727
724
|
instance_id,
|
|
@@ -746,9 +743,9 @@ module Google
|
|
|
746
743
|
#
|
|
747
744
|
# bigtable = Google::Cloud::Bigtable.new
|
|
748
745
|
#
|
|
749
|
-
# instance = bigtable.instance
|
|
746
|
+
# instance = bigtable.instance "my-instance"
|
|
750
747
|
#
|
|
751
|
-
# app_profile = instance.app_profile
|
|
748
|
+
# app_profile = instance.app_profile "my-app-profile"
|
|
752
749
|
#
|
|
753
750
|
# if app_profile
|
|
754
751
|
# puts app_profile.name
|
|
@@ -776,7 +773,7 @@ module Google
|
|
|
776
773
|
#
|
|
777
774
|
# bigtable = Google::Cloud::Bigtable.new
|
|
778
775
|
#
|
|
779
|
-
# instance = bigtable.instance
|
|
776
|
+
# instance = bigtable.instance "my-instance"
|
|
780
777
|
#
|
|
781
778
|
# instance.app_profiles.all do |app_profile|
|
|
782
779
|
# puts app_profile.name
|
|
@@ -808,17 +805,17 @@ module Google
|
|
|
808
805
|
#
|
|
809
806
|
# bigtable = Google::Cloud::Bigtable.new
|
|
810
807
|
#
|
|
811
|
-
# instance = bigtable.instance
|
|
808
|
+
# instance = bigtable.instance "my-instance"
|
|
812
809
|
# policy = instance.policy
|
|
813
810
|
#
|
|
814
811
|
# @example Update the policy by passing a block.
|
|
815
812
|
# require "google/cloud/bigtable"
|
|
816
813
|
#
|
|
817
814
|
# bigtable = Google::Cloud::Bigtable.new
|
|
818
|
-
# instance = bigtable.instance
|
|
815
|
+
# instance = bigtable.instance "my-instance"
|
|
819
816
|
#
|
|
820
817
|
# instance.policy do |p|
|
|
821
|
-
# p.add
|
|
818
|
+
# p.add "roles/owner", "user:owner@example.com"
|
|
822
819
|
# end # 2 API calls
|
|
823
820
|
#
|
|
824
821
|
def policy
|
|
@@ -849,11 +846,11 @@ module Google
|
|
|
849
846
|
#
|
|
850
847
|
# bigtable = Google::Cloud::Bigtable.new
|
|
851
848
|
#
|
|
852
|
-
# instance = bigtable.instance
|
|
849
|
+
# instance = bigtable.instance "my-instance"
|
|
853
850
|
#
|
|
854
851
|
# policy = instance.policy
|
|
855
|
-
# policy.add
|
|
856
|
-
# updated_policy = instance.update_policy
|
|
852
|
+
# policy.add "roles/owner", "user:owner@example.com"
|
|
853
|
+
# updated_policy = instance.update_policy policy
|
|
857
854
|
#
|
|
858
855
|
# puts updated_policy.roles
|
|
859
856
|
#
|
|
@@ -892,7 +889,7 @@ module Google
|
|
|
892
889
|
#
|
|
893
890
|
# bigtable = Google::Cloud::Bigtable.new
|
|
894
891
|
#
|
|
895
|
-
# instance = bigtable.instance
|
|
892
|
+
# instance = bigtable.instance "my-instance"
|
|
896
893
|
#
|
|
897
894
|
# permissions = instance.test_iam_permissions(
|
|
898
895
|
# "bigtable.instances.get",
|
|
@@ -33,14 +33,14 @@ module Google
|
|
|
33
33
|
# See {Google::Cloud::Bigtable::Table#check_and_mutate_row}
|
|
34
34
|
#
|
|
35
35
|
# @example
|
|
36
|
-
# entry = Google::Cloud::Bigtable::MutationEntry.new
|
|
37
|
-
# timestamp_micros = (Time.now.to_f *
|
|
36
|
+
# entry = Google::Cloud::Bigtable::MutationEntry.new "user-1"
|
|
37
|
+
# timestamp_micros = (Time.now.to_f * 1_000_000).round(-3)
|
|
38
38
|
# entry.set_cell(
|
|
39
39
|
# "cf1", "fiel01", "XYZ", timestamp: timestamp_micros
|
|
40
40
|
# ).delete_cells(
|
|
41
41
|
# "cf2",
|
|
42
42
|
# "field02",
|
|
43
|
-
# timestamp_from: timestamp_micros -
|
|
43
|
+
# timestamp_from: timestamp_micros - 5_000_000,
|
|
44
44
|
# timestamp_to: timestamp_micros
|
|
45
45
|
# ).delete_from_family("cf3").delete_from_row
|
|
46
46
|
#
|
|
@@ -48,10 +48,10 @@ module Google
|
|
|
48
48
|
# require "google/cloud/bigtable"
|
|
49
49
|
#
|
|
50
50
|
# bigtable = Google::Cloud::Bigtable.new
|
|
51
|
-
# table = bigtable.table
|
|
51
|
+
# table = bigtable.table "my-instance", "my-table"
|
|
52
52
|
#
|
|
53
|
-
# entry = table.new_mutation_entry
|
|
54
|
-
# timestamp_micros = (Time.now.to_f *
|
|
53
|
+
# entry = table.new_mutation_entry "user-1"
|
|
54
|
+
# timestamp_micros = (Time.now.to_f * 1_000_000).round(-3)
|
|
55
55
|
# entry.set_cell(
|
|
56
56
|
# "cf1", "fiel01", "XYZ", timestamp: timestamp_micros
|
|
57
57
|
# )
|
|
@@ -101,16 +101,16 @@ module Google
|
|
|
101
101
|
# @return [MutationEntry] `self` object of entry for chaining.
|
|
102
102
|
#
|
|
103
103
|
# @example
|
|
104
|
-
# entry = Google::Cloud::Bigtable::MutationEntry.new
|
|
105
|
-
# entry.set_cell
|
|
104
|
+
# entry = Google::Cloud::Bigtable::MutationEntry.new "user-1"
|
|
105
|
+
# entry.set_cell "cf1", "field01", "XYZ"
|
|
106
106
|
#
|
|
107
107
|
# @example With timestamp.
|
|
108
|
-
# entry = Google::Cloud::Bigtable::MutationEntry.new
|
|
108
|
+
# entry = Google::Cloud::Bigtable::MutationEntry.new "user-1"
|
|
109
109
|
# entry.set_cell(
|
|
110
110
|
# "cf1",
|
|
111
111
|
# "field1",
|
|
112
112
|
# "XYZ",
|
|
113
|
-
# timestamp: (Time.now.to_f *
|
|
113
|
+
# timestamp: (Time.now.to_f * 1_000_000).round(-3) # microseconds
|
|
114
114
|
# )
|
|
115
115
|
#
|
|
116
116
|
def set_cell family, qualifier, value, timestamp: nil
|
|
@@ -158,25 +158,25 @@ module Google
|
|
|
158
158
|
# @return [MutationEntry] `self` object of entry for chaining.
|
|
159
159
|
#
|
|
160
160
|
# @example Without timestamp range.
|
|
161
|
-
# entry = Google::Cloud::Bigtable::MutationEntry.new
|
|
162
|
-
# entry.delete_cells
|
|
161
|
+
# entry = Google::Cloud::Bigtable::MutationEntry.new "user-1"
|
|
162
|
+
# entry.delete_cells "cf1", "field1"
|
|
163
163
|
#
|
|
164
164
|
# @example With timestamp range.
|
|
165
|
-
# entry = Google::Cloud::Bigtable::MutationEntry.new
|
|
166
|
-
# timestamp_micros = (Time.now.to_f *
|
|
165
|
+
# entry = Google::Cloud::Bigtable::MutationEntry.new "user-1"
|
|
166
|
+
# timestamp_micros = (Time.now.to_f * 1_000_000).round(-3)
|
|
167
167
|
# entry.delete_cells(
|
|
168
168
|
# "cf1",
|
|
169
169
|
# "field1",
|
|
170
|
-
# timestamp_from: timestamp_micros -
|
|
170
|
+
# timestamp_from: timestamp_micros - 5_000_000,
|
|
171
171
|
# timestamp_to: timestamp_micros
|
|
172
172
|
# )
|
|
173
173
|
# @example With timestamp range with lower boundary only.
|
|
174
|
-
# entry = Google::Cloud::Bigtable::MutationEntry.new
|
|
175
|
-
# timestamp_micros = (Time.now.to_f *
|
|
174
|
+
# entry = Google::Cloud::Bigtable::MutationEntry.new "user-1"
|
|
175
|
+
# timestamp_micros = (Time.now.to_f * 1_000_000).round(-3)
|
|
176
176
|
# entry.delete_cells(
|
|
177
177
|
# "cf1",
|
|
178
178
|
# "field1",
|
|
179
|
-
# timestamp_from: timestamp_micros -
|
|
179
|
+
# timestamp_from: timestamp_micros - 5_000_000
|
|
180
180
|
# )
|
|
181
181
|
#
|
|
182
182
|
def delete_cells family, qualifier, timestamp_from: nil, timestamp_to: nil
|
|
@@ -203,8 +203,8 @@ module Google
|
|
|
203
203
|
# @return [MutationEntry] `self` object of entry for chaining.
|
|
204
204
|
#
|
|
205
205
|
# @example
|
|
206
|
-
# entry = Google::Cloud::Bigtable::MutationEntry.new
|
|
207
|
-
# entry.delete_from_family
|
|
206
|
+
# entry = Google::Cloud::Bigtable::MutationEntry.new "user-1"
|
|
207
|
+
# entry.delete_from_family "cf1"
|
|
208
208
|
#
|
|
209
209
|
def delete_from_family family
|
|
210
210
|
@mutations << Google::Cloud::Bigtable::V2::Mutation.new(delete_from_family: { family_name: family })
|
|
@@ -219,7 +219,7 @@ module Google
|
|
|
219
219
|
# @return [MutationEntry] `self` object of entry for chaining.
|
|
220
220
|
#
|
|
221
221
|
# @example
|
|
222
|
-
# entry = Google::Cloud::Bigtable::MutationEntry.new
|
|
222
|
+
# entry = Google::Cloud::Bigtable::MutationEntry.new "user-1"
|
|
223
223
|
# entry.delete_from_row
|
|
224
224
|
#
|
|
225
225
|
def delete_from_row
|
|
@@ -50,28 +50,28 @@ module Google
|
|
|
50
50
|
#
|
|
51
51
|
# bigtable = Google::Cloud::Bigtable.new
|
|
52
52
|
#
|
|
53
|
-
# table = bigtable.table
|
|
53
|
+
# table = bigtable.table "my-instance", "my-table"
|
|
54
54
|
#
|
|
55
|
-
# entry = table.new_mutation_entry
|
|
56
|
-
# entry.set_cell
|
|
57
|
-
# table.mutate_row
|
|
55
|
+
# entry = table.new_mutation_entry "user-1"
|
|
56
|
+
# entry.set_cell "cf1", "field1", "XYZ"
|
|
57
|
+
# table.mutate_row entry
|
|
58
58
|
#
|
|
59
59
|
# @example Multiple mutations on row.
|
|
60
60
|
# require "google/cloud/bigtable"
|
|
61
61
|
#
|
|
62
62
|
# bigtable = Google::Cloud::Bigtable.new
|
|
63
63
|
#
|
|
64
|
-
# table = bigtable.table
|
|
64
|
+
# table = bigtable.table "my-instance", "my-table"
|
|
65
65
|
#
|
|
66
|
-
# entry = table.new_mutation_entry
|
|
66
|
+
# entry = table.new_mutation_entry "user-1"
|
|
67
67
|
# entry.set_cell(
|
|
68
68
|
# "cf1",
|
|
69
69
|
# "field1",
|
|
70
70
|
# "XYZ",
|
|
71
|
-
# timestamp: (Time.now.to_f *
|
|
72
|
-
# ).delete_cells
|
|
71
|
+
# timestamp: (Time.now.to_f * 1_000_000).round(-3) # microseconds
|
|
72
|
+
# ).delete_cells "cf2", "field02"
|
|
73
73
|
#
|
|
74
|
-
# table.mutate_row
|
|
74
|
+
# table.mutate_row entry
|
|
75
75
|
#
|
|
76
76
|
def mutate_row entry
|
|
77
77
|
service.mutate_row path, entry.row_key, entry.mutations, app_profile_id: @app_profile_id
|
|
@@ -96,12 +96,12 @@ module Google
|
|
|
96
96
|
#
|
|
97
97
|
# bigtable = Google::Cloud::Bigtable.new
|
|
98
98
|
#
|
|
99
|
-
# table = bigtable.table
|
|
99
|
+
# table = bigtable.table "my-instance", "my-table"
|
|
100
100
|
#
|
|
101
101
|
# entries = []
|
|
102
102
|
# entries << table.new_mutation_entry("row-1").set_cell("cf1", "field1", "XYZ")
|
|
103
103
|
# entries << table.new_mutation_entry("row-2").set_cell("cf1", "field1", "ABC")
|
|
104
|
-
# responses = table.mutate_rows
|
|
104
|
+
# responses = table.mutate_rows entries
|
|
105
105
|
#
|
|
106
106
|
# responses.each do |response|
|
|
107
107
|
# puts response.status.description
|
|
@@ -131,15 +131,15 @@ module Google
|
|
|
131
131
|
# require "google/cloud/bigtable"
|
|
132
132
|
#
|
|
133
133
|
# bigtable = Google::Cloud::Bigtable.new
|
|
134
|
-
# table = bigtable.table
|
|
134
|
+
# table = bigtable.table "my-instance", "my-table"
|
|
135
135
|
#
|
|
136
|
-
# rule_1 = table.new_read_modify_write_rule
|
|
137
|
-
# rule_1.append
|
|
136
|
+
# rule_1 = table.new_read_modify_write_rule "cf", "field01"
|
|
137
|
+
# rule_1.append "append-xyz"
|
|
138
138
|
#
|
|
139
|
-
# rule_2 = table.new_read_modify_write_rule
|
|
140
|
-
# rule_2.increment
|
|
139
|
+
# rule_2 = table.new_read_modify_write_rule "cf", "field01"
|
|
140
|
+
# rule_2.increment 1
|
|
141
141
|
#
|
|
142
|
-
# row = table.read_modify_write_row
|
|
142
|
+
# row = table.read_modify_write_row "user01", [rule_1, rule_2]
|
|
143
143
|
#
|
|
144
144
|
# puts row.cells
|
|
145
145
|
#
|
|
@@ -147,11 +147,11 @@ module Google
|
|
|
147
147
|
# require "google/cloud/bigtable"
|
|
148
148
|
#
|
|
149
149
|
# bigtable = Google::Cloud::Bigtable.new
|
|
150
|
-
# table = bigtable.table
|
|
150
|
+
# table = bigtable.table "my-instance", "my-table"
|
|
151
151
|
#
|
|
152
152
|
# rule = table.new_read_modify_write_rule("cf", "field01").append("append-xyz")
|
|
153
153
|
#
|
|
154
|
-
# row = table.read_modify_write_row
|
|
154
|
+
# row = table.read_modify_write_row "user01", rule
|
|
155
155
|
#
|
|
156
156
|
# puts row.cells
|
|
157
157
|
#
|
|
@@ -214,19 +214,19 @@ module Google
|
|
|
214
214
|
# require "google/cloud/bigtable"
|
|
215
215
|
#
|
|
216
216
|
# bigtable = Google::Cloud::Bigtable.new
|
|
217
|
-
# table = bigtable.table
|
|
217
|
+
# table = bigtable.table "my-instance", "my-table"
|
|
218
218
|
#
|
|
219
|
-
# predicate_filter = Google::Cloud::Bigtable::RowFilter.key
|
|
219
|
+
# predicate_filter = Google::Cloud::Bigtable::RowFilter.key "user-10"
|
|
220
220
|
# on_match_mutations = Google::Cloud::Bigtable::MutationEntry.new
|
|
221
221
|
# on_match_mutations.set_cell(
|
|
222
222
|
# "cf1",
|
|
223
223
|
# "field1",
|
|
224
224
|
# "XYZ",
|
|
225
|
-
# timestamp: (Time.now.to_f *
|
|
226
|
-
# ).delete_cells
|
|
225
|
+
# timestamp: (Time.now.to_f * 1_000_000).round(-3) # microseconds
|
|
226
|
+
# ).delete_cells "cf2", "field02"
|
|
227
227
|
#
|
|
228
228
|
# otherwise_mutations = Google::Cloud::Bigtable::MutationEntry.new
|
|
229
|
-
# otherwise_mutations.delete_from_family
|
|
229
|
+
# otherwise_mutations.delete_from_family "cf3"
|
|
230
230
|
#
|
|
231
231
|
# predicate_matched = table.check_and_mutate_row(
|
|
232
232
|
# "user01",
|
|
@@ -264,9 +264,9 @@ module Google
|
|
|
264
264
|
# require "google/cloud/bigtable"
|
|
265
265
|
#
|
|
266
266
|
# bigtable = Google::Cloud::Bigtable.new
|
|
267
|
-
# table = bigtable.table
|
|
267
|
+
# table = bigtable.table "my-instance", "my-table"
|
|
268
268
|
#
|
|
269
|
-
# entry = table.new_mutation_entry
|
|
269
|
+
# entry = table.new_mutation_entry "row-key-1"
|
|
270
270
|
#
|
|
271
271
|
# # Without row key
|
|
272
272
|
# entry = table.new_mutation_entry
|
|
@@ -289,17 +289,17 @@ module Google
|
|
|
289
289
|
# require "google/cloud/bigtable"
|
|
290
290
|
#
|
|
291
291
|
# bigtable = Google::Cloud::Bigtable.new
|
|
292
|
-
# table = bigtable.table
|
|
293
|
-
# rule = table.new_read_modify_write_rule
|
|
294
|
-
# rule.append
|
|
292
|
+
# table = bigtable.table "my-instance", "my-table"
|
|
293
|
+
# rule = table.new_read_modify_write_rule "cf", "qualifier-1"
|
|
294
|
+
# rule.append "append-xyz"
|
|
295
295
|
#
|
|
296
296
|
# @example Create rule to increment qualifier value.
|
|
297
297
|
# require "google/cloud/bigtable"
|
|
298
298
|
#
|
|
299
299
|
# bigtable = Google::Cloud::Bigtable.new
|
|
300
|
-
# table = bigtable.table
|
|
301
|
-
# rule = table.new_read_modify_write_rule
|
|
302
|
-
# rule.increment
|
|
300
|
+
# table = bigtable.table "my-instance", "my-table"
|
|
301
|
+
# rule = table.new_read_modify_write_rule "cf", "qualifier-1"
|
|
302
|
+
# rule.increment 100
|
|
303
303
|
#
|
|
304
304
|
def new_read_modify_write_rule family, qualifier
|
|
305
305
|
Google::Cloud::Bigtable::ReadModifyWriteRule.new family, qualifier
|
|
@@ -323,12 +323,12 @@ module Google
|
|
|
323
323
|
#
|
|
324
324
|
# bigtable = Google::Cloud::Bigtable.new
|
|
325
325
|
#
|
|
326
|
-
# table = bigtable.table
|
|
326
|
+
# table = bigtable.table "my-instance", "my-table"
|
|
327
327
|
#
|
|
328
328
|
# entries = []
|
|
329
329
|
# entries << table.new_mutation_entry("row-1").set_cell("cf1", "field1", "XYZ")
|
|
330
330
|
# entries << table.new_mutation_entry("row-2").set_cell("cf1", "field1", "ABC")
|
|
331
|
-
# responses = table.mutate_rows
|
|
331
|
+
# responses = table.mutate_rows entries
|
|
332
332
|
#
|
|
333
333
|
# responses.each do |response|
|
|
334
334
|
# puts response.status.description
|
|
@@ -49,8 +49,8 @@ module Google
|
|
|
49
49
|
# instance = bigtable.instance "my-instance"
|
|
50
50
|
#
|
|
51
51
|
# policy = instance.policy
|
|
52
|
-
# policy.remove
|
|
53
|
-
# policy.add
|
|
52
|
+
# policy.remove "roles/owner", "user:owner@example.com"
|
|
53
|
+
# policy.add "roles/owner", "user:newowner@example.com"
|
|
54
54
|
# policy.roles["roles/viewer"] = ["allUsers"]
|
|
55
55
|
#
|
|
56
56
|
class Policy
|
|
@@ -85,7 +85,7 @@ module Google
|
|
|
85
85
|
# instance = bigtable.instance "my-instance"
|
|
86
86
|
#
|
|
87
87
|
# policy = instance.policy
|
|
88
|
-
# policy.add
|
|
88
|
+
# policy.add "roles/owner", "user:newowner@example.com"
|
|
89
89
|
#
|
|
90
90
|
def add role_name, member
|
|
91
91
|
role(role_name) << member
|
|
@@ -111,7 +111,7 @@ module Google
|
|
|
111
111
|
# instance = bigtable.instance "my-instance"
|
|
112
112
|
#
|
|
113
113
|
# policy = instance.policy
|
|
114
|
-
# policy.remove
|
|
114
|
+
# policy.remove "roles/owner", "user:newowner@example.com"
|
|
115
115
|
#
|
|
116
116
|
def remove role_name, member
|
|
117
117
|
role(role_name).delete member
|