google-cloud-bigtable 0.6.2 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +36 -0
  3. data/CONTRIBUTING.md +1 -1
  4. data/lib/google-cloud-bigtable.rb +19 -21
  5. data/lib/google/cloud/bigtable.rb +11 -17
  6. data/lib/google/cloud/bigtable/app_profile.rb +148 -82
  7. data/lib/google/cloud/bigtable/app_profile/job.rb +5 -8
  8. data/lib/google/cloud/bigtable/app_profile/list.rb +11 -5
  9. data/lib/google/cloud/bigtable/chunk_processor.rb +23 -35
  10. data/lib/google/cloud/bigtable/cluster.rb +38 -11
  11. data/lib/google/cloud/bigtable/cluster/job.rb +3 -7
  12. data/lib/google/cloud/bigtable/cluster/list.rb +20 -18
  13. data/lib/google/cloud/bigtable/column_family.rb +22 -229
  14. data/lib/google/cloud/bigtable/column_family_map.rb +426 -0
  15. data/lib/google/cloud/bigtable/column_range.rb +9 -1
  16. data/lib/google/cloud/bigtable/convert.rb +12 -4
  17. data/lib/google/cloud/bigtable/errors.rb +4 -1
  18. data/lib/google/cloud/bigtable/gc_rule.rb +184 -65
  19. data/lib/google/cloud/bigtable/instance.rb +136 -126
  20. data/lib/google/cloud/bigtable/instance/cluster_map.rb +9 -7
  21. data/lib/google/cloud/bigtable/instance/job.rb +4 -3
  22. data/lib/google/cloud/bigtable/instance/list.rb +14 -9
  23. data/lib/google/cloud/bigtable/longrunning_job.rb +6 -0
  24. data/lib/google/cloud/bigtable/mutation_entry.rb +19 -23
  25. data/lib/google/cloud/bigtable/mutation_operations.rb +82 -29
  26. data/lib/google/cloud/bigtable/policy.rb +9 -5
  27. data/lib/google/cloud/bigtable/project.rb +62 -140
  28. data/lib/google/cloud/bigtable/read_modify_write_rule.rb +9 -4
  29. data/lib/google/cloud/bigtable/read_operations.rb +28 -41
  30. data/lib/google/cloud/bigtable/routing_policy.rb +171 -0
  31. data/lib/google/cloud/bigtable/row.rb +18 -7
  32. data/lib/google/cloud/bigtable/row_filter.rb +49 -20
  33. data/lib/google/cloud/bigtable/row_filter/chain_filter.rb +71 -43
  34. data/lib/google/cloud/bigtable/row_filter/condition_filter.rb +4 -1
  35. data/lib/google/cloud/bigtable/row_filter/interleave_filter.rb +74 -43
  36. data/lib/google/cloud/bigtable/row_filter/simple_filter.rb +22 -7
  37. data/lib/google/cloud/bigtable/row_range.rb +5 -0
  38. data/lib/google/cloud/bigtable/rows_mutator.rb +14 -17
  39. data/lib/google/cloud/bigtable/rows_reader.rb +18 -14
  40. data/lib/google/cloud/bigtable/sample_row_key.rb +5 -2
  41. data/lib/google/cloud/bigtable/service.rb +161 -242
  42. data/lib/google/cloud/bigtable/status.rb +76 -0
  43. data/lib/google/cloud/bigtable/table.rb +141 -236
  44. data/lib/google/cloud/bigtable/table/cluster_state.rb +7 -1
  45. data/lib/google/cloud/bigtable/table/list.rb +14 -7
  46. data/lib/google/cloud/bigtable/value_range.rb +5 -0
  47. data/lib/google/cloud/bigtable/version.rb +1 -1
  48. metadata +27 -25
  49. data/lib/google/cloud/bigtable/table/column_family_map.rb +0 -70
@@ -19,6 +19,7 @@ module Google
19
19
  module Cloud
20
20
  module Bigtable
21
21
  class Table
22
+ ##
22
23
  # Table::ClusterState is the state of a table's data in a particular cluster.
23
24
  class ClusterState
24
25
  attr_reader :cluster_name
@@ -31,6 +32,7 @@ module Google
31
32
  @cluster_name = cluster_name
