google-cloud-bigtable 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.yardopts +19 -0
- data/AUTHENTICATION.md +177 -0
- data/CHANGELOG.md +223 -0
- data/CODE_OF_CONDUCT.md +40 -0
- data/CONTRIBUTING.md +188 -0
- data/EMULATOR.md +30 -0
- data/LICENSE +201 -0
- data/LOGGING.md +32 -0
- data/OVERVIEW.md +400 -0
- data/TROUBLESHOOTING.md +31 -0
- data/lib/google-cloud-bigtable.rb +171 -0
- data/lib/google/bigtable/admin/v2/bigtable_instance_admin_pb.rb +145 -0
- data/lib/google/bigtable/admin/v2/bigtable_instance_admin_services_pb.rb +90 -0
- data/lib/google/bigtable/admin/v2/bigtable_table_admin_pb.rb +208 -0
- data/lib/google/bigtable/admin/v2/bigtable_table_admin_services_pb.rb +154 -0
- data/lib/google/bigtable/admin/v2/common_pb.rb +30 -0
- data/lib/google/bigtable/admin/v2/instance_pb.rb +74 -0
- data/lib/google/bigtable/admin/v2/table_pb.rb +127 -0
- data/lib/google/bigtable/v2/bigtable_pb.rb +113 -0
- data/lib/google/bigtable/v2/bigtable_services_pb.rb +68 -0
- data/lib/google/bigtable/v2/data_pb.rb +156 -0
- data/lib/google/cloud/bigtable.rb +184 -0
- data/lib/google/cloud/bigtable/admin.rb +202 -0
- data/lib/google/cloud/bigtable/admin/credentials.rb +27 -0
- data/lib/google/cloud/bigtable/admin/v2.rb +223 -0
- data/lib/google/cloud/bigtable/admin/v2/bigtable_instance_admin_client.rb +1451 -0
- data/lib/google/cloud/bigtable/admin/v2/bigtable_instance_admin_client_config.json +139 -0
- data/lib/google/cloud/bigtable/admin/v2/bigtable_table_admin_client.rb +1734 -0
- data/lib/google/cloud/bigtable/admin/v2/bigtable_table_admin_client_config.json +163 -0
- data/lib/google/cloud/bigtable/admin/v2/credentials.rb +51 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/bigtable/admin/v2/bigtable_instance_admin.rb +297 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/bigtable/admin/v2/bigtable_table_admin.rb +587 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/bigtable/admin/v2/instance.rb +193 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/bigtable/admin/v2/table.rb +303 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/iam/v1/iam_policy.rb +64 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/iam/v1/options.rb +33 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/iam/v1/policy.rb +151 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/longrunning/operations.rb +51 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/any.rb +131 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/duration.rb +91 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/empty.rb +29 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/field_mask.rb +222 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/timestamp.rb +113 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/rpc/status.rb +39 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/type/expr.rb +45 -0
- data/lib/google/cloud/bigtable/app_profile.rb +439 -0
- data/lib/google/cloud/bigtable/app_profile/job.rb +99 -0
- data/lib/google/cloud/bigtable/app_profile/list.rb +165 -0
- data/lib/google/cloud/bigtable/backup.rb +324 -0
- data/lib/google/cloud/bigtable/backup/job.rb +87 -0
- data/lib/google/cloud/bigtable/backup/list.rb +167 -0
- data/lib/google/cloud/bigtable/chunk_processor.rb +241 -0
- data/lib/google/cloud/bigtable/cluster.rb +390 -0
- data/lib/google/cloud/bigtable/cluster/job.rb +88 -0
- data/lib/google/cloud/bigtable/cluster/list.rb +171 -0
- data/lib/google/cloud/bigtable/column_family.rb +73 -0
- data/lib/google/cloud/bigtable/column_family_map.rb +426 -0
- data/lib/google/cloud/bigtable/column_range.rb +194 -0
- data/lib/google/cloud/bigtable/convert.rb +83 -0
- data/lib/google/cloud/bigtable/credentials.rb +25 -0
- data/lib/google/cloud/bigtable/errors.rb +38 -0
- data/lib/google/cloud/bigtable/gc_rule.rb +334 -0
- data/lib/google/cloud/bigtable/instance.rb +935 -0
- data/lib/google/cloud/bigtable/instance/cluster_map.rb +74 -0
- data/lib/google/cloud/bigtable/instance/job.rb +98 -0
- data/lib/google/cloud/bigtable/instance/list.rb +164 -0
- data/lib/google/cloud/bigtable/longrunning_job.rb +122 -0
- data/lib/google/cloud/bigtable/mutation_entry.rb +256 -0
- data/lib/google/cloud/bigtable/mutation_operations.rb +357 -0
- data/lib/google/cloud/bigtable/policy.rb +167 -0
- data/lib/google/cloud/bigtable/project.rb +471 -0
- data/lib/google/cloud/bigtable/read_modify_write_rule.rb +134 -0
- data/lib/google/cloud/bigtable/read_operations.rb +328 -0
- data/lib/google/cloud/bigtable/routing_policy.rb +172 -0
- data/lib/google/cloud/bigtable/row.rb +136 -0
- data/lib/google/cloud/bigtable/row_filter.rb +639 -0
- data/lib/google/cloud/bigtable/row_filter/chain_filter.rb +590 -0
- data/lib/google/cloud/bigtable/row_filter/condition_filter.rb +114 -0
- data/lib/google/cloud/bigtable/row_filter/interleave_filter.rb +621 -0
- data/lib/google/cloud/bigtable/row_filter/simple_filter.rb +287 -0
- data/lib/google/cloud/bigtable/row_range.rb +179 -0
- data/lib/google/cloud/bigtable/rows_mutator.rb +113 -0
- data/lib/google/cloud/bigtable/rows_reader.rb +200 -0
- data/lib/google/cloud/bigtable/sample_row_key.rb +85 -0
- data/lib/google/cloud/bigtable/service.rb +913 -0
- data/lib/google/cloud/bigtable/status.rb +76 -0
- data/lib/google/cloud/bigtable/table.rb +686 -0
- data/lib/google/cloud/bigtable/table/cluster_state.rb +125 -0
- data/lib/google/cloud/bigtable/table/list.rb +154 -0
- data/lib/google/cloud/bigtable/table/restore_job.rb +117 -0
- data/lib/google/cloud/bigtable/v2.rb +146 -0
- data/lib/google/cloud/bigtable/v2/bigtable_client.rb +591 -0
- data/lib/google/cloud/bigtable/v2/bigtable_client_config.json +83 -0
- data/lib/google/cloud/bigtable/v2/credentials.rb +46 -0
- data/lib/google/cloud/bigtable/v2/doc/google/bigtable/v2/bigtable.rb +290 -0
- data/lib/google/cloud/bigtable/v2/doc/google/bigtable/v2/data.rb +493 -0
- data/lib/google/cloud/bigtable/v2/doc/google/protobuf/any.rb +131 -0
- data/lib/google/cloud/bigtable/v2/doc/google/protobuf/wrappers.rb +34 -0
- data/lib/google/cloud/bigtable/v2/doc/google/rpc/status.rb +39 -0
- data/lib/google/cloud/bigtable/value_range.rb +181 -0
- data/lib/google/cloud/bigtable/version.rb +22 -0
- metadata +337 -0
@@ -0,0 +1,287 @@
|
|
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
|
+
##
|
23
|
+
#
|
24
|
+
# # SimpleFilter
|
25
|
+
#
|
26
|
+
class SimpleFilter
|
27
|
+
# @private
|
28
|
+
# Creates a simple filter instance.
|
29
|
+
#
|
30
|
+
def initialize
|
31
|
+
@grpc = Google::Bigtable::V2::RowFilter.new
|
32
|
+
end
|
33
|
+
|
34
|
+
##
|
35
|
+
# Outputs all cells directly to the output of the read rather than to any parent filter.
|
36
|
+
#
|
37
|
+
# @return [Google::Cloud::Bigtable::RowFilter::SimpleFilter]
|
38
|
+
#
|
39
|
+
def sink
|
40
|
+
@grpc.sink = true
|
41
|
+
self
|
42
|
+
end
|
43
|
+
|
44
|
+
##
|
45
|
+
# Matches all cells, regardless of input. Functionally equivalent to
|
46
|
+
# leaving `filter` unset, but included for completeness.
|
47
|
+
#
|
48
|
+
# @return [Google::Cloud::Bigtable::RowFilter::SimpleFilter]
|
49
|
+
#
|
50
|
+
def pass
|
51
|
+
@grpc.pass_all_filter = true
|
52
|
+
self
|
53
|
+
end
|
54
|
+
|
55
|
+
##
|
56
|
+
# Does not match any cells, regardless of input. Useful for temporarily
|
57
|
+
# disabling just part of a filter.
|
58
|
+
#
|
59
|
+
# @return [Google::Cloud::Bigtable::RowFilter::SimpleFilter]
|
60
|
+
#
|
61
|
+
def block
|
62
|
+
@grpc.block_all_filter = true
|
63
|
+
self
|
64
|
+
end
|
65
|
+
|
66
|
+
##
|
67
|
+
# Replaces each cell's value with an empty string.
|
68
|
+
#
|
69
|
+
# @return [Google::Cloud::Bigtable::RowFilter::SimpleFilter]
|
70
|
+
#
|
71
|
+
def strip_value
|
72
|
+
@grpc.strip_value_transformer = true
|
73
|
+
self
|
74
|
+
end
|
75
|
+
|
76
|
+
##
|
77
|
+
# Matches only cells from rows whose keys satisfy the given RE2 regex. In
|
78
|
+
# other words, passes through the entire row when the key matches, and
|
79
|
+
# otherwise produces an empty row.
|
80
|
+
# Note that, since row keys can contain arbitrary bytes, the `\C` escape
|
81
|
+
# sequence must be used if a true wildcard is desired. The `.` character
|
82
|
+
# will not match the new line character `\n`, which may be present in a
|
83
|
+
# binary key.
|
84
|
+
#
|
85
|
+
# For Regex syntax:
|
86
|
+
# @see https://github.com/google/re2/wiki/Syntax
|
87
|
+
#
|
88
|
+
# @param regex [String] Regex to match row keys.
|
89
|
+
# @return [Google::Cloud::Bigtable::RowFilter::SimpleFilter]
|
90
|
+
#
|
91
|
+
def key regex
|
92
|
+
@grpc.row_key_regex_filter = regex
|
93
|
+
self
|
94
|
+
end
|
95
|
+
|
96
|
+
##
|
97
|
+
# Matches all cells from a row with probability p, and matches no cells
|
98
|
+
# from the row with probability 1-p.
|
99
|
+
#
|
100
|
+
# @param probability [Float]
|
101
|
+
# @return [Google::Cloud::Bigtable::RowFilter::SimpleFilter]
|
102
|
+
#
|
103
|
+
def sample probability
|
104
|
+
if probability >= 1 || probability <= 0
|
105
|
+
raise RowFilterError, "Probability must be greater than 0 and less than 1.0."
|
106
|
+
end
|
107
|
+
@grpc.row_sample_filter = probability
|
108
|
+
self
|
109
|
+
end
|
110
|
+
|
111
|
+
##
|
112
|
+
# Matches only cells from columns whose families satisfy the given RE2
|
113
|
+
# regex. For technical reasons, the regex must not contain the `:`
|
114
|
+
# character, even if it is not being used as a literal.
|
115
|
+
# Note that, since column families cannot contain the new line character
|
116
|
+
# `\n`, it is sufficient to use `.` as a full wildcard when matching
|
117
|
+
# column family names.
|
118
|
+
#
|
119
|
+
# @param regex [String] Regex to match family name.
|
120
|
+
# @return [Google::Cloud::Bigtable::RowFilter::SimpleFilter]
|
121
|
+
#
|
122
|
+
def family regex
|
123
|
+
@grpc.family_name_regex_filter = regex
|
124
|
+
self
|
125
|
+
end
|
126
|
+
|
127
|
+
##
|
128
|
+
# Matches only cells from columns whose qualifiers satisfy the given RE2
|
129
|
+
# regex.
|
130
|
+
# Note that, since column qualifiers can contain arbitrary bytes, the `\C`
|
131
|
+
# escape sequence must be used if a true wildcard is desired. The `.`
|
132
|
+
# character will not match the new line character `\n`, which may be
|
133
|
+
# present in a binary qualifier.
|
134
|
+
#
|
135
|
+
# @param regex [String] Regex to match column qualifier name.
|
136
|
+
# @return [Google::Cloud::Bigtable::RowFilter::SimpleFilter]
|
137
|
+
#
|
138
|
+
def qualifier regex
|
139
|
+
@grpc.column_qualifier_regex_filter = regex
|
140
|
+
self
|
141
|
+
end
|
142
|
+
|
143
|
+
##
|
144
|
+
# Matches only cells with values that satisfy the given regular expression.
|
145
|
+
# Note that, since cell values can contain arbitrary bytes, the `\C` escape
|
146
|
+
# sequence must be used if a true wildcard is desired. The `.` character
|
147
|
+
# will not match the new line character `\n`, which may be present in a
|
148
|
+
# binary value.
|
149
|
+
#
|
150
|
+
# @param regex [String] Regex to match cell value.
|
151
|
+
# @return [Google::Cloud::Bigtable::RowFilter::SimpleFilter]
|
152
|
+
#
|
153
|
+
def value regex
|
154
|
+
@grpc.value_regex_filter = regex
|
155
|
+
self
|
156
|
+
end
|
157
|
+
|
158
|
+
##
|
159
|
+
# Applies the given label to all cells in the output row. This allows
|
160
|
+
# the client to determine which results were produced from which part of
|
161
|
+
# the filter.
|
162
|
+
#
|
163
|
+
# Values must be at most 15 characters in length, and match the RE2
|
164
|
+
# pattern `[a-z0-9\\-]+`
|
165
|
+
#
|
166
|
+
# Due to a technical limitation, it is not possible to apply
|
167
|
+
# multiple labels to a cell. As a result, a chain may have no more than
|
168
|
+
# one sub-filter that contains an `apply_label_transformer`. It is okay for
|
169
|
+
# an interleave to contain multiple `apply_label_transformers`, as they
|
170
|
+
# will be applied to separate copies of the input.
|
171
|
+
#
|
172
|
+
# @param value [String] Label name
|
173
|
+
# @return [Google::Cloud::Bigtable::RowFilter::SimpleFilter]
|
174
|
+
#
|
175
|
+
def label value
|
176
|
+
@grpc.apply_label_transformer = value
|
177
|
+
self
|
178
|
+
end
|
179
|
+
|
180
|
+
##
|
181
|
+
# Skips the first N cells of each row, matching all subsequent cells.
|
182
|
+
# If duplicate cells are present, as is possible when using an interleave,
|
183
|
+
# each copy of the cell is counted separately.
|
184
|
+
#
|
185
|
+
# @param offset [Integer] Offset value.
|
186
|
+
# @return [Google::Cloud::Bigtable::RowFilter::SimpleFilter]
|
187
|
+
#
|
188
|
+
def cells_per_row_offset offset
|
189
|
+
@grpc.cells_per_row_offset_filter = offset
|
190
|
+
self
|
191
|
+
end
|
192
|
+
|
193
|
+
##
|
194
|
+
# Matches only the first N cells of each row.
|
195
|
+
# If duplicate cells are present, as is possible when using an Interleave,
|
196
|
+
# each copy of the cell is counted separately.
|
197
|
+
#
|
198
|
+
# @param limit [String] Max cell match per row limit
|
199
|
+
# @return [Google::Cloud::Bigtable::RowFilter::SimpleFilter]
|
200
|
+
#
|
201
|
+
def cells_per_row limit
|
202
|
+
@grpc.cells_per_row_limit_filter = limit
|
203
|
+
self
|
204
|
+
end
|
205
|
+
|
206
|
+
##
|
207
|
+
# Matches only the most recent N cells within each column. For example,
|
208
|
+
# if N=2, this filter would match column `foo:bar` at timestamps 10 and 9,
|
209
|
+
# skip all earlier cells in `foo:bar`, and then begin matching again in
|
210
|
+
# column `foo:bar2`.
|
211
|
+
# If duplicate cells are present, as is possible when using an interleave,
|
212
|
+
# each copy of the cell is counted separately.
|
213
|
+
#
|
214
|
+
# @param limit [String] Max cell match per column limit
|
215
|
+
# @return [Google::Cloud::Bigtable::RowFilter::SimpleFilter]
|
216
|
+
#
|
217
|
+
def cells_per_column limit
|
218
|
+
@grpc.cells_per_column_limit_filter = limit
|
219
|
+
self
|
220
|
+
end
|
221
|
+
|
222
|
+
##
|
223
|
+
# Creates a timestamp-range filter.
|
224
|
+
#
|
225
|
+
# Matches only cells with timestamps within the given range.
|
226
|
+
# Specifies a contiguous range of timestamps.
|
227
|
+
#
|
228
|
+
# @param from [Integer] Inclusive lower bound. If left empty, interpreted as 0.
|
229
|
+
# @param to [Integer] Exclusive upper bound. If left empty, interpreted as infinity.
|
230
|
+
# @return [Google::Cloud::Bigtable::RowFilter::SimpleFilter]
|
231
|
+
#
|
232
|
+
def timestamp_range from, to
|
233
|
+
range_grpc = Google::Bigtable::V2::TimestampRange.new
|
234
|
+
range_grpc.start_timestamp_micros = from if from
|
235
|
+
range_grpc.end_timestamp_micros = to if to
|
236
|
+
@grpc.timestamp_range_filter = range_grpc
|
237
|
+
self
|
238
|
+
end
|
239
|
+
|
240
|
+
##
|
241
|
+
# Matches only cells with values that fall within the given range.
|
242
|
+
#
|
243
|
+
# See {Google::Cloud::Bigtable::ValueRange#from} and { Google::Cloud::Bigtable::ValueRange#to} for range
|
244
|
+
# option inclusive/exclusive options
|
245
|
+
#
|
246
|
+
# * The value at which to start the range. If neither field is set, interpreted as an empty string, inclusive.
|
247
|
+
# * The value at which to end the range. If neither field is set, interpreted as an infinite string,
|
248
|
+
# exclusive.
|
249
|
+
#
|
250
|
+
# @param range [Google::Cloud::Bigtable::ValueRange]
|
251
|
+
# @return [Google::Cloud::Bigtable::RowFilter::SimpleFilter]
|
252
|
+
#
|
253
|
+
def value_range range
|
254
|
+
unless range.instance_of? Google::Cloud::Bigtable::ValueRange
|
255
|
+
raise RowFilterError, "Range type mustbe ValueRange"
|
256
|
+
end
|
257
|
+
@grpc.value_range_filter = range.to_grpc
|
258
|
+
self
|
259
|
+
end
|
260
|
+
|
261
|
+
##
|
262
|
+
# Matches only cells from columns within the given range.
|
263
|
+
#
|
264
|
+
# @param range [Google::Cloud::Bigtable::ColumnRange]
|
265
|
+
# @return [Google::Cloud::Bigtable::RowFilter::SimpleFilter]
|
266
|
+
#
|
267
|
+
def column_range range
|
268
|
+
unless range.instance_of? Google::Cloud::Bigtable::ColumnRange
|
269
|
+
raise RowFilterError, "Range type mustbe ColumnRange"
|
270
|
+
end
|
271
|
+
@grpc.column_range_filter = range.to_grpc
|
272
|
+
self
|
273
|
+
end
|
274
|
+
|
275
|
+
# @private
|
276
|
+
#
|
277
|
+
# Converts to a gRPC row filter instance.
|
278
|
+
#
|
279
|
+
# @return [Google::Bigtable::V2::RowFilter]
|
280
|
+
def to_grpc
|
281
|
+
@grpc
|
282
|
+
end
|
283
|
+
end
|
284
|
+
end
|
285
|
+
end
|
286
|
+
end
|
287
|
+
end
|
@@ -0,0 +1,179 @@
|
|
1
|
+
# Copyright 2018 Google LLC
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
|
16
|
+
module Google
|
17
|
+
module Cloud
|
18
|
+
module Bigtable
|
19
|
+
##
|
20
|
+
# # RowRange
|
21
|
+
#
|
22
|
+
# Specifies a contiguous range of rows.
|
23
|
+
#
|
24
|
+
# * From key bound : The row key at which to begin the range.
|
25
|
+
# If neither field is set, interpreted as an empty string, inclusive.
|
26
|
+
# * End key bound: The row key at which to end the range.
|
27
|
+
# If neither field is set, interpreted as the infinite row key, exclusive.
|
28
|
+
#
|
29
|
+
# @example
|
30
|
+
# require "google/cloud/bigtable"
|
31
|
+
#
|
32
|
+
# bigtable = Google::Cloud::Bigtable.new
|
33
|
+
# table = bigtable.table("my-instance", "my-table")
|
34
|
+
#
|
35
|
+
# # Range that includes all row keys including "user-001" to "user-005"
|
36
|
+
# table.new_row_range.from("user-001").to("user-005", inclusive: true)
|
37
|
+
#
|
38
|
+
# # Range that includes all row keys including "user-001" up to exclusive "user-010".
|
39
|
+
# table.new_row_range.from("user-001").to("user-010")
|
40
|
+
#
|
41
|
+
# # Range that includes all row keys including "user-001" up until end of the row keys.
|
42
|
+
# table.new_row_range.from("user-001")
|
43
|
+
#
|
44
|
+
# # Range that includes all row keys exclusive "user-001" up until end of the row keys.
|
45
|
+
# table.new_row_range.from("user-001", inclusive: false)
|
46
|
+
#
|
47
|
+
# # Range with unbounded from and the exclusive end "user-010"
|
48
|
+
# table.new_row_range.to("user-010")
|
49
|
+
#
|
50
|
+
# # Range that includes all row keys including from and end row keys "user-001", "user-010"
|
51
|
+
# table.new_row_range.between("user-001", "user-010")
|
52
|
+
#
|
53
|
+
# # Range that includes all row keys including "user-001" up until "user-010"
|
54
|
+
# table.new_row_range.of("user-001", "user-010")
|
55
|
+
#
|
56
|
+
class RowRange
|
57
|
+
# @private
|
58
|
+
# Creates a row range instance.
|
59
|
+
def initialize
|
60
|
+
@grpc = Google::Bigtable::V2::RowRange.new
|
61
|
+
end
|
62
|
+
|
63
|
+
##
|
64
|
+
# Sets a row range with a lower bound.
|
65
|
+
#
|
66
|
+
# @param key [String] Row key. Required.
|
67
|
+
# @param inclusive [String] Inclusive/exclusive lower bound.
|
68
|
+
# Default is an inclusive lower bound.
|
69
|
+
# @return [Google::Cloud::Bigtable::RowRange]
|
70
|
+
#
|
71
|
+
# @example Inclusive lower bound.
|
72
|
+
# require "google/cloud/bigtable"
|
73
|
+
#
|
74
|
+
# bigtable = Google::Cloud::Bigtable.new
|
75
|
+
# table = bigtable.table("my-instance", "my-table")
|
76
|
+
#
|
77
|
+
# range = table.new_row_range.from("key-001")
|
78
|
+
#
|
79
|
+
# @example Exclusive lower bound.
|
80
|
+
# require "google/cloud/bigtable"
|
81
|
+
#
|
82
|
+
# bigtable = Google::Cloud::Bigtable.new
|
83
|
+
# table = bigtable.table("my-instance", "my-table")
|
84
|
+
#
|
85
|
+
# range = table.new_row_range.from("key-001", inclusive: false)
|
86
|
+
#
|
87
|
+
def from key, inclusive: true
|
88
|
+
if inclusive
|
89
|
+
@grpc.start_key_closed = key
|
90
|
+
else
|
91
|
+
@grpc.start_key_open = key
|
92
|
+
end
|
93
|
+
self
|
94
|
+
end
|
95
|
+
|
96
|
+
##
|
97
|
+
# Sets a row range with an upper bound.
|
98
|
+
#
|
99
|
+
# @param key [String] Row key. Required.
|
100
|
+
# @param inclusive [String] Inclusive/Exclusive upper bound.
|
101
|
+
# Default it is an exclusive upper bound.
|
102
|
+
# @return [Google::Cloud::Bigtable::RowRange]
|
103
|
+
#
|
104
|
+
# @example Inclusive upper bound.
|
105
|
+
# require "google/cloud/bigtable"
|
106
|
+
#
|
107
|
+
# bigtable = Google::Cloud::Bigtable.new
|
108
|
+
# table = bigtable.table("my-instance", "my-table")
|
109
|
+
#
|
110
|
+
# range = table.new_row_range.to("key-001", inclusive: true)
|
111
|
+
#
|
112
|
+
# @example Exclusive upper bound.
|
113
|
+
# require "google/cloud/bigtable"
|
114
|
+
#
|
115
|
+
# bigtable = Google::Cloud::Bigtable.new
|
116
|
+
# table = bigtable.table("my-instance", "my-table")
|
117
|
+
#
|
118
|
+
# range = table.new_row_range.to("key-001")
|
119
|
+
#
|
120
|
+
def to key, inclusive: false
|
121
|
+
if inclusive
|
122
|
+
@grpc.end_key_closed = key
|
123
|
+
else
|
124
|
+
@grpc.end_key_open = key
|
125
|
+
end
|
126
|
+
self
|
127
|
+
end
|
128
|
+
|
129
|
+
##
|
130
|
+
# Sets a row range with inclusive upper and lower bounds.
|
131
|
+
#
|
132
|
+
# @param from_key [String] Inclusive from row key. Required.
|
133
|
+
# @param to_key [String] Inclusive end row key. Required.
|
134
|
+
# @return [Google::Cloud::Bigtable::RowRange]
|
135
|
+
# Range with inclusive from and end row keys.
|
136
|
+
#
|
137
|
+
# @example
|
138
|
+
# require "google/cloud/bigtable"
|
139
|
+
#
|
140
|
+
# bigtable = Google::Cloud::Bigtable.new
|
141
|
+
# table = bigtable.table("my-instance", "my-table")
|
142
|
+
#
|
143
|
+
# range = table.new_row_range.between("key-001", "key-010")
|
144
|
+
#
|
145
|
+
def between from_key, to_key
|
146
|
+
from(from_key).to(to_key, inclusive: true)
|
147
|
+
end
|
148
|
+
|
149
|
+
##
|
150
|
+
# Sets a row range with an inclusive lower bound and an exclusive upper bound.
|
151
|
+
#
|
152
|
+
# @param from_key [String] Inclusive from row key.
|
153
|
+
# @param to_key [String] Exclusive end row key.
|
154
|
+
# @return [Google::Cloud::Bigtable::RowRange]
|
155
|
+
# Range with inclusive from and exclusive end row key.
|
156
|
+
#
|
157
|
+
# @example
|
158
|
+
# require "google/cloud/bigtable"
|
159
|
+
#
|
160
|
+
# bigtable = Google::Cloud::Bigtable.new
|
161
|
+
# table = bigtable.table("my-instance", "my-table")
|
162
|
+
#
|
163
|
+
# range = table.new_row_range.of("key-001", "key-010")
|
164
|
+
#
|
165
|
+
def of from_key, to_key
|
166
|
+
from(from_key).to(to_key)
|
167
|
+
end
|
168
|
+
|
169
|
+
# @private
|
170
|
+
#
|
171
|
+
# @return [Google::Bigtable::V2::RowRange]
|
172
|
+
#
|
173
|
+
def to_grpc
|
174
|
+
@grpc
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|