google-cloud-bigtable 0.1.0

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.
Files changed (88) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +10 -0
  3. data/LICENSE +201 -0
  4. data/README.md +65 -0
  5. data/lib/google/bigtable/admin/v2/bigtable_instance_admin_pb.rb +139 -0
  6. data/lib/google/bigtable/admin/v2/bigtable_instance_admin_services_pb.rb +85 -0
  7. data/lib/google/bigtable/admin/v2/bigtable_table_admin_pb.rb +137 -0
  8. data/lib/google/bigtable/admin/v2/bigtable_table_admin_services_pb.rb +117 -0
  9. data/lib/google/bigtable/admin/v2/common_pb.rb +24 -0
  10. data/lib/google/bigtable/admin/v2/instance_pb.rb +72 -0
  11. data/lib/google/bigtable/admin/v2/table_pb.rb +88 -0
  12. data/lib/google/bigtable/v2/bigtable_pb.rb +109 -0
  13. data/lib/google/bigtable/v2/bigtable_services_pb.rb +67 -0
  14. data/lib/google/bigtable/v2/data_pb.rb +155 -0
  15. data/lib/google/cloud/bigtable/admin/credentials.rb +26 -0
  16. data/lib/google/cloud/bigtable/admin/v2/bigtable_instance_admin_client.rb +1417 -0
  17. data/lib/google/cloud/bigtable/admin/v2/bigtable_instance_admin_client_config.json +123 -0
  18. data/lib/google/cloud/bigtable/admin/v2/bigtable_table_admin_client.rb +1079 -0
  19. data/lib/google/cloud/bigtable/admin/v2/bigtable_table_admin_client_config.json +109 -0
  20. data/lib/google/cloud/bigtable/admin/v2/credentials.rb +50 -0
  21. data/lib/google/cloud/bigtable/admin/v2/doc/google/bigtable/admin/v2/bigtable_instance_admin.rb +279 -0
  22. data/lib/google/cloud/bigtable/admin/v2/doc/google/bigtable/admin/v2/bigtable_table_admin.rb +353 -0
  23. data/lib/google/cloud/bigtable/admin/v2/doc/google/bigtable/admin/v2/instance.rb +194 -0
  24. data/lib/google/cloud/bigtable/admin/v2/doc/google/bigtable/admin/v2/table.rb +209 -0
  25. data/lib/google/cloud/bigtable/admin/v2/doc/google/iam/v1/iam_policy.rb +62 -0
  26. data/lib/google/cloud/bigtable/admin/v2/doc/google/iam/v1/policy.rb +127 -0
  27. data/lib/google/cloud/bigtable/admin/v2/doc/google/longrunning/operations.rb +92 -0
  28. data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/any.rb +124 -0
  29. data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/duration.rb +90 -0
  30. data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/empty.rb +28 -0
  31. data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/field_mask.rb +223 -0
  32. data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/timestamp.rb +106 -0
  33. data/lib/google/cloud/bigtable/admin/v2/doc/google/rpc/status.rb +83 -0
  34. data/lib/google/cloud/bigtable/admin/v2.rb +200 -0
  35. data/lib/google/cloud/bigtable/admin.rb +196 -0
  36. data/lib/google/cloud/bigtable/app_profile/job.rb +102 -0
  37. data/lib/google/cloud/bigtable/app_profile/list.rb +159 -0
  38. data/lib/google/cloud/bigtable/app_profile.rb +373 -0
  39. data/lib/google/cloud/bigtable/chunk_processor.rb +253 -0
  40. data/lib/google/cloud/bigtable/cluster/job.rb +92 -0
  41. data/lib/google/cloud/bigtable/cluster/list.rb +169 -0
  42. data/lib/google/cloud/bigtable/cluster.rb +264 -0
  43. data/lib/google/cloud/bigtable/column_family.rb +280 -0
  44. data/lib/google/cloud/bigtable/column_range.rb +186 -0
  45. data/lib/google/cloud/bigtable/convert.rb +75 -0
  46. data/lib/google/cloud/bigtable/credentials.rb +24 -0
  47. data/lib/google/cloud/bigtable/errors.rb +35 -0
  48. data/lib/google/cloud/bigtable/gc_rule.rb +215 -0
  49. data/lib/google/cloud/bigtable/instance/cluster_map.rb +70 -0
  50. data/lib/google/cloud/bigtable/instance/job.rb +97 -0
  51. data/lib/google/cloud/bigtable/instance/list.rb +159 -0
  52. data/lib/google/cloud/bigtable/instance.rb +921 -0
  53. data/lib/google/cloud/bigtable/longrunning_job.rb +105 -0
  54. data/lib/google/cloud/bigtable/mutation_entry.rb +244 -0
  55. data/lib/google/cloud/bigtable/mutation_operations.rb +338 -0
  56. data/lib/google/cloud/bigtable/policy.rb +163 -0
  57. data/lib/google/cloud/bigtable/project.rb +580 -0
  58. data/lib/google/cloud/bigtable/read_modify_write_rule.rb +129 -0
  59. data/lib/google/cloud/bigtable/read_operations.rb +345 -0
  60. data/lib/google/cloud/bigtable/row.rb +125 -0
  61. data/lib/google/cloud/bigtable/row_filter/chain_filter.rb +539 -0
  62. data/lib/google/cloud/bigtable/row_filter/condition_filter.rb +108 -0
  63. data/lib/google/cloud/bigtable/row_filter/interleave_filter.rb +570 -0
  64. data/lib/google/cloud/bigtable/row_filter/simple_filter.rb +273 -0
  65. data/lib/google/cloud/bigtable/row_filter.rb +593 -0
  66. data/lib/google/cloud/bigtable/row_range.rb +174 -0
  67. data/lib/google/cloud/bigtable/rows_mutator.rb +120 -0
  68. data/lib/google/cloud/bigtable/rows_reader.rb +196 -0
  69. data/lib/google/cloud/bigtable/sample_row_key.rb +82 -0
  70. data/lib/google/cloud/bigtable/service.rb +817 -0
  71. data/lib/google/cloud/bigtable/table/cluster_state.rb +93 -0
  72. data/lib/google/cloud/bigtable/table/column_family_map.rb +68 -0
  73. data/lib/google/cloud/bigtable/table/list.rb +147 -0
  74. data/lib/google/cloud/bigtable/table.rb +676 -0
  75. data/lib/google/cloud/bigtable/v2/bigtable_client.rb +579 -0
  76. data/lib/google/cloud/bigtable/v2/bigtable_client_config.json +65 -0
  77. data/lib/google/cloud/bigtable/v2/credentials.rb +45 -0
  78. data/lib/google/cloud/bigtable/v2/doc/google/bigtable/v2/bigtable.rb +286 -0
  79. data/lib/google/cloud/bigtable/v2/doc/google/bigtable/v2/data.rb +492 -0
  80. data/lib/google/cloud/bigtable/v2/doc/google/protobuf/any.rb +124 -0
  81. data/lib/google/cloud/bigtable/v2/doc/google/protobuf/wrappers.rb +89 -0
  82. data/lib/google/cloud/bigtable/v2/doc/google/rpc/status.rb +83 -0
  83. data/lib/google/cloud/bigtable/v2.rb +132 -0
  84. data/lib/google/cloud/bigtable/value_range.rb +175 -0
  85. data/lib/google/cloud/bigtable/version.rb +22 -0
  86. data/lib/google/cloud/bigtable.rb +223 -0
  87. data/lib/google-cloud-bigtable.rb +167 -0
  88. metadata +283 -0