32
33
  end
33
34
 
35
+ ##
34
36
  # The state of replication for the table in this cluster.
35
37
  # Valid values are:
36
38
  # * `:INITIALIZING` - The cluster was recently created.
@@ -43,6 +45,7 @@ module Google
43
45
  @grpc.replication_state
44
46
  end
45
47
 
48
+ ##
46
49
  # The cluster was recently created, and the table must finish copying
47
50
  # over pre-existing data from other clusters before it can begin
48
51
  # receiving live replication updates and serving.
@@ -52,6 +55,7 @@ module Google
52
55
  replication_state == :INITIALIZING
53
56
  end
54
57
 
58
+ ##
55
59
  # The table is temporarily unable to serve
56
60
  # requests from this cluster due to planned internal maintenance.
57
61
  # @return [Boolean]
@@ -60,6 +64,7 @@ module Google
60
64
  replication_state == :PLANNED_MAINTENANCE
61
65
  end
62
66
 
67
+ ##
63
68
  # The table is temporarily unable to serve requests from this
64
69
  # cluster due to unplanned or emergency maintenance.
65
70
  # @return [Boolean]
@@ -68,6 +73,7 @@ module Google
68
73
  replication_state == :UNPLANNED_MAINTENANCE
69
74
  end
70
75
 
76
+ ##
71
77
  # The table can serve requests from this cluster.
72
78
  # Depending on replication delay, reads may not immediately
73
79
  # reflect the state of the table in other clusters.
@@ -84,7 +90,7 @@ module Google
84
90
  # @return [Google::Cloud::Bigtable::Table::ClusterState]
85
91
  #
86
92
  def self.from_grpc grpc, cluster_name
87
- new(grpc, cluster_name)
93
+ new grpc, cluster_name
88
94
  end
89
95
  end
90
96
  end
@@ -19,8 +19,10 @@ module Google
19
19
  module Cloud
20
20
  module Bigtable
21
21
  class Table
22
+ ##
22
23
  # Table::List is a special-case array with additional
23
24
  # values.
25
+ #
24
26
  class List < DelegateClass(::Array)
25
27
  # @private
26
28
  # The gRPC Service object.
@@ -33,9 +35,10 @@ module Google
33
35
  # @private
34
36
  # Creates a new Table::List with an array of table instances.
35
37
  def initialize arr = []
36
- super(arr)
38
+ super arr
37
39
  end
38
40
 
41
+ ##
39
42
  # Whether there is a next page of tables.
40
43
  #
41
44
  # @return [Boolean]
@@ -49,10 +52,12 @@ module Google
49
52
  # if tables.next?
50
53
  # next_tables = tables.next
51
54
  # end
55
+ #
52
56
  def next?
53
57
  grpc.next_page?
54
58
  end
55
59
 
60
+ ##
56
61
  # Retrieves the next page of tables.
57
62
  #
58
63
  # @return [Table::List] The list of table instances.
@@ -66,14 +71,16 @@ module Google
66
71
  # if tables.next?
67
72
  # next_tables = tables.next
68
73
  # end
74
+ #
69
75
  def next
70
76
  ensure_grpc!
71
77
 
72
78
  return nil unless next?
73
79
  grpc.next_page
74
- self.class.from_grpc(grpc, service)
80
+ self.class.from_grpc grpc, service
75
81
  end
76
82
 
83
+ ##
77
84
  # Retrieves remaining results by repeatedly invoking {#next} until
78
85
  # {#next?} returns `false`. Calls the given block once for each
79
86
  # result, which is passed as the argument to the block.
@@ -94,7 +101,7 @@ module Google
94
101
  #
95
102
  # bigtable = Google::Cloud::Bigtable.new
96
103
  #
97
- # bigtable.tables("instance-id").all do |table|
104
+ # bigtable.tables("my-instance").all do |table|
98
105
  # puts table.table_id
99
106
  # end
100
107
  #
@@ -103,19 +110,19 @@ module Google
103
110
  #
104
111
  # bigtable = Google::Cloud::Bigtable.new
105
112
  #
106
- # all_table_ids = bigtable.tables("instance-id").all.map do |table|
113
+ # all_table_ids = bigtable.tables("my-instance").all.map do |table|
107
114
  # puts table.table_id
