google-cloud-bigtable 1.3.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.
- 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,134 @@
|
|
|
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
|
+
##
|
|
22
|
+
# # ReadModifyWriteRule
|
|
23
|
+
#
|
|
24
|
+
# Specifies an atomic read/modify/write operation on the latest value of the
|
|
25
|
+
# specified column.
|
|
26
|
+
#
|
|
27
|
+
# @example Append value rule
|
|
28
|
+
# rule = Google::Cloud::Bigtable::ReadModifyWriteRule.append(
|
|
29
|
+
# "cf", "field01", "append-xyz"
|
|
30
|
+
# )
|
|
31
|
+
#
|
|
32
|
+
# @example increment value rule
|
|
33
|
+
# rule = Google::Cloud::Bigtable::ReadModifyWriteRule.increment(
|
|
34
|
+
# "cf", "field01", 1
|
|
35
|
+
# )
|
|
36
|
+
#
|
|
37
|
+
class ReadModifyWriteRule
|
|
38
|
+
# @private
|
|
39
|
+
# Creates an instance of ReadModifyWriteRule
|
|
40
|
+
#
|
|
41
|
+
# @param family [String]
|
|
42
|
+
# The name of the family to which the read/modify/write should be applied.
|
|
43
|
+
# @param qualifier [String]
|
|
44
|
+
# The qualifier of the column to which the read/modify/write should be applied.
|
|
45
|
+
#
|
|
46
|
+
def initialize family, qualifier
|
|
47
|
+
@grpc = Google::Bigtable::V2::ReadModifyWriteRule.new
|
|
48
|
+
@grpc.family_name = family
|
|
49
|
+
@grpc.column_qualifier = qualifier
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
##
|
|
53
|
+
# Creates an instance of an append-value rule.
|
|
54
|
+
#
|
|
55
|
+
# @param family [String]
|
|
56
|
+
# The name of the family to which the read/modify/write should be applied.
|
|
57
|
+
# @param qualifier [String]
|
|
58
|
+
# The qualifier of the column to which the read/modify/write should be applied.
|
|
59
|
+
# @param value [String]
|
|
60
|
+
# Rule specifying that `append_value` be appended to the existing value.
|
|
61
|
+
# If the targeted cell is unset, it will be treated as if it contains an empty string.
|
|
62
|
+
# @return [Google::Cloud::Bigtable::ReadModifyWriteRule]
|
|
63
|
+
#
|
|
64
|
+
# @example Append value rule
|
|
65
|
+
# rule = Google::Cloud::Bigtable::ReadModifyWriteRule.append(
|
|
66
|
+
# "cf", "field01", "append-xyz"
|
|
67
|
+
# )
|
|
68
|
+
#
|
|
69
|
+
def self.append family, qualifier, value
|
|
70
|
+
rule = new family, qualifier
|
|
71
|
+
rule.append value
|
|
72
|
+
rule
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
##
|
|
76
|
+
# Creates an instance of an increment-amount rule.
|
|
77
|
+
#
|
|
78
|
+
# @param family [String]
|
|
79
|
+
# The name of the family to which the read/modify/write should be applied.
|
|
80
|
+
# @param qualifier [String]
|
|
81
|
+
# The qualifier of the column to which the read/modify/write should be applied.
|
|
82
|
+
# @param amount [String]
|
|
83
|
+
# Rule specifying that `increment_amount` be added to the existing value.
|
|
84
|
+
# If the targeted cell is unset, it will be treated as if it contains a zero.
|
|
85
|
+
# Otherwise, the targeted cell must contain an 8-byte value (interpreted
|
|
86
|
+
# as a 64-bit big-endian signed integer), or the entire request will fail.
|
|
87
|
+
# @return [Google::Cloud::Bigtable::ReadModifyWriteRule]
|
|
88
|
+
#
|
|
89
|
+
# @example
|
|
90
|
+
# rule = Google::Cloud::Bigtable::ReadModifyWriteRule.increment(
|
|
91
|
+
# "cf", "field01", 1
|
|
92
|
+
# )
|
|
93
|
+
#
|
|
94
|
+
def self.increment family, qualifier, amount
|
|
95
|
+
rule = new family, qualifier
|
|
96
|
+
rule.increment amount
|
|
97
|
+
rule
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
##
|
|
101
|
+
# Sets the append value.
|
|
102
|
+
#
|
|
103
|
+
# @param value [String]
|
|
104
|
+
# @return [Google::Cloud::Bigtable::ReadModifyWriteRule]
|
|
105
|
+
#
|
|
106
|
+
def append value
|
|
107
|
+
@grpc.append_value = value
|
|
108
|
+
self
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
##
|
|
112
|
+
# Sets the increment amount.
|
|
113
|
+
#
|
|
114
|
+
# @param amount [Integer]
|
|
115
|
+
# @return [Google::Cloud::Bigtable::ReadModifyWriteRule]
|
|
116
|
+
#
|
|
117
|
+
def increment amount
|
|
118
|
+
@grpc.increment_amount = amount
|
|
119
|
+
self
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
# @private
|
|
123
|
+
#
|
|
124
|
+
# Get gRPC protobuf instance.
|
|
125
|
+
#
|
|
126
|
+
# @return [Google::Bigtable::V2::ReadModifyWriteRule]
|
|
127
|
+
#
|
|
128
|
+
def to_grpc
|
|
129
|
+
@grpc
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
end
|
|
@@ -0,0 +1,328 @@
|
|
|
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
|
+
require "google/cloud/bigtable/row"
|
|
19
|
+
require "google/cloud/bigtable/rows_reader"
|
|
20
|
+
require "google/cloud/bigtable/row_range"
|
|
21
|
+
require "google/cloud/bigtable/row_filter"
|
|
22
|
+
require "google/cloud/bigtable/sample_row_key"
|
|
23
|
+
|
|
24
|
+
module Google
|
|
25
|
+
module Cloud
|
|
26
|
+
module Bigtable
|
|
27
|
+
##
|
|
28
|
+
# # ReadOperations
|
|
29
|
+
#
|
|
30
|
+
# Collection of read-rows APIs.
|
|
31
|
+
#
|
|
32
|
+
# * Sample row key
|
|
33
|
+
# * Read row
|
|
34
|
+
# * Read rows
|
|
35
|
+
#
|
|
36
|
+
module ReadOperations
|
|
37
|
+
##
|
|
38
|
+
# Reads sample row keys.
|
|
39
|
+
#
|
|
40
|
+
# Returns a sample of row keys in the table. The returned row keys will
|
|
41
|
+
# delimit contiguous sections of the table of approximately equal size. The
|
|
42
|
+
# sections can be used to break up the data for distributed tasks like
|
|
43
|
+
# MapReduces.
|
|
44
|
+
#
|
|
45
|
+
# @yieldreturn [Google::Cloud::Bigtable::SampleRowKey]
|
|
46
|
+
# @return [:yields: sample_row_key]
|
|
47
|
+
# Yield block for each processed SampleRowKey.
|
|
48
|
+
#
|
|
49
|
+
# @example
|
|
50
|
+
# require "google/cloud/bigtable"
|
|
51
|
+
#
|
|
52
|
+
# bigtable = Google::Cloud::Bigtable.new
|
|
53
|
+
# table = bigtable.table("my-instance", "my-table")
|
|
54
|
+
#
|
|
55
|
+
# table.sample_row_keys.each do |sample_row_key|
|
|
56
|
+
# p sample_row_key.key # user00116
|
|
57
|
+
# p sample_row_key.offset # 805306368
|
|
58
|
+
# end
|
|
59
|
+
#
|
|
60
|
+
def sample_row_keys
|
|
61
|
+
return enum_for :sample_row_keys unless block_given?
|
|
62
|
+
|
|
63
|
+
response = service.sample_row_keys path, app_profile_id: @app_profile_id
|
|
64
|
+
response.each do |grpc|
|
|
65
|
+
yield SampleRowKey.from_grpc grpc
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
##
|
|
70
|
+
# Reads rows.
|
|
71
|
+
#
|
|
72
|
+
# Streams back the contents of all requested rows in key order, optionally
|
|
73
|
+
# applying the same Reader filter to each.
|
|
74
|
+
# `read_rows`, `row_ranges` and `filter` if not specified, reads from all rows.
|
|
75
|
+
#
|
|
76
|
+
# See {Google::Cloud::Bigtable::RowFilter} for filter types.
|
|
77
|
+
#
|
|
78
|
+
# @param keys [Array<String>] List of row keys to be read. Optional.
|
|
79
|
+
# @param ranges [Google::Cloud::Bigtable::RowRange | Array<Google::Cloud::Bigtable::RowRange>]
|
|
80
|
+
# Row ranges array or single range. Optional.
|
|
81
|
+
# @param filter [SimpleFilter, ChainFilter, InterleaveFilter, ConditionFilter]
|
|
82
|
+
# The filter to apply to the contents of the specified row(s). If unset,
|
|
83
|
+
# reads the entries of each row. Optional.
|
|
84
|
+
# @param limit [Integer] Limit number of read rows count. Optional.
|
|
85
|
+
# The read will terminate after committing to N rows' worth of results.
|
|
86
|
+
# The default (zero) is to return all results.
|
|
87
|
+
# @return [Array<Google::Cloud::Bigtable::Row> | :yields: row]
|
|
88
|
+
# Array of row or yield block for each processed row.
|
|
89
|
+
# @example Read with limit.
|
|
90
|
+
# require "google/cloud/bigtable"
|
|
91
|
+
#
|
|
92
|
+
# bigtable = Google::Cloud::Bigtable.new
|
|
93
|
+
# table = bigtable.table("my-instance", "my-table")
|
|
94
|
+
#
|
|
95
|
+
# table.read_rows(limit: 10).each do |row|
|
|
96
|
+
# puts row
|
|
97
|
+
# end
|
|
98
|
+
#
|
|
99
|
+
# @example Read using row keys.
|
|
100
|
+
# require "google/cloud/bigtable"
|
|
101
|
+
#
|
|
102
|
+
# bigtable = Google::Cloud::Bigtable.new
|
|
103
|
+
# table = bigtable.table("my-instance", "my-table")
|
|
104
|
+
#
|
|
105
|
+
# table.read_rows(keys: ["user-1", "user-2"]).each do |row|
|
|
106
|
+
# puts row
|
|
107
|
+
# end
|
|
108
|
+
#
|
|
109
|
+
# @example Read using row ranges.
|
|
110
|
+
# require "google/cloud/bigtable"
|
|
111
|
+
#
|
|
112
|
+
# bigtable = Google::Cloud::Bigtable.new
|
|
113
|
+
# table = bigtable.table("my-instance", "my-table")
|
|
114
|
+
#
|
|
115
|
+
# range = table.new_row_range.between("user-1", "user-100")
|
|
116
|
+
#
|
|
117
|
+
# table.read_rows(ranges: range).each do |row|
|
|
118
|
+
# puts row
|
|
119
|
+
# end
|
|
120
|
+
#
|
|
121
|
+
# @example Read using filter.
|
|
122
|
+
# require "google/cloud/bigtable"
|
|
123
|
+
#
|
|
124
|
+
# bigtable = Google::Cloud::Bigtable.new
|
|
125
|
+
# table = bigtable.table("my-instance", "my-table")
|
|
126
|
+
#
|
|
127
|
+
# filter = table.filter.key("user-*")
|
|
128
|
+
# # OR
|
|
129
|
+
# # filter = Google::Cloud::Bigtable::RowFilter.key("user-*")
|
|
130
|
+
#
|
|
131
|
+
# table.read_rows(filter: filter).each do |row|
|
|
132
|
+
# puts row
|
|
133
|
+
# end
|
|
134
|
+
#
|
|
135
|
+
# @example Read using filter with limit.
|
|
136
|
+
# require "google/cloud/bigtable"
|
|
137
|
+
#
|
|
138
|
+
# bigtable = Google::Cloud::Bigtable.new
|
|
139
|
+
# table = bigtable.table("my-instance", "my-table")
|
|
140
|
+
#
|
|
141
|
+
# filter = table.filter.key("user-*")
|
|
142
|
+
# # OR
|
|
143
|
+
# # filter = Google::Cloud::Bigtable::RowFilter.key("user-*")
|
|
144
|
+
#
|
|
145
|
+
# table.read_rows(filter: filter, limit: 10).each do |row|
|
|
146
|
+
# puts row
|
|
147
|
+
# end
|
|
148
|
+
#
|
|
149
|
+
def read_rows keys: nil, ranges: nil, filter: nil, limit: nil, &block
|
|
150
|
+
return enum_for :read_rows, keys: keys, ranges: ranges, filter: filter, limit: limit unless block_given?
|
|
151
|
+
|
|
152
|
+
row_set = build_row_set keys, ranges
|
|
153
|
+
rows_limit = limit
|
|
154
|
+
rows_filter = filter.to_grpc if filter
|
|
155
|
+
rows_reader = RowsReader.new self
|
|
156
|
+
|
|
157
|
+
begin
|
|
158
|
+
rows_reader.read rows: row_set, filter: rows_filter, rows_limit: rows_limit, &block
|
|
159
|
+
rescue *RowsReader::RETRYABLE_ERRORS => e
|
|
160
|
+
rows_reader.retry_count += 1
|
|
161
|
+
raise Google::Cloud::Error.from_error(e) unless rows_reader.retryable?
|
|
162
|
+
rows_limit, row_set = rows_reader.retry_options limit, row_set
|
|
163
|
+
retry
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
##
|
|
168
|
+
# Reads a single row by row key.
|
|
169
|
+
#
|
|
170
|
+
# @param key [String] Row key. Required.
|
|
171
|
+
# @param filter [Google::Cloud::Bigtable::RowFilter]
|
|
172
|
+
# The filter to apply to the contents of the specified row. Optional.
|
|
173
|
+
# @return [Google::Cloud::Bigtable::Row]
|
|
174
|
+
#
|
|
175
|
+
# @example
|
|
176
|
+
# require "google/cloud/bigtable"
|
|
177
|
+
#
|
|
178
|
+
# bigtable = Google::Cloud::Bigtable.new
|
|
179
|
+
# table = bigtable.table("my-instance", "my-table")
|
|
180
|
+
#
|
|
181
|
+
# row = table.read_row("user-1")
|
|
182
|
+
#
|
|
183
|
+
# @example Read row with filter.
|
|
184
|
+
# require "google/cloud/bigtable"
|
|
185
|
+
#
|
|
186
|
+
# bigtable = Google::Cloud::Bigtable.new
|
|
187
|
+
# table = bigtable.table("my-instance", "my-table")
|
|
188
|
+
#
|
|
189
|
+
# filter = Google::Cloud::Bigtable::RowFilter.cells_per_row(3)
|
|
190
|
+
#
|
|
191
|
+
# row = table.read_row("user-1", filter: filter)
|
|
192
|
+
#
|
|
193
|
+
def read_row key, filter: nil
|
|
194
|
+
read_rows(keys: [key], filter: filter).first
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
##
|
|
198
|
+
# Creates a new instance of ValueRange.
|
|
199
|
+
#
|
|
200
|
+
# @return [Google::Cloud::Bigtable::ValueRange]
|
|
201
|
+
#
|
|
202
|
+
# @example
|
|
203
|
+
# require "google/cloud/bigtable"
|
|
204
|
+
#
|
|
205
|
+
# bigtable = Google::Cloud::Bigtable.new
|
|
206
|
+
# table = bigtable.table("my-instance", "my-table")
|
|
207
|
+
#
|
|
208
|
+
# range = table.new_value_range
|
|
209
|
+
# range.from("abc")
|
|
210
|
+
# range.to("xyz")
|
|
211
|
+
#
|
|
212
|
+
# # OR
|
|
213
|
+
# range = table.new_value_range.from("abc").to("xyz")
|
|
214
|
+
#
|
|
215
|
+
# @example With exclusive from range.
|
|
216
|
+
# require "google/cloud/bigtable"
|
|
217
|
+
#
|
|
218
|
+
# bigtable = Google::Cloud::Bigtable.new
|
|
219
|
+
# table = bigtable.table("my-instance", "my-table")
|
|
220
|
+
#
|
|
221
|
+
# range = table.new_value_range.from("abc", inclusive: false).to("xyz")
|
|
222
|
+
#
|
|
223
|
+
def new_value_range
|
|
224
|
+
Google::Cloud::Bigtable::ValueRange.new
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
##
|
|
228
|
+
# Gets a new instance of ColumnRange.
|
|
229
|
+
#
|
|
230
|
+
# @param family [String] Column family name.
|
|
231
|
+
# @return [Google::Cloud::Bigtable::ColumnRange]
|
|
232
|
+
#
|
|
233
|
+
# @example
|
|
234
|
+
# require "google/cloud/bigtable"
|
|
235
|
+
#
|
|
236
|
+
# bigtable = Google::Cloud::Bigtable.new
|
|
237
|
+
# table = bigtable.table("my-instance", "my-table")
|
|
238
|
+
#
|
|
239
|
+
# range = table.new_column_range("test-family")
|
|
240
|
+
# range.from("abc")
|
|
241
|
+
# range.to("xyz")
|
|
242
|
+
#
|
|
243
|
+
# # OR
|
|
244
|
+
# range = table.new_column_range("test-family").from("key-1").to("key-5")
|
|
245
|
+
#
|
|
246
|
+
# @example With exclusive from range.
|
|
247
|
+
# require "google/cloud/bigtable"
|
|
248
|
+
#
|
|
249
|
+
# bigtable = Google::Cloud::Bigtable.new
|
|
250
|
+
# table = bigtable.table("my-instance", "my-table")
|
|
251
|
+
#
|
|
252
|
+
# range = table.new_column_range("test-family").from("key-1", inclusive: false).to("key-5")
|
|
253
|
+
#
|
|
254
|
+
def new_column_range family
|
|
255
|
+
Google::Cloud::Bigtable::ColumnRange.new family
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
##
|
|
259
|
+
# Gets a new instance of RowRange.
|
|
260
|
+
#
|
|
261
|
+
# @return [Google::Cloud::Bigtable::RowRange]
|
|
262
|
+
#
|
|
263
|
+
# @example
|
|
264
|
+
# require "google/cloud/bigtable"
|
|
265
|
+
#
|
|
266
|
+
# bigtable = Google::Cloud::Bigtable.new
|
|
267
|
+
# table = bigtable.table("my-instance", "my-table")
|
|
268
|
+
#
|
|
269
|
+
# range = table.new_row_range
|
|
270
|
+
# range.from("abc")
|
|
271
|
+
# range.to("xyz")
|
|
272
|
+
#
|
|
273
|
+
# # OR
|
|
274
|
+
# range = table.new_row_range.from("key-1").to("key-5")
|
|
275
|
+
#
|
|
276
|
+
# @example With exclusive from range.
|
|
277
|
+
# require "google/cloud/bigtable"
|
|
278
|
+
#
|
|
279
|
+
# bigtable = Google::Cloud::Bigtable.new
|
|
280
|
+
# table = bigtable.table("my-instance", "my-table")
|
|
281
|
+
#
|
|
282
|
+
# range = table.new_row_range.from("key-1", inclusive: false).to("key-5")
|
|
283
|
+
#
|
|
284
|
+
def new_row_range
|
|
285
|
+
Google::Cloud::Bigtable::RowRange.new
|
|
286
|
+
end
|
|
287
|
+
|
|
288
|
+
##
|
|
289
|
+
# Gets a row filter.
|
|
290
|
+
#
|
|
291
|
+
# @return [Google::Cloud::Bigtable::RowRange]
|
|
292
|
+
#
|
|
293
|
+
# @example
|
|
294
|
+
# require "google/cloud/bigtable"
|
|
295
|
+
#
|
|
296
|
+
# bigtable = Google::Cloud::Bigtable.new
|
|
297
|
+
# table = bigtable.table("my-instance", "my-table")
|
|
298
|
+
#
|
|
299
|
+
# filter = table.filter.key("user-*")
|
|
300
|
+
#
|
|
301
|
+
def filter
|
|
302
|
+
Google::Cloud::Bigtable::RowFilter
|
|
303
|
+
end
|
|
304
|
+
|
|
305
|
+
private
|
|
306
|
+
|
|
307
|
+
##
|
|
308
|
+
# Builds a RowSet object from row keys and row ranges.
|
|
309
|
+
#
|
|
310
|
+
# @param row_keys [Array<String>]
|
|
311
|
+
# @param row_ranges [Google::Cloud::Bigtable::RowRange | Array<Google::Cloud::Bigtable::RowRange>]
|
|
312
|
+
# @return [Google::Bigtable::V2::RowSet]
|
|
313
|
+
#
|
|
314
|
+
def build_row_set row_keys, row_ranges
|
|
315
|
+
row_set = {}
|
|
316
|
+
row_set[:row_keys] = row_keys if row_keys
|
|
317
|
+
|
|
318
|
+
if row_ranges
|
|
319
|
+
row_ranges = [row_ranges] unless row_ranges.instance_of? Array
|
|
320
|
+
row_set[:row_ranges] = row_ranges.map(&:to_grpc)
|
|
321
|
+
end
|
|
322
|
+
|
|
323
|
+
Google::Bigtable::V2::RowSet.new row_set
|
|
324
|
+
end
|
|
325
|
+
end
|
|
326
|
+
end
|
|
327
|
+
end
|
|
328
|
+
end
|