@@ -0,0 +1,108 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2018 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https:#www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+
18
+ module Google
19
+ module Cloud
20
+ module Bigtable
21
+ module RowFilter
22
+ # # ConditionFilter
23
+ #
24
+ # A RowFilter which evaluates one of two possible RowFilters, depending on
25
+ # whether or not a predicate RowFilter outputs any cells from the input row.
26
+ #
27
+ # IMPORTANT NOTE: The predicate filter does not execute atomically with the
28
+ # true and false filters, which may lead to inconsistent or unexpected
29
+ # results. Additionally, Condition filters have poor performance, especially
30
+ # when filters are set for the false condition.
31
+ #
32
+ # If `predicate_filter` outputs any cells, then `true_filter` will be
33
+ # evaluated on the input row. Otherwise, `false_filter` will be evaluated.
34
+ #
35
+ # @example
36
+ # predicate = Google::Cloud::Bigtable::RowFilter.key("user-*")
37
+ #
38
+ # label = Google::Cloud::Bigtable::RowFilter.label("user")
39
+ # strip_value = Google::Cloud::Bigtable::RowFilter.strip_value
40
+ #
41
+ # Google::Cloud::Bigtable::RowFilter.condition(predicate).on_match(label).otherwise(strip_value)
42
+ #
43
+ class ConditionFilter
44
+ # @private
45
+ # Create condition filter instance
46
+ #
47
+ # @param predicate [SimpleFilter, ChainFilter, InterleaveFilter, ConditionFilter]
48
+ #
49
+ def initialize predicate
50
+ @grpc = Google::Bigtable::V2::RowFilter::Condition.new
51
+ @grpc.predicate_filter = predicate.to_grpc
52
+ end
53
+
54
+ # Set true filter on predicate filter match.
55
+ #
56
+ # The filter to apply to the input row if `predicate_filter` returns any
57
+ # results. If not provided, no results will be returned in the true case.
58
+ #
59
+ # @param filter [SimpleFilter, ChainFilter, InterleaveFilter, ConditionFilter]
60
+ # @return [Google::Cloud::Bigtable::RowFilter::ConditionFilter]
61
+ #
62
+ # @example
63
+ # predicate = Google::Cloud::Bigtable::RowFilter.key("user-*")
64
+ #
65
+ # label = Google::Cloud::Bigtable::RowFilter.label("user")
66
+ # strip_value = Google::Cloud::Bigtable::RowFilter.strip_value
67
+ #
68
+ # Google::Cloud::Bigtable::RowFilter.condition(predicate).on_match(label).otherwise(strip_value)
69
+ #
70
+ def on_match filter
71
+ @grpc.true_filter = filter.to_grpc
72
+ self
73
+ end
74
+
75
+ # Set otherwise(false) filter.
76
+ #
77
+ # The filter to apply to the input row if `predicate_filter` does not
78
+ # return any results. If not provided, no results will be returned in the
79
+ # false case.
80
+ #
81
+ # @param filter [SimpleFilter, ChainFilter, InterleaveFilter, ConditionFilter]
82
+ # @return [Google::Cloud::Bigtable::RowFilter::ConditionFilter]
83
+ #
84
+ # @example
85
+ # predicate = Google::Cloud::Bigtable::RowFilter.key("user-*")
86
+ #
87
+ # label = Google::Cloud::Bigtable::RowFilter.label("user")
88
+ # strip_value = Google::Cloud::Bigtable::RowFilter.strip_value
89
+ #
90
+ # Google::Cloud::Bigtable::RowFilter.condition(predicate).on_match(label).otherwise(strip_value)
91
+ #
92
+ def otherwise filter
93
+ @grpc.false_filter = filter.to_grpc
94
+ self
95
+ end
96
+
97
+ # @private
98
+ # Get row filter gRPC instance.
99
+ # @return [Google::Bigtable::V2::RowFilter]
100
+ #
101
+ def to_grpc
102
+ Google::Bigtable::V2::RowFilter.new(condition: @grpc)
103
+ end
104
+ end
105
+ end
106
+ end
107
+ end
108
+ end
@@ -0,0 +1,570 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2018 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https:#www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+
18
+ module Google
19
+ module Cloud
20
+ module Bigtable
21
+ module RowFilter
22
+ # # InterleaveFilter
23
+ #
24
+ # A RowFilter which sends each row to each of several component
25
+ # RowFilters and interleaves the results.
26
+ #
27
+ # The elements of "filters" all process a copy of the input row, and the
28
+ # results are pooled, sorted, and combined into a single output row.
29
+ # If multiple cells are produced with the same column and timestamp,
30
+ # they will all appear in the output row in an unspecified mutual order.
31
+ # Consider the following example, with three filters:
32
+ #
33
+ # input row
34
+ # |
35
+ # -----------------------------------------------------
36
+ # | | |
37
+ # f(0) f(1) f(2)
38
+ # | | |
39
+ # 1: foo,bar,10,x foo,bar,10,z far,bar,7,a
40
+ # 2: foo,blah,11,z far,blah,5,x far,blah,5,x
41
+ # | | |
42
+ # -----------------------------------------------------
43
+ # |
44
+ # 1: foo,bar,10,z # could have switched with #2
45
+ # 2: foo,bar,10,x # could have switched with #1
46
+ # 3: foo,blah,11,z
47
+ # 4: far,bar,7,a
48
+ # 5: far,blah,5,x # identical to #6
49
+ # 6: far,blah,5,x # identical to #5
50
+ #
51
+ # All interleaved filters are executed atomically.
52
+ #
53
+ # @example Create interleave filter with simple filter.
54
+ #
55
+ # interleave = Google::Cloud::Bigtable::RowFilter.interleave
56
+ #
57
+ # # Add filters to interleave filter
58
+ # interleave.key("user-*")
59
+ # interleave.sink
60
+ #
61
+ # # OR
62
+ # interleave.key("user-*).sink
63
+ #
64
+ # @example Create complex interleave filter.
65
+ #
66
+ # interleave = Google::Cloud::Bigtable::RowFilter.interleave
67
+ #
68
+ # chain_1 = Google::Cloud::Bigtable::RowFilter.chain
69
+ # chain_1.label("users").qualifier("name").cells_per_row(5)
70
+ #
71
+ # # Add to main chain filter
72
+ # interleave.chain(chain_1).value("xyz*).key("user-*")
73
+ #
74
+ class InterleaveFilter
75
+ def initialize
76
+ @grpc = Google::Bigtable::V2::RowFilter::Interleave.new
77
+ end
78
+
79
+ # Add chain filter instance.
80
+ #
81
+ # A Chain RowFilter which sends rows through several RowFilters in sequence.
82
+ #
83
+ # See {Google::Cloud::Bigtable::RowFilter::InterleaveFilter}
84
+ #
85
+ # The elements of "filters" are chained together to process the input row:
86
+ # in row -> f(0) -> intermediate row -> f(1) -> ... -> f(N) -> out row
87
+ # The full chain is executed atomically.
88
+ #
89
+ # @param filter [SimpleFilter, ChainFilter, InterleaveFilter, ConditionFilter]
90
+ # @return [Google::Cloud::Bigtable::RowFilter::InterleaveFilter]
91
+ # `self` instance of interleave filter.
92
+ #
93
+ # @example Create chain filter and add interleave filter.
94
+ #
95
+ # chain = Google::Cloud::Bigtable::RowFilter.chain
96
+ #
97
+ # # Add filters to chain filter
98
+ # chain.key("user-*").cells_per_row(5)
99
+ #
100
+ # filter = Google::Cloud::Bigtable::RowFilter.interleave.chain(chain)
101
+ #
102
+ def chain filter
103
+ unless filter.instance_of?(ChainFilter)
104
+ raise RowFilterError, "Filter type must be ChainFilter"
105
+ end
106
+ add(filter)
107
+ end
108
+
109
+ # Add interleave filter.
110
+ #
111
+ # A RowFilter which sends each row to each of several component
112
+ # RowFilters and interleaves the results.
113
+ #
114
+ # The elements of "filters" all process a copy of the input row, and the
115
+ # results are pooled, sorted, and combined into a single output row.
116
+ # If multiple cells are produced with the same column and timestamp,
117
+ # they will all appear in the output row in an unspecified mutual order.
118
+ # Consider the following example, with three filters:
119
+ #
120
+ # input row
121
+ # |
122
+ # -----------------------------------------------------
123
+ # | | |
124
+ # f(0) f(1) f(2)
125
+ # | | |
126
+ # 1: foo,bar,10,x foo,bar,10,z far,bar,7,a
127
+ # 2: foo,blah,11,z far,blah,5,x far,blah,5,x
128
+ # | | |
129
+ # -----------------------------------------------------
130
+ # |
131
+ # 1: foo,bar,10,z # could have switched with #2
132
+ # 2: foo,bar,10,x # could have switched with #1
133
+ # 3: foo,blah,11,z
134
+ # 4: far,bar,7,a
135
+ # 5: far,blah,5,x # identical to #6
136
+ # 6: far,blah,5,x # identical to #5
137
+ #
138
+ # All interleaved filters are executed atomically.
139
+ #
140
+ # @param filter [SimpleFilter, ChainFilter, InterleaveFilter, ConditionFilter]
141
+ # @return [Google::Cloud::Bigtable::RowFilter::InterleaveFilter]
142
+ # `self` instance of interleave filter.
143
+ #
144
+ # @example Add interleave filter to chain filter
145
+ #
146
+ # interleave = Google::Cloud::Bigtable::RowFilter.interleave
147
+ #
148
+ # # Add filters to interleave filter
149
+ # interleave.key("user-*").cells_per_column(3)
150
+ #
151
+ # filter = Google::Cloud::Bigtable::RowFilter.interleave.interleave(interleave)
152
+ #
153
+ def interleave filter
154
+ unless filter.instance_of?(InterleaveFilter)
155
+ raise RowFilterError, "Filter type must be InterleaveFilter"
156
+ end
157
+ add(filter)
158
+ end
159
+
160
+ # Add condition filter instance
161
+ #
162
+ # A RowFilter which evaluates one of two possible RowFilters, depending on
163
+ # whether or not a predicate RowFilter outputs any cells from the input row.
164
+ #
165
+ # IMPORTANT NOTE: The predicate filter does not execute atomically with the
166
+ # true and false filters, which may lead to inconsistent or unexpected
167
+ # results. Additionally, Condition filters have poor performance, especially
168
+ # when filters are set for the false condition.
169
+ #
170
+ # Cannot be used within the `predicate_filter`, `true_filter`, or `false_filter`
171
+ #
172
+ # @param filter [Google::Cloud::Bigtable::RowFilter::ConditionFilter]
173
+ # @return [Google::Cloud::Bigtable::RowFilter::InterleaveFilter]
174
+ # `self` instance of interleave filter.
175
+ #
176
+ # @example
177
+ #
178
+ # predicate = Google::Cloud::Bigtable::RowFilter.key("user-*")
179
+ #
180
+ # label = Google::Cloud::Bigtable::RowFilter.label("user")
181
+ # strip_value = Google::Cloud::Bigtable::RowFilter.strip_value
182
+ #
183
+ # condition_filter = Google::Cloud::Bigtable::RowFilter.condition(predicate).on_match(label).otherwise(strip_value)
184
+ #
185
+ # filter = Google::Cloud::Bigtable::RowFilter.interleave.condition(condition_filter)
186
+ #
187
+ def condition filter
188
+ unless filter.instance_of?(ConditionFilter)
189
+ raise RowFilterError, "Filter type must be ConditionFilter"
190
+ end
191
+ add(filter)
192
+ end
193
+
194
+ # Add pass filter instance
195
+ #
196
+ # Matches all cells, regardless of input. Functionally equivalent to
197
+ # leaving `filter` unset, but included for completeness.
198
+ #
199
+ # @return [Google::Cloud::Bigtable::RowFilter::InterleaveFilter]
200
+ # `self` instance of interleave filter.
201
+ #
202
+ # @example
203
+ #
204
+ # filter = Google::Cloud::Bigtable::RowFilter.interleave.pass
205
+ #
206
+ def pass
207
+ add(RowFilter.pass)
208
+ end
209
+
210
+ # Add block all filter instance
211
+ #
212
+ # Does not match any cells, regardless of input. Useful for temporarily
213
+ # disabling just part of a filter.
214
+ #
215
+ # @return [Google::Cloud::Bigtable::RowFilter::InterleaveFilter]
216
+ # `self` instance of interleave filter.
217
+ #
218
+ # @example
219
+ #
220
+ # filter = Google::Cloud::Bigtable::RowFilter.interleave.block
221
+ #
222
+ def block
223
+ add(RowFilter.block)
224
+ end
225
+
226
+ # Add sink filter instance
227
+ #
228
+ # Outputs all cells directly to the output of the read rather than to any parent filter
229
+ #
230
+ # @return [Google::Cloud::Bigtable::RowFilter::InterleaveFilter]
231
+ # `self` instance of interleave filter.
232
+ #
233
+ # @example
234
+ #
235
+ # filter = Google::Cloud::Bigtable::RowFilter.interleave.sink
236
+ #
237
+ def sink
238
+ add(RowFilter.sink)
239
+ end
240
+
241
+ # Add strip value filter instance
242
+ #
243
+ # Replaces each cell's value with the empty string.
244
+ #
245
+ # @return [Google::Cloud::Bigtable::RowFilter::InterleaveFilter]
246
+ # `self` instance of interleave filter.
247
+ #
248
+ # @example
249
+ #
250
+ # filter = Google::Cloud::Bigtable::RowFilter.interleave.strip_value
251
+ #
252
+ def strip_value
253
+ add(RowFilter.strip_value)
254
+ end
255
+
256
+ # Add key filter instance to match key using regular expression.
257
+ #
258
+ # Matches only cells from rows whose keys satisfy the given RE2 regex. In
259
+ # other words, passes through the entire row when the key matches, and
260
+ # otherwise produces an empty row.
261
+ # Note that, since row keys can contain arbitrary bytes, the `\C` escape
262
+ # sequence must be used if a true wildcard is desired. The `.` character
263
+ # will not match the new line character `\n`, which may be present in a
264
+ # binary key.
265
+ #
266
+ # For Regex syntax:
267
+ # @see https:#github.com/google/re2/wiki/Syntax
268
+ #
269
+ # @param regex [String] Regex to match row keys.
270
+ # @return [Google::Cloud::Bigtable::RowFilter::InterleaveFilter]
271
+ # `self` instance of interleave filter.
272
+ #
273
+ # @example
274
+ #
275
+ # filter = Google::Cloud::Bigtable::RowFilter.interleave.key("user-*")
276
+ #
277
+ def key regex
278
+ add(RowFilter.key(regex))
279
+ end
280
+
281
+ # Add sample probability filter instance
282
+ #
283
+ # Matches all cells from a row with probability p, and matches no cells
284
+ # from the row with probability 1-p.
285
+ #
286
+ # @param probability [Float] Probability value
287
+ # Probability must be greather then 0 and less then 1.0
288
+ # @return [Google::Cloud::Bigtable::RowFilter::InterleaveFilter]
289
+ # `self` instance of interleave filter.
290
+ #
291
+ # @example
292
+ #
293
+ # filter = Google::Cloud::Bigtable::RowFilter.interleave.sample(0.5)
294
+ #
295
+ def sample probability
296
+ add(RowFilter.sample(probability))
297
+ end
298
+
299
+ # Add family name match filter using regex
300
+ #
301
+ # Matches only cells from columns whose families satisfy the given RE2
302
+ # regex. For technical reasons, the regex must not contain the `:`
303
+ # character, even if it is not being used as a literal.
304
+ # Note that, since column families cannot contain the new line character
305
+ # `\n`, it is sufficient to use `.` as a full wildcard when matching
306
+ # column family names.
307
+ #
308
+ # For Regex syntax:
309
+ # @see https:#github.com/google/re2/wiki/Syntax
310
+ #
311
+ # @param regex [String] Regex to match family name.
312
+ # @return [Google::Cloud::Bigtable::RowFilter::InterleaveFilter]
313
+ # `self` instance of interleave filter.
314
+ #
315
+ # @example
316
+ #
317
+ # filter = Google::Cloud::Bigtable::RowFilter.interleave.family("cf-*")
318
+ #
319
+ def family regex
320
+ add(RowFilter.family(regex))
321
+ end
322
+
323
+ # Add column qualifier match filter using regex
324
+ #
325
+ # Matches only cells from columns whose qualifiers satisfy the given RE2
326
+ # regex.
327
+ # Note that, since column qualifiers can contain arbitrary bytes, the `\C`
328
+ # escape sequence must be used if a true wildcard is desired. The `.`
329
+ # character will not match the new line character `\n`, which may be
330
+ # present in a binary qualifier.
331
+ #
332
+ # For Regex syntax:
333
+ # @see https:#github.com/google/re2/wiki/Syntax
334
+ #
335
+ # @param regex [String] Regex to match column qualifier name.
336
+ # @return [Google::Cloud::Bigtable::RowFilter::InterleaveFilter]
337
+ # `self` instance of interleave filter.
338
+ #
339
+ # @example
340
+ #
341
+ # filter = Google::Cloud::Bigtable::RowFilter.interleave.qualifier("user-name*")
342
+ #
343
+ def qualifier regex
344
+ add(RowFilter.qualifier(regex))
345
+ end
346
+
347
+ # Add value match filter using regex
348
+ #
349
+ # Matches only cells with values that satisfy the given regular expression.
350
+ # Note that, since cell values can contain arbitrary bytes, the `\C` escape
351
+ # sequence must be used if a true wildcard is desired. The `.` character
352
+ # will not match the new line character `\n`, which may be present in a
353
+ # binary value.
354
+ #
355
+ # For Regex syntax:
356
+ # @see https:#github.com/google/re2/wiki/Syntax
357
+ #
358
+ # @param regex [String] Regex to match cell value.
359
+ # @return [Google::Cloud::Bigtable::RowFilter::InterleaveFilter]
360
+ # `self` instance of interleave filter.
361
+ #
362
+ # @example
363
+ #
364
+ # filter = Google::Cloud::Bigtable::RowFilter.interleave.value("abc*")
365
+ #
366
+ def value regex
367
+ add(RowFilter.value(regex))
368
+ end
369
+
370
+ # Add label filter instance to apply label on result of read rows.
371
+ #
372
+ # Applies the given label to all cells in the output row. This allows
373
+ # the client to determine which results were produced from which part of
374
+ # the filter.
375
+ #
376
+ # Values must be at most 15 characters in length, and match the RE2
377
+ # pattern `[a-z0-9\\-]+`
378
+ #
379
+ # Due to a technical limitation, it is not currently possible to apply
380
+ # multiple labels to a cell. As a result, a Chain may have no more than
381
+ # one sub-filter which contains a `apply_label_transformer`. It is okay for
382
+ # an Interleave to contain multiple `apply_label_transformers`, as they
383
+ # will be applied to separate copies of the input. This may be relaxed in
384
+ # the future.
385
+ #
386
+ # @param value [String] Label name
387
+ # @return [Google::Cloud::Bigtable::RowFilter::InterleaveFilter]
388
+ # `self` instance of interleave filter.
389
+ #
390
+ # @example
391
+ #
392
+ # filter = Google::Cloud::Bigtable::RowFilter.interleave.label("user-detail")
393
+ #
394
+ def label value
395
+ add(RowFilter.label(value))
396
+ end
397
+
398
+ # Add cell per row offset filter instance to skip first N cells.
399
+ #
400
+ # Skips the first N cells of each row, matching all subsequent cells.
401
+ # If duplicate cells are present, as is possible when using an Interleave,
402
+ # each copy of the cell is counted separately.
403
+ #
404
+ # @param offset [Integer] Offset value.
405
+ # @return [Google::Cloud::Bigtable::RowFilter::InterleaveFilter]
406
+ # `self` instance of interleave filter.
407
+ #
408
+ # @example
409
+ #
410
+ # filter = Google::Cloud::Bigtable::RowFilter.interleave.cells_per_row_offset(3)
411
+ #
412
+ def cells_per_row_offset offset
413
+ add(RowFilter.cells_per_row_offset(offset))
414
+ end
415
+
416
+ # Add cells per row limit filter instance
417
+ #
418
+ # Matches only the first N cells of each row.
419
+ # If duplicate cells are present, as is possible when using an Interleave,
420
+ # each copy of the cell is counted separately.
421
+ #
422
+ # @param limit [String] Max cell match per row limit
423
+ # @return [Google::Cloud::Bigtable::RowFilter::InterleaveFilter]
424
+ # `self` instance of interleave filter.
425
+ #
426
+ # @example
427
+ #
428
+ # filter = Google::Cloud::Bigtable::RowFilter.interleave.cells_per_row(5)
429
+ #
430
+ def cells_per_row limit
431
+ add(RowFilter.cells_per_row(limit))
432
+ end
433
+
434
+ # Add cells per column filter instance
435
+ #
436
+ # Matches only the most recent N cells within each column. For example,
437
+ # if N=2, this filter would match column `foo:bar` at timestamps 10 and 9,
438
+ # skip all earlier cells in `foo:bar`, and then begin matching again in
439
+ # column `foo:bar2`.
440
+ # If duplicate cells are present, as is possible when using an Interleave,
441
+ # each copy of the cell is counted separately.
442
+ #
443
+ # @param limit [String] Max cell match per column limit
444
+ # @return [Google::Cloud::Bigtable::RowFilter::InterleaveFilter]
445
+ # `self` instance of interleave filter.
446
+ #
447
+ # @example
448
+ #
449
+ # filter = Google::Cloud::Bigtable::RowFilter.interleave.cells_per_column(5)
450
+ #
451
+ def cells_per_column limit
452
+ add(RowFilter.cells_per_column(limit))
453
+ end
454
+
455
+ # Add timestamp range filter instance
456
+ #
457
+ # Matches only cells with timestamps within the given range.
458
+ # Specified a contiguous range of timestamps.
459
+ #
460
+ # @param from [Integer] Inclusive lower bound.
461
+ # If left empty, interpreted as 0.
462
+ # @param to [Integer] Exclusive upper bound.
463
+ # If left empty, interpreted as infinity.
464
+ # @return [Google::Cloud::Bigtable::RowFilter::InterleaveFilter]
465
+ # `self` instance of interleave filter.
466
+ #
467
+ # @example
468
+ #
469
+ # from = (Time.now - 300).to_f * 1000
470
+ # to = Time.now.to_f * 1000
471
+ #
472
+ # filter = Google::Cloud::Bigtable::RowFilter.interleave.timestamp_range(from: from, to: to)
473
+ #
474
+ def timestamp_range from: nil, to: nil
475
+ add(RowFilter.timestamp_range(from: from, to: to))
476
+ end
477
+
478
+ # Add value range filter instance
479
+ #
480
+ # Matches only cells with values that fall within the given range.
481
+ #
482
+ # See {Google::Cloud::Bigtable::ValueRange#from} and { Google::Cloud::Bigtable::ValueRange#to} for range
483
+ # option inclusive/exclusive options
484
+ #
485
+ # * The value at which to start the range.If neither field is set, interpreted as the empty string, inclusive.
486
+ # * The value at which to end the range. If neither field is set, interpreted as the infinite string, exclusive.
487
+ #
488
+ # @param range [Google::Cloud::Bigtable::ValueRange]
489
+ # @return [Google::Cloud::Bigtable::RowFilter::InterleaveFilter]
490
+ # `self` instance of interleave filter.
491
+ #
492
+ # @example Start to end range
493
+ #
494
+ # range = Google::Cloud::Bigtable::ValueRange.from("abc").to('xyz')
495
+ # filter = Google::Cloud::Bigtable::RowFilter.interleave.value_range(range)
496
+ #
497
+ # @example Start exlusive to infinite end range
498
+ #
499
+ # range = Google::Cloud::Bigtable::ValueRange.from("abc", inclusive: false)
500
+ # filter = Google::Cloud::Bigtable::RowFilter.interleave.value_range(range)
501
+ #
502
+ def value_range range
503
+ add(RowFilter.value_range(range))
504
+ end
505
+
506
+ # Add column range filter instance.
507
+ #
508
+ # Matches only cells from columns within the given range.
509
+ #
510
+ # @param range [Google::Cloud::Bigtable::ColumnRange]
511
+ # @return [Google::Cloud::Bigtable::RowFilter::InterleaveFilter]
512
+ # `self` instance of interleave filter.
513
+ #
514
+ # @example
515
+ #
516
+ # range = Google::Cloud::Bigtable::ColumnRange.new(cf).from("field0").to('field5')
517
+ #
518
+ # filter = Google::Cloud::Bigtable::RowFilter.interleave.column_range(range)
519
+ #
520
+ def column_range range
521
+ add(RowFilter.column_range(range))
522
+ end
523
+
524
+ # Get number of filter count in chain filters
525
+ #
526
+ # @return [Integer]
527
+ #
528
+ # @example
529
+ #
530
+ # filter = Google::Cloud::Bigtable::RowFilter.interleave.key("user-1*").label("user")
531
+ # filter.length # 2
532
+ #
533
+ def length
534
+ @grpc.filters.length
535
+ end
536
+
537
+ # Get list of filters
538
+ #
539
+ # @return [Array<Google::Bigtable::V2::RowFilter>]
540
+ #
541
+ def filters
542
+ @grpc.filters
543
+ end
544
+
545
+ # @private
546
+ #
547
+ # Get gRPC object of RowFilter with interleave filter
548
+ #
549
+ # @return [Google::Bigtable::V2::RowFilter]
550
+ #
551
+ def to_grpc
552
+ Google::Bigtable::V2::RowFilter.new(interleave: @grpc)
553
+ end
554
+
555
+ private
556
+
557
+ # @private
558
+ # Add filter to interleave filter.
559
+ #
560
+ # @param filter [SimpleFilter, ChainFilter, InterleaveFilter, ConditionFilter]
561
+ #
562
+ def add filter
563
+ @grpc.filters << filter.to_grpc
564
+ self
565
+ end
566
+ end
567
+ end
568
+ end
569
+ end
570
+ end