108
115
  # end
109
116
  #
110
117
  def all
111
- return enum_for(:all) unless block_given?
118
+ return enum_for :all unless block_given?
112
119
 
113
120
  results = self
114
121
  loop do
115
122
  results.each { |r| yield r }
116
123
  break unless next?
117
124
  grpc.next_page
118
- results = self.class.from_grpc(grpc, service)
125
+ results = self.class.from_grpc grpc, service
119
126
  end
120
127
  end
121
128
 
@@ -124,7 +131,7 @@ module Google
124
131
  #
125
132
  def self.from_grpc grpc, service
126
133
  tables = List.new(Array(grpc.response.tables).map do |table|
127
- Table.from_grpc(table, service, view: :NAME_ONLY)
134
+ Table.from_grpc table, service, view: :NAME_ONLY
128
135
  end)
129
136
  tables.grpc = grpc
130
137
  tables.service = service
@@ -18,6 +18,7 @@
18
18
  module Google
19
19
  module Cloud
20
20
  module Bigtable
21
+ ##
21
22
  # # ValueRange
22
23
  #
23
24
  # Specifies a contiguous range of string values.
@@ -61,6 +62,7 @@ module Google
61
62
  @grpc = Google::Bigtable::V2::ValueRange.new
62
63
  end
63
64
 
65
+ ##
64
66
  # Sets the row range with the lower bound.
65
67
  #
66
68
  # @param value [String] value. Required
@@ -93,6 +95,7 @@ module Google
93
95
  self
94
96
  end
95
97
 
98
+ ##
96
99
  # Sets the value range with upper bound.
97
100
  #
98
101
  # @param value [String] value. Required
@@ -125,6 +128,7 @@ module Google
125
128
  self
126
129
  end
127
130
 
131
+ ##
128
132
  # Sets the value range with the inclusive lower and upper bound.
129
133
  #
130
134
  # @param from_value [String] Inclusive from value. Required
@@ -144,6 +148,7 @@ module Google
144
148
  from(from_value).to(to_value, inclusive: true)
145
149
  end
146
150
 
151
+ ##
147
152
  # Set value range with the inclusive lower and the exclusive upper bound.
148
153
  #
149
154
  # @param from_value [String] Inclusive from value
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Bigtable
19
- VERSION = "0.6.2".freeze
19
+ VERSION = "0.7.0".freeze
20
20
  end
21
21
  end
22
22
  end
metadata CHANGED
@@ -1,29 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-cloud-bigtable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Google LLC
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-02 00:00:00.000000000 Z
11
+ date: 2019-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: google-cloud-core
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.1'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: google-gax
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
31
  - - "~>"
18
32
  - !ruby/object:Gem::Version
19
- version: '1.7'
33
+ version: '1.8'
20
34
  type: :runtime
21
35
  prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
24
38
  - - "~>"
25
39
  - !ruby/object:Gem::Version
26
- version: '1.7'
40
+ version: '1.8'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: grpc-google-iam-v1
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -39,19 +53,19 @@ dependencies:
39
53
  - !ruby/object:Gem::Version
40
54
  version: 0.6.9
41
55
  - !ruby/object:Gem::Dependency
42
- name: google-cloud-core
56
+ name: google-style
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - "~>"
46
60
  - !ruby/object:Gem::Version
47
- version: '1.1'
48
- type: :runtime
61
+ version: 1.24.0
62
+ type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
66
  - - "~>"
53
67
  - !ruby/object:Gem::Version
54
- version: '1.1'
68
+ version: 1.24.0
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: minitest
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -108,20 +122,6 @@ dependencies:
108
122
  - - "~>"
109
123
  - !ruby/object:Gem::Version
110
124
  version: '3.0'
111
- - !ruby/object:Gem::Dependency
112
- name: rubocop
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: 0.64.0
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - "~>"
123
- - !ruby/object:Gem::Version
124
- version: 0.64.0
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: simplecov
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -223,6 +223,7 @@ files:
223
223
  - lib/google/cloud/bigtable/cluster/job.rb
224
224
  - lib/google/cloud/bigtable/cluster/list.rb
225
225
  - lib/google/cloud/bigtable/column_family.rb
