google-cloud-bigtable 0.6.1 → 1.0.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 +4 -26
- data/CHANGELOG.md +85 -0
- data/CONTRIBUTING.md +1 -1
- data/OVERVIEW.md +388 -19
- data/lib/google-cloud-bigtable.rb +19 -22
- data/lib/google/bigtable/admin/v2/bigtable_table_admin_services_pb.rb +1 -1
- data/lib/google/bigtable/v2/bigtable_pb.rb +3 -0
- data/lib/google/bigtable/v2/bigtable_services_pb.rb +1 -1
- data/lib/google/cloud/bigtable.rb +11 -17
- data/lib/google/cloud/bigtable/admin.rb +1 -1
- data/lib/google/cloud/bigtable/admin/v2.rb +1 -1
- data/lib/google/cloud/bigtable/admin/v2/bigtable_table_admin_client.rb +1 -1
- data/lib/google/cloud/bigtable/admin/v2/doc/google/iam/v1/policy.rb +42 -21
- data/lib/google/cloud/bigtable/app_profile.rb +162 -96
- data/lib/google/cloud/bigtable/app_profile/job.rb +5 -8
- data/lib/google/cloud/bigtable/app_profile/list.rb +18 -12
- data/lib/google/cloud/bigtable/chunk_processor.rb +24 -36
- data/lib/google/cloud/bigtable/cluster.rb +45 -18
- data/lib/google/cloud/bigtable/cluster/job.rb +3 -7
- data/lib/google/cloud/bigtable/cluster/list.rb +22 -20
- data/lib/google/cloud/bigtable/column_family.rb +18 -231
- data/lib/google/cloud/bigtable/column_family_map.rb +426 -0
- data/lib/google/cloud/bigtable/column_range.rb +15 -7
- 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 +188 -69
- data/lib/google/cloud/bigtable/instance.rb +209 -189
- data/lib/google/cloud/bigtable/instance/cluster_map.rb +17 -13
- data/lib/google/cloud/bigtable/instance/job.rb +6 -5
- data/lib/google/cloud/bigtable/instance/list.rb +18 -13
- data/lib/google/cloud/bigtable/longrunning_job.rb +7 -1
- data/lib/google/cloud/bigtable/mutation_entry.rb +36 -39
- data/lib/google/cloud/bigtable/mutation_operations.rb +90 -73
- data/lib/google/cloud/bigtable/policy.rb +9 -5
- data/lib/google/cloud/bigtable/project.rb +87 -196
- data/lib/google/cloud/bigtable/read_modify_write_rule.rb +15 -10
- data/lib/google/cloud/bigtable/read_operations.rb +42 -59
- data/lib/google/cloud/bigtable/routing_policy.rb +172 -0
- data/lib/google/cloud/bigtable/row.rb +32 -21
- data/lib/google/cloud/bigtable/row_filter.rb +80 -35
- data/lib/google/cloud/bigtable/row_filter/chain_filter.rb +119 -68
- data/lib/google/cloud/bigtable/row_filter/condition_filter.rb +8 -2
- data/lib/google/cloud/bigtable/row_filter/interleave_filter.rb +117 -66
- data/lib/google/cloud/bigtable/row_filter/simple_filter.rb +24 -9
- data/lib/google/cloud/bigtable/row_range.rb +5 -0
- data/lib/google/cloud/bigtable/rows_mutator.rb +14 -21
- data/lib/google/cloud/bigtable/rows_reader.rb +23 -18
- data/lib/google/cloud/bigtable/sample_row_key.rb +6 -3
- data/lib/google/cloud/bigtable/service.rb +200 -253
- data/lib/google/cloud/bigtable/status.rb +76 -0
- data/lib/google/cloud/bigtable/table.rb +158 -262
- data/lib/google/cloud/bigtable/table/cluster_state.rb +17 -6
- data/lib/google/cloud/bigtable/table/list.rb +16 -9
- data/lib/google/cloud/bigtable/v2.rb +1 -1
- data/lib/google/cloud/bigtable/v2/bigtable_client.rb +12 -12
- data/lib/google/cloud/bigtable/v2/doc/google/bigtable/v2/bigtable.rb +16 -13
- data/lib/google/cloud/bigtable/value_range.rb +19 -13
- data/lib/google/cloud/bigtable/version.rb +1 -1
- metadata +67 -25
- data/lib/google/cloud/bigtable/table/column_family_map.rb +0 -70
@@ -18,6 +18,7 @@
|
|
18
18
|
module Google
|
19
19
|
module Cloud
|
20
20
|
module Bigtable
|
21
|
+
##
|
21
22
|
# # ColumnRange
|
22
23
|
#
|
23
24
|
# Specifies a contiguous range of column qualifiers.
|
@@ -49,15 +50,17 @@ module Google
|
|
49
50
|
# table.new_column_range("cf").between("user-001", "user-100")
|
50
51
|
#
|
51
52
|
class ColumnRange
|
53
|
+
##
|
52
54
|
# Create qualifier range instance.
|
53
55
|
#
|
54
56
|
# @param family [String] Column family name.
|
55
57
|
#
|
56
58
|
def initialize family
|
57
|
-
@grpc = Google::Bigtable::V2::ColumnRange.new
|
59
|
+
@grpc = Google::Bigtable::V2::ColumnRange.new family_name: family
|
58
60
|
end
|
59
61
|
|
60
|
-
|
62
|
+
##
|
63
|
+
# Gets the column family name.
|
61
64
|
#
|
62
65
|
# @return [String]
|
63
66
|
#
|
@@ -65,7 +68,8 @@ module Google
|
|
65
68
|
@grpc.family_name
|
66
69
|
end
|
67
70
|
|
68
|
-
|
71
|
+
##
|
72
|
+
# Sets the column family name.
|
69
73
|
#
|
70
74
|
# @param name [String] Column family name
|
71
75
|
#
|
@@ -73,7 +77,8 @@ module Google
|
|
73
77
|
@grpc.family_name = name
|
74
78
|
end
|
75
79
|
|
76
|
-
|
80
|
+
##
|
81
|
+
# Sets the column range with the lower bound.
|
77
82
|
#
|
78
83
|
# @param qualifier [String] Column qualifier name. Required
|
79
84
|
# @param inclusive [String] Lower bound flag. Inclusive/Exclusive.
|
@@ -105,7 +110,8 @@ module Google
|
|
105
110
|
self
|
106
111
|
end
|
107
112
|
|
108
|
-
|
113
|
+
##
|
114
|
+
# Sets the column range with the upper bound.
|
109
115
|
#
|
110
116
|
# @param qualifier [String] Column qualifier name. Required.
|
111
117
|
# @param inclusive [String] Upper bound flag. Inclusive/Exclusive.
|
@@ -137,7 +143,8 @@ module Google
|
|
137
143
|
self
|
138
144
|
end
|
139
145
|
|
140
|
-
|
146
|
+
##
|
147
|
+
# Sets the column range with the inclusive upper and lower bound.
|
141
148
|
#
|
142
149
|
# @param from_qualifier [String] Inclusive from qualifier. Required.
|
143
150
|
# @param to_qualifier [String] Inclusive to qualifier. Required.
|
@@ -155,7 +162,8 @@ module Google
|
|
155
162
|
from(from_qualifier).to(to_qualifier, inclusive: true)
|
156
163
|
end
|
157
164
|
|
158
|
-
|
165
|
+
##
|
166
|
+
# Sets the column range with the inclusive upper and the exclusive lower bound.
|
159
167
|
#
|
160
168
|
# @param from_qualifier [String] Inclusive from qualifier
|
161
169
|
# @param to_qualifier [String] Exclusive to qualifier
|
@@ -26,48 +26,56 @@ module Google
|
|
26
26
|
module Convert
|
27
27
|
module_function
|
28
28
|
|
29
|
+
##
|
29
30
|
# Convert number to protobuf duration.
|
30
31
|
#
|
31
32
|
# @param number [Float] Seconds with nano seconds
|
32
33
|
# @return [Google::Protobuf::Duration, nil]
|
34
|
+
#
|
33
35
|
def number_to_duration number
|
34
36
|
return unless number
|
35
37
|
|
36
38
|
Google::Protobuf::Duration.new(
|
37
39
|
seconds: number.to_i,
|
38
|
-
nanos:
|
40
|
+
nanos: (number.remainder(1) * 1_000_000_000).round
|
39
41
|
)
|
40
42
|
end
|
41
43
|
|
44
|
+
##
|
42
45
|
# Convert protobuf durations to float.
|
43
46
|
#
|
44
47
|
# @param duration [Google::Protobuf::Duration, nil]
|
45
48
|
# @return [Float, Integer, nil] Seconds with nano seconds
|
49
|
+
#
|
46
50
|
def duration_to_number duration
|
47
51
|
return unless duration
|
48
52
|
return duration.seconds if duration.nanos.zero?
|
49
53
|
|
50
|
-
duration.seconds + (duration.nanos /
|
54
|
+
duration.seconds + (duration.nanos / 1_000_000_000.0)
|
51
55
|
end
|
52
56
|
|
57
|
+
##
|
53
58
|
# Convert protobuf timestamp to Time object.
|
54
59
|
#
|
55
60
|
# @param timestamp [Google::Protobuf::Timestamp]
|
56
61
|
# @return [Time, nil]
|
62
|
+
#
|
57
63
|
def timestamp_to_time timestamp
|
58
64
|
return unless timestamp
|
59
65
|
|
60
|
-
Time.at
|
66
|
+
Time.at timestamp.seconds, timestamp.nanos / 1000.0
|
61
67
|
end
|
62
68
|
|
69
|
+
##
|
63
70
|
# Convert time to timestamp protobuf object.
|
64
71
|
#
|
65
72
|
# @param time [Time]
|
66
73
|
# @return [Google::Protobuf::Timestamp, nil]
|
74
|
+
#
|
67
75
|
def time_to_timestamp time
|
68
76
|
return unless time
|
69
77
|
|
70
|
-
Google::Protobuf::Timestamp.new
|
78
|
+
Google::Protobuf::Timestamp.new seconds: time.to_i, nanos: time.nsec
|
71
79
|
end
|
72
80
|
end
|
73
81
|
end
|
@@ -16,17 +16,20 @@
|
|
16
16
|
module Google
|
17
17
|
module Cloud
|
18
18
|
module Bigtable
|
19
|
+
##
|
19
20
|
# Invalid read row state error
|
20
21
|
class InvalidRowStateError < Google::Cloud::Error
|
22
|
+
##
|
21
23
|
# Invalid row chunk data
|
22
24
|
attr_reader :data
|
23
25
|
|
24
26
|
def initialize message, data = nil
|
25
|
-
super
|
27
|
+
super message
|
26
28
|
@data = data if data
|
27
29
|
end
|
28
30
|
end
|
29
31
|
|
32
|
+
##
|
30
33
|
# Row filter error.
|
31
34
|
class RowFilterError < Google::Cloud::Error
|
32
35
|
end
|
@@ -18,51 +18,49 @@
|
|
18
18
|
module Google
|
19
19
|
module Cloud
|
20
20
|
module Bigtable
|
21
|
+
##
|
21
22
|
# # GcRule
|
22
23
|
#
|
23
|
-
#
|
24
|
+
# A rule or rules for determining which cells to delete during garbage
|
25
|
+
# collection.
|
26
|
+
#
|
24
27
|
# Garbage collection (GC) executes opportunistically in the background,
|
25
|
-
# so it
|
26
|
-
# GC expression for its family.
|
28
|
+
# so it is possible for reads to return a cell even if it matches the
|
29
|
+
# active GC expression for its column family.
|
27
30
|
#
|
28
|
-
# NOTE: GC Rule can hold only one type at a time.
|
29
31
|
# GC Rule types:
|
30
|
-
# * `max_num_versions` -
|
31
|
-
#
|
32
|
-
#
|
33
|
-
#
|
34
|
-
#
|
35
|
-
#
|
36
|
-
#
|
37
|
-
#
|
38
|
-
#
|
39
|
-
#
|
40
|
-
#
|
41
|
-
#
|
42
|
-
# gc_rule.max_versions = 5
|
43
|
-
#
|
44
|
-
# @example Create GC rule instance with max age.
|
45
|
-
#
|
46
|
-
# gc_rule = Google::Cloud::Bigtable::GcRule.max_age(3)
|
32
|
+
# * `max_num_versions` - A garbage-collection rule that explicitly
|
33
|
+
# states the maximum number of cells to keep for all columns in a
|
34
|
+
# column family.
|
35
|
+
# * `max_age` - A garbage-collection rule based on the timestamp for
|
36
|
+
# each cell. With this type of garbage-collection rule, you set the
|
37
|
+
# time to live (TTL) for data. Cloud Bigtable looks at each column
|
38
|
+
# family during garbage collection and removes any cells that have
|
39
|
+
# expired.
|
40
|
+
# * `union` - A union garbage-collection policy will remove all data
|
41
|
+
# matching *any* of a set of given rules.
|
42
|
+
# * `intersection` - An intersection garbage-collection policy will
|
43
|
+
# remove all data matching *all* of a set of given rules.
|
47
44
|
#
|
48
|
-
#
|
49
|
-
#
|
45
|
+
# @example Create a table with column families.
|
46
|
+
# require "google/cloud/bigtable"
|
50
47
|
#
|
51
|
-
#
|
48
|
+
# bigtable = Google::Cloud::Bigtable.new
|
52
49
|
#
|
53
|
-
#
|
54
|
-
#
|
50
|
+
# table = bigtable.create_table("my-instance", "my-table") do |cfm|
|
51
|
+
# cfm.add("cf1", gc_rule: Google::Cloud::Bigtable::GcRule.max_versions(5))
|
52
|
+
# cfm.add("cf2", gc_rule: Google::Cloud::Bigtable::GcRule.max_age(600))
|
55
53
|
#
|
56
|
-
#
|
57
|
-
#
|
54
|
+
# gc_rule = Google::Cloud::Bigtable::GcRule.union(
|
55
|
+
# Google::Cloud::Bigtable::GcRule.max_age(1800),
|
56
|
+
# Google::Cloud::Bigtable::GcRule.max_versions(3)
|
57
|
+
# )
|
58
|
+
# cfm.add("cf3", gc_rule: gc_rule)
|
59
|
+
# end
|
58
60
|
#
|
59
|
-
#
|
60
|
-
#
|
61
|
-
#
|
62
|
-
# gc_rule = Google::Cloud::Bigtable::GcRule.intersection(max_versions_gc_rule)
|
63
|
-
#
|
64
|
-
# # Change intersection GC rule
|
65
|
-
# gc_rule.intersection = Google::Cloud::Bigtable::GcRule.max_age(600)
|
61
|
+
# puts table.column_families["cf1"].gc_rule.max_versions
|
62
|
+
# puts table.column_families["cf2"].gc_rule.max_age
|
63
|
+
# puts table.column_families["cf3"].gc_rule.union
|
66
64
|
#
|
67
65
|
class GcRule
|
68
66
|
# @private
|
@@ -74,7 +72,9 @@ module Google
|
|
74
72
|
@grpc = grpc || Google::Bigtable::Admin::V2::GcRule.new
|
75
73
|
end
|
76
74
|
|
77
|
-
|
75
|
+
##
|
76
|
+
# Sets a garbage-collection rule that explicitly states the maximum
|
77
|
+
# number of cells to keep for all columns in a column family.
|
78
78
|
#
|
79
79
|
# @param versions [Integer]
|
80
80
|
#
|
@@ -82,75 +82,156 @@ module Google
|
|
82
82
|
@grpc.max_num_versions = versions
|
83
83
|
end
|
84
84
|
|
85
|
-
|
85
|
+
##
|
86
|
+
# Gets the garbage-collection rule that explicitly states the maximum
|
87
|
+
# number of cells to keep for all columns in a column family.
|
86
88
|
#
|
87
89
|
# @return [Integer, nil]
|
88
90
|
#
|
91
|
+
# @example
|
92
|
+
# require "google/cloud/bigtable"
|
93
|
+
#
|
94
|
+
# bigtable = Google::Cloud::Bigtable.new
|
95
|
+
#
|
96
|
+
# table = bigtable.create_table("my-instance", "my-table") do |cfm|
|
97
|
+
# cfm.add("cf1", gc_rule: Google::Cloud::Bigtable::GcRule.max_versions(5))
|
98
|
+
# end
|
99
|
+
#
|
100
|
+
# puts table.column_families["cf1"].gc_rule.max_versions
|
101
|
+
#
|
89
102
|
def max_versions
|
90
103
|
@grpc.max_num_versions
|
91
104
|
end
|
92
105
|
|
93
|
-
|
94
|
-
#
|
95
|
-
#
|
106
|
+
##
|
107
|
+
# Sets a garbage-collection rule based on the timestamp for each cell.
|
108
|
+
# With this type of garbage-collection rule, you set the time to live
|
109
|
+
# (TTL) for data. Cloud Bigtable looks at each column family during
|
110
|
+
# garbage collection and removes any cells that have expired.
|
96
111
|
#
|
97
|
-
# @param age [
|
112
|
+
# @param age [Numeric] Max age in seconds. Values must be at least one
|
113
|
+
# millisecond, and will be truncated to microsecond granularity.
|
98
114
|
#
|
99
115
|
def max_age= age
|
100
|
-
@grpc.max_age = Convert.number_to_duration
|
116
|
+
@grpc.max_age = Convert.number_to_duration age
|
101
117
|
end
|
102
118
|
|
103
|
-
|
119
|
+
##
|
120
|
+
# Gets the garbage-collection rule based on the timestamp for each cell.
|
121
|
+
# With this type of garbage-collection rule, you set the time to live
|
122
|
+
# (TTL) for data. Cloud Bigtable looks at each column family during
|
123
|
+
# garbage collection and removes any cells that have expired.
|
104
124
|
#
|
105
|
-
# @return [
|
125
|
+
# @return [Numeric, nil] Max age in seconds.
|
126
|
+
#
|
127
|
+
# @example
|
128
|
+
# require "google/cloud/bigtable"
|
129
|
+
#
|
130
|
+
# bigtable = Google::Cloud::Bigtable.new
|
131
|
+
#
|
132
|
+
# table = bigtable.create_table("my-instance", "my-table") do |cfm|
|
133
|
+
# cfm.add("cf1", gc_rule: Google::Cloud::Bigtable::GcRule.max_age(600))
|
134
|
+
# end
|
135
|
+
#
|
136
|
+
# puts table.column_families["cf1"].gc_rule.max_age
|
106
137
|
#
|
107
138
|
def max_age
|
108
|
-
|
139
|
+
Convert.duration_to_number @grpc.max_age
|
109
140
|
end
|
110
141
|
|
111
|
-
|
142
|
+
##
|
143
|
+
# Sets the intersection rules collection for this GcRule.
|
112
144
|
#
|
113
145
|
# @param rules [Array<Google::Cloud::Bigtable::GcRule>]
|
114
146
|
# List of GcRule with nested rules.
|
115
147
|
#
|
116
148
|
def intersection= rules
|
117
|
-
@grpc.intersection =
|
118
|
-
Google::Bigtable::Admin::V2::GcRule::Intersection.new(
|
119
|
-
rules: rules.map(&:to_grpc)
|
120
|
-
)
|
149
|
+
@grpc.intersection = Google::Bigtable::Admin::V2::GcRule::Intersection.new rules: rules.map(&:to_grpc)
|
121
150
|
end
|
122
151
|
|
123
|
-
|
152
|
+
##
|
153
|
+
#
|
154
|
+
# Gets the intersection rules collection for this GcRule.
|
155
|
+
#
|
156
|
+
# @return [Array<Google::Cloud::Bigtable::GcRule>, nil]
|
124
157
|
#
|
125
|
-
# @
|
158
|
+
# @example
|
159
|
+
# require "google/cloud/bigtable"
|
160
|
+
#
|
161
|
+
# bigtable = Google::Cloud::Bigtable.new
|
162
|
+
#
|
163
|
+
# table = bigtable.create_table("my-instance", "my-table") do |cfm|
|
164
|
+
# gc_rule = Google::Cloud::Bigtable::GcRule.intersection(
|
165
|
+
# Google::Cloud::Bigtable::GcRule.max_age(1800),
|
166
|
+
# Google::Cloud::Bigtable::GcRule.max_versions(3)
|
167
|
+
# )
|
168
|
+
# cfm.add("cf1", gc_rule: gc_rule)
|
169
|
+
# end
|
170
|
+
#
|
171
|
+
# puts table.column_families["cf1"].gc_rule.intersection
|
126
172
|
#
|
127
173
|
def intersection
|
128
|
-
@grpc.intersection
|
174
|
+
return nil unless @grpc.intersection
|
175
|
+
@grpc.intersection.rules.map do |gc_rule_grpc|
|
176
|
+
self.class.from_grpc gc_rule_grpc
|
177
|
+
end
|
129
178
|
end
|
130
179
|
|
131
|
-
|
180
|
+
##
|
181
|
+
# Sets the union rules collection for this GcRule. A union
|
182
|
+
# garbage-collection policy will remove all data matching *any* of its
|
183
|
+
# set of given rules.
|
132
184
|
#
|
133
185
|
# @param rules [Array<Google::Cloud::Bigtable::GcRule>]
|
134
186
|
# List of GcRule with nested rules.
|
135
187
|
#
|
136
188
|
def union= rules
|
137
|
-
@grpc.union = Google::Bigtable::Admin::V2::GcRule::Union.new(
|
138
|
-
rules: rules.map(&:to_grpc)
|
139
|
-
)
|
189
|
+
@grpc.union = Google::Bigtable::Admin::V2::GcRule::Union.new rules: rules.map(&:to_grpc)
|
140
190
|
end
|
141
191
|
|
142
|
-
|
192
|
+
##
|
193
|
+
# Gets the union rules collection for this GcRule. A union
|
194
|
+
# garbage-collection policy will remove all data matching *any* of its
|
195
|
+
# set of given rules.
|
196
|
+
#
|
197
|
+
# @return [Array<Google::Cloud::Bigtable::GcRule>, nil]
|
198
|
+
#
|
199
|
+
# @example
|
200
|
+
# require "google/cloud/bigtable"
|
143
201
|
#
|
144
|
-
#
|
202
|
+
# bigtable = Google::Cloud::Bigtable.new
|
203
|
+
#
|
204
|
+
# table = bigtable.create_table("my-instance", "my-table") do |cfm|
|
205
|
+
# gc_rule = Google::Cloud::Bigtable::GcRule.union(
|
206
|
+
# Google::Cloud::Bigtable::GcRule.max_age(1800),
|
207
|
+
# Google::Cloud::Bigtable::GcRule.max_versions(3)
|
208
|
+
# )
|
209
|
+
# cfm.add("cf1", gc_rule: gc_rule)
|
210
|
+
# end
|
211
|
+
#
|
212
|
+
# puts table.column_families["cf1"].gc_rule.union
|
145
213
|
#
|
146
214
|
def union
|
147
|
-
@grpc.union
|
215
|
+
return nil unless @grpc.union
|
216
|
+
@grpc.union.rules.map do |gc_rule_grpc|
|
217
|
+
self.class.from_grpc gc_rule_grpc
|
218
|
+
end
|
148
219
|
end
|
149
220
|
|
150
|
-
|
221
|
+
##
|
222
|
+
# Creates a GcRule instance with max number of versions.
|
151
223
|
#
|
152
224
|
# @param versions [Integer] Max number of versions
|
153
|
-
# @return [Google::Bigtable::
|
225
|
+
# @return [Google::Cloud::Bigtable::GcRule]
|
226
|
+
#
|
227
|
+
# @example
|
228
|
+
# require "google/cloud/bigtable"
|
229
|
+
#
|
230
|
+
# bigtable = Google::Cloud::Bigtable.new
|
231
|
+
#
|
232
|
+
# table = bigtable.create_table("my-instance", "my-table") do |cfm|
|
233
|
+
# cfm.add("cf1", gc_rule: Google::Cloud::Bigtable::GcRule.max_versions(5))
|
234
|
+
# end
|
154
235
|
#
|
155
236
|
def self.max_versions versions
|
156
237
|
new.tap do |gc_rule|
|
@@ -158,10 +239,20 @@ module Google
|
|
158
239
|
end
|
159
240
|
end
|
160
241
|
|
161
|
-
|
242
|
+
##
|
243
|
+
# Creates a GcRule instance with max age.
|
162
244
|
#
|
163
245
|
# @param age [Integer] Max age in seconds.
|
164
|
-
# @return [Google::Bigtable::
|
246
|
+
# @return [Google::Cloud::Bigtable::GcRule]
|
247
|
+
#
|
248
|
+
# @example
|
249
|
+
# require "google/cloud/bigtable"
|
250
|
+
#
|
251
|
+
# bigtable = Google::Cloud::Bigtable.new
|
252
|
+
#
|
253
|
+
# table = bigtable.create_table("my-instance", "my-table") do |cfm|
|
254
|
+
# cfm.add("cf1", gc_rule: Google::Cloud::Bigtable::GcRule.max_age(600))
|
255
|
+
# end
|
165
256
|
#
|
166
257
|
def self.max_age age
|
167
258
|
new.tap do |gc_rule|
|
@@ -169,11 +260,25 @@ module Google
|
|
169
260
|
end
|
170
261
|
end
|
171
262
|
|
172
|
-
|
263
|
+
##
|
264
|
+
# Creates a union GcRule instance.
|
173
265
|
#
|
174
266
|
# @param rules [Google::Cloud::Bigtable::GcRule, Array<Google::Cloud::Bigtable::GcRule>]
|
175
267
|
# List of GcRule with nested rules.
|
176
|
-
# @return [Google::Bigtable::
|
268
|
+
# @return [Google::Cloud::Bigtable::GcRule]
|
269
|
+
#
|
270
|
+
# @example
|
271
|
+
# require "google/cloud/bigtable"
|
272
|
+
#
|
273
|
+
# bigtable = Google::Cloud::Bigtable.new
|
274
|
+
#
|
275
|
+
# table = bigtable.create_table("my-instance", "my-table") do |cfm|
|
276
|
+
# gc_rule = Google::Cloud::Bigtable::GcRule.union(
|
277
|
+
# Google::Cloud::Bigtable::GcRule.max_age(1800),
|
278
|
+
# Google::Cloud::Bigtable::GcRule.max_versions(3)
|
279
|
+
# )
|
280
|
+
# cfm.add("cf1", gc_rule: gc_rule)
|
281
|
+
# end
|
177
282
|
#
|
178
283
|
def self.union *rules
|
179
284
|
new.tap do |gc_rule|
|
@@ -181,11 +286,25 @@ module Google
|
|
181
286
|
end
|
182
287
|
end
|
183
288
|
|
184
|
-
|
289
|
+
##
|
290
|
+
# Creates a intersection GCRule instance.
|
185
291
|
#
|
186
292
|
# @param rules [Google::Cloud::Bigtable::GcRule, Array<Google::Cloud::Bigtable::GcRule>]
|
187
293
|
# List of GcRule with nested rules.
|
188
|
-
# @return [Google::Bigtable::
|
294
|
+
# @return [Google::Cloud::Bigtable::GcRule]
|
295
|
+
#
|
296
|
+
# @example
|
297
|
+
# require "google/cloud/bigtable"
|
298
|
+
#
|
299
|
+
# bigtable = Google::Cloud::Bigtable.new
|
300
|
+
#
|
301
|
+
# table = bigtable.create_table("my-instance", "my-table") do |cfm|
|
302
|
+
# gc_rule = Google::Cloud::Bigtable::GcRule.intersection(
|
303
|
+
# Google::Cloud::Bigtable::GcRule.max_age(1800),
|
304
|
+
# Google::Cloud::Bigtable::GcRule.max_versions(3)
|
305
|
+
# )
|
306
|
+
# cfm.add("cf1", gc_rule: gc_rule)
|
307
|
+
# end
|
189
308
|
#
|
190
309
|
def self.intersection *rules
|
191
310
|
new.tap do |gc_rule|
|
@@ -207,7 +326,7 @@ module Google
|
|
207
326
|
# @param grpc [Google::Bigtable::Admin::V2::GcRule]
|
208
327
|
# @return [Google::Cloud::Bigtable::GcRule]
|
209
328
|
def self.from_grpc grpc
|
210
|
-
new
|
329
|
+
new grpc
|
211
330
|
end
|
212
331
|
end
|
213
332
|
end
|