226
+ - lib/google/cloud/bigtable/column_family_map.rb
226
227
  - lib/google/cloud/bigtable/column_range.rb
227
228
  - lib/google/cloud/bigtable/convert.rb
228
229
  - lib/google/cloud/bigtable/credentials.rb
@@ -239,6 +240,7 @@ files:
239
240
  - lib/google/cloud/bigtable/project.rb
240
241
  - lib/google/cloud/bigtable/read_modify_write_rule.rb
241
242
  - lib/google/cloud/bigtable/read_operations.rb
243
+ - lib/google/cloud/bigtable/routing_policy.rb
242
244
  - lib/google/cloud/bigtable/row.rb
243
245
  - lib/google/cloud/bigtable/row_filter.rb
244
246
  - lib/google/cloud/bigtable/row_filter/chain_filter.rb
@@ -250,9 +252,9 @@ files:
250
252
  - lib/google/cloud/bigtable/rows_reader.rb
251
253
  - lib/google/cloud/bigtable/sample_row_key.rb
252
254
  - lib/google/cloud/bigtable/service.rb
255
+ - lib/google/cloud/bigtable/status.rb
253
256
  - lib/google/cloud/bigtable/table.rb
254
257
  - lib/google/cloud/bigtable/table/cluster_state.rb
255
- - lib/google/cloud/bigtable/table/column_family_map.rb
256
258
  - lib/google/cloud/bigtable/table/list.rb
257
259
  - lib/google/cloud/bigtable/v2.rb
258
260
  - lib/google/cloud/bigtable/v2/bigtable_client.rb
@@ -277,14 +279,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
277
279
  requirements:
278
280
  - - ">="
279
281
  - !ruby/object:Gem::Version
280
- version: 2.0.0
282
+ version: '2.4'
281
283
  required_rubygems_version: !ruby/object:Gem::Requirement
282
284
  requirements:
283
285
  - - ">="
284
286
  - !ruby/object:Gem::Version
285
287
  version: '0'
286
288
  requirements: []
287
- rubygems_version: 3.0.4
289
+ rubygems_version: 3.0.6
288
290
  signing_key:
289
291
  specification_version: 4
290
292
  summary: API Client library for Cloud Bigtable API
@@ -1,70 +0,0 @@
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
- class Table
22
- # Table::ColumnFamilyMap is a hash accepting string `ColumnFamily` names as keys and `GcRule` objects as values.
23
- # It is used to create an instance.
24
- # @example Add column family with name and garbage collection rule
25
- #
26
- # column_families = Google::Cloud::Bigtable::Instance::ColumnFamilyMap.new
27
- #
28
- # column_families.add('cf1', Google::Cloud::Bigtable::GcRule.max_versions(3))
29
- #
30
- class ColumnFamilyMap < DelegateClass(::Hash)
31
- # @private
32
- # Create a new ColumnFamilyMap.
33
- def initialize value = {}
34
- super(value)
35
- end
36
-
37
- # Adds a column family.
38
- #
39
- # @param name [String] Column family name
40
- # @param gc_rule [Google::Cloud::Bigtable::GcRule] The garbage
41
- # collection rule to be used for the column family. Optional. The
42
- # service default value will be used when not specified.
43
- # @example
44
- # column_families = Google::Cloud::Bigtable::Instance::ColumnFamilyMap.new
45
- #
46
- # gc_rule_1 = Google::Cloud::Bigtable::GcRule.max_versions(3)
47
- # column_families.add('cf1', gc_rule_1)
48
- #
49
- # gc_rule = Google::Cloud::Bigtable::GcRule.max_age(1800)
50
- # column_families.add('cf2', gc_rule)
51
-
52
- def add name, gc_rule = nil
53
- cf = Google::Bigtable::Admin::V2::ColumnFamily.new
54
- cf.gc_rule = gc_rule.to_grpc if gc_rule
55
- self[name] = cf
56
- end
57
-
58
- # Removes a column family from the map.
59
- #
60
- # @param name [String] Column family name
61
- # @return [Google::Bigtable::Admin::V2::ColumnFamily]
62
-
63
- def remove name
64
- delete(name)
65
- end
66
- end
67
- end
68
- end
69
- end
70
- end