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,172 @@
|
|
|
1
|
+
# Copyright 2019 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
|
+
# # RoutingPolicy
|
|
21
|
+
#
|
|
22
|
+
# An abstract routing policy.
|
|
23
|
+
#
|
|
24
|
+
# See subclasses for concrete implementations:
|
|
25
|
+
# * {Google::Cloud::Bigtable::MultiClusterRoutingUseAny} - Read/write
|
|
26
|
+
# requests may be routed to any cluster in the instance and will
|
|
27
|
+
# fail over to another cluster in the event of transient errors or
|
|
28
|
+
# delays. Choosing this option sacrifices read-your-writes
|
|
29
|
+
# consistency to improve availability.
|
|
30
|
+
# * {Google::Cloud::Bigtable::SingleClusterRouting} - Unconditionally
|
|
31
|
+
# routes all read/write requests to a specific cluster. This option
|
|
32
|
+
# preserves read-your-writes consistency but does not improve
|
|
33
|
+
# availability. Value contains `cluster_id` and optional field
|
|
34
|
+
# `allow_transactional_writes`.
|
|
35
|
+
#
|
|
36
|
+
# @example Create an app profile with a single cluster routing policy.
|
|
37
|
+
# require "google/cloud/bigtable"
|
|
38
|
+
#
|
|
39
|
+
# bigtable = Google::Cloud::Bigtable.new
|
|
40
|
+
#
|
|
41
|
+
# instance = bigtable.instance("my-instance")
|
|
42
|
+
#
|
|
43
|
+
# routing_policy = Google::Cloud::Bigtable::AppProfile.single_cluster_routing(
|
|
44
|
+
# "my-instance-cluster-1",
|
|
45
|
+
# allow_transactional_writes: true
|
|
46
|
+
# )
|
|
47
|
+
#
|
|
48
|
+
# app_profile = instance.create_app_profile(
|
|
49
|
+
# "my-app-profile",
|
|
50
|
+
# routing_policy,
|
|
51
|
+
# description: "App profile for user data instance"
|
|
52
|
+
# )
|
|
53
|
+
# puts app_profile.routing_policy
|
|
54
|
+
#
|
|
55
|
+
# @example Create an app profile with multi-cluster routing policy.
|
|
56
|
+
# require "google/cloud/bigtable"
|
|
57
|
+
#
|
|
58
|
+
# bigtable = Google::Cloud::Bigtable.new
|
|
59
|
+
#
|
|
60
|
+
# instance = bigtable.instance("my-instance")
|
|
61
|
+
#
|
|
62
|
+
# routing_policy = Google::Cloud::Bigtable::AppProfile.multi_cluster_routing
|
|
63
|
+
#
|
|
64
|
+
# app_profile = instance.create_app_profile(
|
|
65
|
+
# "my-app-profile",
|
|
66
|
+
# routing_policy,
|
|
67
|
+
# description: "App profile for user data instance"
|
|
68
|
+
# )
|
|
69
|
+
# puts app_profile.routing_policy
|
|
70
|
+
#
|
|
71
|
+
class RoutingPolicy
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
##
|
|
75
|
+
# A multi-cluster routing policy for all read/write requests that use the
|
|
76
|
+
# associated app profile.
|
|
77
|
+
#
|
|
78
|
+
# Read/write requests may be routed to any cluster in the instance, and will
|
|
79
|
+
# fail over to another cluster in the event of transient errors or delays.
|
|
80
|
+
# Choosing this option sacrifices read-your-writes consistency to improve
|
|
81
|
+
# availability.
|
|
82
|
+
#
|
|
83
|
+
# @example
|
|
84
|
+
# require "google/cloud/bigtable"
|
|
85
|
+
#
|
|
86
|
+
# bigtable = Google::Cloud::Bigtable.new
|
|
87
|
+
#
|
|
88
|
+
# instance = bigtable.instance("my-instance")
|
|
89
|
+
#
|
|
90
|
+
# routing_policy = Google::Cloud::Bigtable::AppProfile.multi_cluster_routing
|
|
91
|
+
#
|
|
92
|
+
# app_profile = instance.create_app_profile(
|
|
93
|
+
# "my-app-profile",
|
|
94
|
+
# routing_policy,
|
|
95
|
+
# description: "App profile for user data instance"
|
|
96
|
+
# )
|
|
97
|
+
# puts app_profile.routing_policy
|
|
98
|
+
#
|
|
99
|
+
class MultiClusterRoutingUseAny < RoutingPolicy
|
|
100
|
+
# @private
|
|
101
|
+
def to_grpc
|
|
102
|
+
Google::Bigtable::Admin::V2::AppProfile::MultiClusterRoutingUseAny.new
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
##
|
|
107
|
+
# A single-cluster routing policy for all read/write requests that use the
|
|
108
|
+
# associated app profile.
|
|
109
|
+
#
|
|
110
|
+
# Unconditionally routes all read/write requests to a specific cluster.
|
|
111
|
+
# This option preserves read-your-writes consistency, but does not improve
|
|
112
|
+
# availability.
|
|
113
|
+
#
|
|
114
|
+
# @example
|
|
115
|
+
# require "google/cloud/bigtable"
|
|
116
|
+
#
|
|
117
|
+
# bigtable = Google::Cloud::Bigtable.new
|
|
118
|
+
#
|
|
119
|
+
# instance = bigtable.instance("my-instance")
|
|
120
|
+
#
|
|
121
|
+
# routing_policy = Google::Cloud::Bigtable::AppProfile.single_cluster_routing(
|
|
122
|
+
# "my-instance-cluster-1",
|
|
123
|
+
# allow_transactional_writes: true
|
|
124
|
+
# )
|
|
125
|
+
#
|
|
126
|
+
# app_profile = instance.create_app_profile(
|
|
127
|
+
# "my-app-profile",
|
|
128
|
+
# routing_policy,
|
|
129
|
+
# description: "App profile for user data instance"
|
|
130
|
+
# )
|
|
131
|
+
# puts app_profile.routing_policy
|
|
132
|
+
#
|
|
133
|
+
# @!attribute [rw] cluster_id
|
|
134
|
+
# @return [String]
|
|
135
|
+
# The cluster to which read/write requests should be routed.
|
|
136
|
+
# @!attribute [rw] allow_transactional_writes
|
|
137
|
+
# @return [true, false]
|
|
138
|
+
# If true, `CheckAndMutateRow` and `ReadModifyWriteRow` requests are
|
|
139
|
+
# allowed by this app profile. It is unsafe to send these requests to
|
|
140
|
+
# the same table/row/column in multiple clusters.
|
|
141
|
+
# Default value is false.
|
|
142
|
+
#
|
|
143
|
+
class SingleClusterRouting < RoutingPolicy
|
|
144
|
+
attr_reader :cluster_id, :allow_transactional_writes
|
|
145
|
+
|
|
146
|
+
##
|
|
147
|
+
# Creates a new single-cluster routing policy.
|
|
148
|
+
#
|
|
149
|
+
# @param cluster_id [String] The cluster to which read/write requests
|
|
150
|
+
# should be routed.
|
|
151
|
+
# @param allow_transactional_writes [Boolean]
|
|
152
|
+
# If true, `CheckAndMutateRow` and `ReadModifyWriteRow` requests are
|
|
153
|
+
# allowed by this app profile. It is unsafe to send these requests to
|
|
154
|
+
# the same table/row/column in multiple clusters.
|
|
155
|
+
# Default value is false.
|
|
156
|
+
#
|
|
157
|
+
def initialize cluster_id, allow_transactional_writes
|
|
158
|
+
@cluster_id = cluster_id
|
|
159
|
+
@allow_transactional_writes = allow_transactional_writes
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
# @private
|
|
163
|
+
def to_grpc
|
|
164
|
+
Google::Bigtable::Admin::V2::AppProfile::SingleClusterRouting.new(
|
|
165
|
+
cluster_id: cluster_id,
|
|
166
|
+
allow_transactional_writes: allow_transactional_writes
|
|
167
|
+
)
|
|
168
|
+
end
|
|
169
|
+
end
|
|
170
|
+
end
|
|
171
|
+
end
|
|
172
|
+
end
|
|
@@ -0,0 +1,136 @@
|
|
|
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
|
+
# # Row
|
|
23
|
+
#
|
|
24
|
+
# Row structure based on merged cells using read row state.
|
|
25
|
+
#
|
|
26
|
+
class Row
|
|
27
|
+
##
|
|
28
|
+
# Cell
|
|
29
|
+
#
|
|
30
|
+
# Row cell built from data chunks.
|
|
31
|
+
#
|
|
32
|
+
class Cell
|
|
33
|
+
attr_reader :family, :qualifier, :value, :labels, :timestamp
|
|
34
|
+
|
|
35
|
+
##
|
|
36
|
+
# Creates a row cell instance.
|
|
37
|
+
#
|
|
38
|
+
# @param family [String] Column family name.
|
|
39
|
+
# @param qualifier [String] Column cell qualifier name.
|
|
40
|
+
# @param timestamp [Integer] Timestamp in microseconds.
|
|
41
|
+
# @param value [String] Cell value.
|
|
42
|
+
# @param labels [Array<String>] List of label array.
|
|
43
|
+
#
|
|
44
|
+
def initialize family, qualifier, timestamp, value, labels = []
|
|
45
|
+
@family = family
|
|
46
|
+
@qualifier = qualifier
|
|
47
|
+
@timestamp = timestamp
|
|
48
|
+
@value = value
|
|
49
|
+
@labels = labels
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
##
|
|
53
|
+
# Converts timestamp to Time instance.
|
|
54
|
+
#
|
|
55
|
+
# @param granularity [Symbol] Optional.
|
|
56
|
+
# Valid granularity types are `:micros`, `:millis`.
|
|
57
|
+
# Default is `:millis`.
|
|
58
|
+
# @return [Time | nil]
|
|
59
|
+
#
|
|
60
|
+
def to_time granularity = nil
|
|
61
|
+
return nil if @timestamp.zero?
|
|
62
|
+
return Time.at @timestamp / 1_000_000.0 if granularity == :micros
|
|
63
|
+
Time.at @timestamp / 1000.0
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
##
|
|
67
|
+
# Converts a value to an integer.
|
|
68
|
+
#
|
|
69
|
+
# @return [Integer]
|
|
70
|
+
#
|
|
71
|
+
def to_i
|
|
72
|
+
@value.unpack1 "q>"
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# @private
|
|
76
|
+
#
|
|
77
|
+
# Cell object comparator.
|
|
78
|
+
#
|
|
79
|
+
# @return [Boolean]
|
|
80
|
+
#
|
|
81
|
+
def == other
|
|
82
|
+
return false unless self.class == other.class
|
|
83
|
+
|
|
84
|
+
instance_variables.all? do |var|
|
|
85
|
+
instance_variable_get(var) == other.instance_variable_get(var)
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
##
|
|
91
|
+
# @return [String] Row key.
|
|
92
|
+
#
|
|
93
|
+
attr_accessor :key
|
|
94
|
+
|
|
95
|
+
##
|
|
96
|
+
# @return [Hash{String => Array<Google::Cloud::Bigtable::Row::Cell>}] Row cells.
|
|
97
|
+
#
|
|
98
|
+
attr_accessor :cells
|
|
99
|
+
|
|
100
|
+
##
|
|
101
|
+
# Creates a flat row object.
|
|
102
|
+
#
|
|
103
|
+
# @param key [String] Row key name.
|
|
104
|
+
#
|
|
105
|
+
def initialize key = nil
|
|
106
|
+
@key = key
|
|
107
|
+
@cells = Hash.new { |h, k| h[k] = [] }
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
##
|
|
111
|
+
# List of column families names.
|
|
112
|
+
#
|
|
113
|
+
# @return [Array<String>]
|
|
114
|
+
#
|
|
115
|
+
def column_families
|
|
116
|
+
@cells.keys
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
# @private
|
|
120
|
+
#
|
|
121
|
+
# FlatRow object comparator.
|
|
122
|
+
#
|
|
123
|
+
# @return [Boolean]
|
|
124
|
+
#
|
|
125
|
+
def == other
|
|
126
|
+
return false unless self.class == other.class
|
|
127
|
+
return false if key != other.key || column_families != other.column_families
|
|
128
|
+
|
|
129
|
+
cells.all? do |family, list|
|
|
130
|
+
list == other.cells[family]
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
end
|
|
@@ -0,0 +1,639 @@
|
|
|
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/bigtable/v2/data_pb"
|
|
19
|
+
require "google/cloud/bigtable/value_range"
|
|
20
|
+
require "google/cloud/bigtable/column_range"
|
|
21
|
+
require "google/cloud/bigtable/row_filter/simple_filter"
|
|
22
|
+
require "google/cloud/bigtable/row_filter/chain_filter"
|
|
23
|
+
require "google/cloud/bigtable/row_filter/interleave_filter"
|
|
24
|
+
require "google/cloud/bigtable/row_filter/condition_filter"
|
|
25
|
+
|
|
26
|
+
module Google
|
|
27
|
+
module Cloud
|
|
28
|
+
module Bigtable
|
|
29
|
+
##
|
|
30
|
+
# # RowFilter
|
|
31
|
+
#
|
|
32
|
+
# Takes a row as input and produces an alternate view of the row based on
|
|
33
|
+
# specified rules. For example, a RowFilter might trim down a row to include
|
|
34
|
+
# just the cells from columns matching a given regular expression, or it might
|
|
35
|
+
# return all the cells of a row but not their values. More complicated filters
|
|
36
|
+
# can be composed out of these components to express requests such as, "within
|
|
37
|
+
# every column of a particular family, give just the two most recent cells
|
|
38
|
+
# that are older than timestamp X."
|
|
39
|
+
#
|
|
40
|
+
# Two broad categories of RowFilters are `true filters` and `transformers`.
|
|
41
|
+
# Two ways to compose simple filters into more complex ones are
|
|
42
|
+
# `chains` and `interleaves`. They work as follows:
|
|
43
|
+
#
|
|
44
|
+
# * True filters alter the input row by excluding some of its cells wholesale
|
|
45
|
+
# from the output row. An example of a true filter is the `value_regex_filter`,
|
|
46
|
+
# which excludes cells whose values don't match the specified pattern. All
|
|
47
|
+
# regex true filters use RE2 syntax (https:#github.com/google/re2/wiki/Syntax)
|
|
48
|
+
# in raw byte mode (RE2::Latin1) and are evaluated as full matches. An
|
|
49
|
+
# important point to keep in mind is that `RE2(.)` is equivalent by default to
|
|
50
|
+
# `RE2([^\n])`, meaning that it does not match newlines. When attempting to
|
|
51
|
+
# match an arbitrary byte, you should therefore use the escape sequence `\C`,
|
|
52
|
+
# which should be further escaped as `\\C` in Ruby.
|
|
53
|
+
#
|
|
54
|
+
# * Transformers alter the input row by changing the values of some of its
|
|
55
|
+
# cells in the output, without excluding them completely. Currently, the only
|
|
56
|
+
# supported transformer is the `strip_value_transformer`, which replaces every
|
|
57
|
+
# cell's value with an empty string.
|
|
58
|
+
#
|
|
59
|
+
# * Chains and interleaves are described in more detail in the
|
|
60
|
+
# RowFilter.Chain and RowFilter.Interleave documentation.
|
|
61
|
+
#
|
|
62
|
+
# The total serialized size of a RowFilter message must not
|
|
63
|
+
# exceed 4096 bytes, and RowFilters may not be nested within each other
|
|
64
|
+
# (in chains or interleaves) to a depth of more than 20.
|
|
65
|
+
#
|
|
66
|
+
# ADVANCED USE:.
|
|
67
|
+
# Hook for introspection into the RowFilter. Outputs all cells directly to
|
|
68
|
+
# the output of the read rather than to any parent filter. Consider the
|
|
69
|
+
# following example:
|
|
70
|
+
#
|
|
71
|
+
# Chain(
|
|
72
|
+
# FamilyRegex("A"),
|
|
73
|
+
# Interleave(
|
|
74
|
+
# All(),
|
|
75
|
+
# Chain(Label("foo"), Sink())
|
|
76
|
+
# ),
|
|
77
|
+
# QualifierRegex("B")
|
|
78
|
+
# )
|
|
79
|
+
#
|
|
80
|
+
# A,A,1,w
|
|
81
|
+
# A,B,2,x
|
|
82
|
+
# B,B,4,z
|
|
83
|
+
# |
|
|
84
|
+
# FamilyRegex("A")
|
|
85
|
+
# |
|
|
86
|
+
# A,A,1,w
|
|
87
|
+
# A,B,2,x
|
|
88
|
+
# |
|
|
89
|
+
# +------------+-------------+
|
|
90
|
+
# | |
|
|
91
|
+
# All() Label(foo)
|
|
92
|
+
# | |
|
|
93
|
+
# A,A,1,w A,A,1,w,labels:[foo]
|
|
94
|
+
# A,B,2,x A,B,2,x,labels:[foo]
|
|
95
|
+
# | |
|
|
96
|
+
# | Sink() --------------+
|
|
97
|
+
# | | |
|
|
98
|
+
# +------------+ x------+ A,A,1,w,labels:[foo]
|
|
99
|
+
# | A,B,2,x,labels:[foo]
|
|
100
|
+
# A,A,1,w |
|
|
101
|
+
# A,B,2,x |
|
|
102
|
+
# | |
|
|
103
|
+
# QualifierRegex("B") |
|
|
104
|
+
# | |
|
|
105
|
+
# A,B,2,x |
|
|
106
|
+
# | |
|
|
107
|
+
# +--------------------------------+
|
|
108
|
+
# |
|
|
109
|
+
# A,A,1,w,labels:[foo]
|
|
110
|
+
# A,B,2,x,labels:[foo] # could be switched
|
|
111
|
+
# A,B,2,x # could be switched
|
|
112
|
+
#
|
|
113
|
+
# Despite being excluded by the qualifier filter, a copy of every cell
|
|
114
|
+
# that reaches the sink is present in the final result.
|
|
115
|
+
#
|
|
116
|
+
# As with an interleave filter, duplicate cells are possible
|
|
117
|
+
# and appear in an unspecified mutual order.
|
|
118
|
+
# In this case we have a duplicate with column "A:B" and timestamp 2
|
|
119
|
+
# because one copy passed through the All filter while the other was
|
|
120
|
+
# passed through the Label and Sink filters. Note that one copy has the label "foo",
|
|
121
|
+
# while the other does not.
|
|
122
|
+
#
|
|
123
|
+
# @example
|
|
124
|
+
# require "google/cloud/bigtable"
|
|
125
|
+
#
|
|
126
|
+
# # Pass filter
|
|
127
|
+
# Google::Cloud::Bigtable::RowFilter.pass
|
|
128
|
+
#
|
|
129
|
+
# # Key regex filter
|
|
130
|
+
# Google::Cloud::Bigtable::RowFilter.key("user-*")
|
|
131
|
+
#
|
|
132
|
+
# # Cell limit filter
|
|
133
|
+
# Google::Cloud::Bigtable::RowFilter.cells_per_row(10)
|
|
134
|
+
#
|
|
135
|
+
module RowFilter
|
|
136
|
+
# @private
|
|
137
|
+
PASS = SimpleFilter.new.pass.freeze
|
|
138
|
+
|
|
139
|
+
# @private
|
|
140
|
+
BLOCK = SimpleFilter.new.block.freeze
|
|
141
|
+
|
|
142
|
+
# @private
|
|
143
|
+
SINK = SimpleFilter.new.sink.freeze
|
|
144
|
+
|
|
145
|
+
# @private
|
|
146
|
+
STRIP_VALUE = SimpleFilter.new.strip_value.freeze
|
|
147
|
+
|
|
148
|
+
private_constant :PASS, :BLOCK, :SINK, :STRIP_VALUE
|
|
149
|
+
|
|
150
|
+
##
|
|
151
|
+
# Creates a chain filter instance.
|
|
152
|
+
#
|
|
153
|
+
# A chain RowFilter that sends rows through several RowFilters in sequence.
|
|
154
|
+
#
|
|
155
|
+
# See {Google::Cloud::Bigtable::RowFilter::ChainFilter}.
|
|
156
|
+
#
|
|
157
|
+
# The elements of "filters" are chained together to process the input row:
|
|
158
|
+
# in row -> f(0) -> intermediate row -> f(1) -> ... -> f(N) -> out row
|
|
159
|
+
# The full chain is executed atomically.
|
|
160
|
+
#
|
|
161
|
+
# @return [Google::Cloud::Bigtable::RowFilter::ChainFilter]
|
|
162
|
+
#
|
|
163
|
+
# @example Create chain filter with simple filter.
|
|
164
|
+
# require "google/cloud/bigtable"
|
|
165
|
+
#
|
|
166
|
+
# chain = Google::Cloud::Bigtable::RowFilter.chain
|
|
167
|
+
#
|
|
168
|
+
# # Add filters to chain filter
|
|
169
|
+
# chain.key("user-*")
|
|
170
|
+
# chain.strip_value
|
|
171
|
+
#
|
|
172
|
+
# # OR
|
|
173
|
+
# chain.key("user-*").strip_value
|
|
174
|
+
#
|
|
175
|
+
# @example Create complex chain filter.
|
|
176
|
+
# require "google/cloud/bigtable"
|
|
177
|
+
#
|
|
178
|
+
# chain = Google::Cloud::Bigtable::RowFilter.chain
|
|
179
|
+
#
|
|
180
|
+
# chain_1 = Google::Cloud::Bigtable::RowFilter.chain
|
|
181
|
+
# chain_1.label("users").qualifier("name").cells_per_row(5)
|
|
182
|
+
#
|
|
183
|
+
# # Add to main chain filter
|
|
184
|
+
# chain.chain(chain_1).value("xyz*").key("user-*")
|
|
185
|
+
#
|
|
186
|
+
def self.chain
|
|
187
|
+
ChainFilter.new
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
##
|
|
191
|
+
# Creates an interleave filter.
|
|
192
|
+
#
|
|
193
|
+
# A RowFilter that sends each row to each of several component
|
|
194
|
+
# RowFilters and interleaves the results.
|
|
195
|
+
#
|
|
196
|
+
# The elements of "filters" all process a copy of the input row, and the
|
|
197
|
+
# results are pooled, sorted, and combined into a single output row.
|
|
198
|
+
# If multiple cells are produced with the same column and timestamp,
|
|
199
|
+
# they will all appear in the output row in an unspecified mutual order.
|
|
200
|
+
# Consider the following example, with three filters:
|
|
201
|
+
#
|
|
202
|
+
# input row
|
|
203
|
+
# |
|
|
204
|
+
# -----------------------------------------------------
|
|
205
|
+
# | | |
|
|
206
|
+
# f(0) f(1) f(2)
|
|
207
|
+
# | | |
|
|
208
|
+
# 1: foo,bar,10,x foo,bar,10,z far,bar,7,a
|
|
209
|
+
# 2: foo,blah,11,z far,blah,5,x far,blah,5,x
|
|
210
|
+
# | | |
|
|
211
|
+
# -----------------------------------------------------
|
|
212
|
+
# |
|
|
213
|
+
# 1: foo,bar,10,z # could have switched with #2
|
|
214
|
+
# 2: foo,bar,10,x # could have switched with #1
|
|
215
|
+
# 3: foo,blah,11,z
|
|
216
|
+
# 4: far,bar,7,a
|
|
217
|
+
# 5: far,blah,5,x # identical to #6
|
|
218
|
+
# 6: far,blah,5,x # identical to #5
|
|
219
|
+
#
|
|
220
|
+
# All interleaved filters are executed atomically.
|
|
221
|
+
#
|
|
222
|
+
# @return [Google::Cloud::Bigtable::RowFilter::InterleaveFilter]
|
|
223
|
+
#
|
|
224
|
+
# @example Create an interleave filter with simple filter.
|
|
225
|
+
# require "google/cloud/bigtable"
|
|
226
|
+
#
|
|
227
|
+
# interleave = Google::Cloud::Bigtable::RowFilter.interleave
|
|
228
|
+
#
|
|
229
|
+
# # Add filters to interleave filter
|
|
230
|
+
# interleave.key("user-*")
|
|
231
|
+
# interleave.sink
|
|
232
|
+
#
|
|
233
|
+
# # OR
|
|
234
|
+
# interleave.key("user-*").sink
|
|
235
|
+
#
|
|
236
|
+
# @example Create complex interleave filter.
|
|
237
|
+
# require "google/cloud/bigtable"
|
|
238
|
+
#
|
|
239
|
+
# interleave = Google::Cloud::Bigtable::RowFilter.interleave
|
|
240
|
+
#
|
|
241
|
+
# chain_1 = Google::Cloud::Bigtable::RowFilter.chain
|
|
242
|
+
# chain_1.label("users").qualifier("name").cells_per_row(5)
|
|
243
|
+
#
|
|
244
|
+
# # Add to main chain filter
|
|
245
|
+
# interleave.chain(chain_1).value("xyz*").key("user-*")
|
|
246
|
+
#
|
|
247
|
+
def self.interleave
|
|
248
|
+
InterleaveFilter.new
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
##
|
|
252
|
+
# Creates a condition filter instance.
|
|
253
|
+
#
|
|
254
|
+
# A RowFilter that evaluates one of two possible RowFilters, depending on
|
|
255
|
+
# whether or not a predicate RowFilter outputs any cells from the input row.
|
|
256
|
+
#
|
|
257
|
+
# IMPORTANT NOTE: The predicate filter does not execute atomically with the
|
|
258
|
+
# true and false filters, which may lead to inconsistent or unexpected
|
|
259
|
+
# results. Additionally, condition filters have poor performance, especially
|
|
260
|
+
# when filters are set for the false condition.
|
|
261
|
+
#
|
|
262
|
+
# Cannot be used within the `predicate_filter`, `true_filter`, or `false_filter`.
|
|
263
|
+
#
|
|
264
|
+
# @param predicate [SimpleFilter, ChainFilter, InterleaveFilter, ConditionFilter]
|
|
265
|
+
# @return [Google::Cloud::Bigtable::RowFilter::ConditionFilter]
|
|
266
|
+
#
|
|
267
|
+
# @example
|
|
268
|
+
# require "google/cloud/bigtable"
|
|
269
|
+
#
|
|
270
|
+
# predicate = Google::Cloud::Bigtable::RowFilter.key("user-*")
|
|
271
|
+
# condition = Google::Cloud::Bigtable::RowFilter.condition(predicate)
|
|
272
|
+
#
|
|
273
|
+
# label = Google::Cloud::Bigtable::RowFilter.label("user")
|
|
274
|
+
# strip_value = Google::Cloud::Bigtable::RowFilter.strip_value
|
|
275
|
+
#
|
|
276
|
+
# # On match apply label, else strip cell values
|
|
277
|
+
# condition.on_match(label).otherwise(strip_value)
|
|
278
|
+
#
|
|
279
|
+
def self.condition predicate
|
|
280
|
+
ConditionFilter.new predicate
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
##
|
|
284
|
+
# Creates a pass filter instance.
|
|
285
|
+
#
|
|
286
|
+
# Matches all cells, regardless of input. Functionally equivalent to
|
|
287
|
+
# leaving `filter` unset, but included for completeness.
|
|
288
|
+
#
|
|
289
|
+
# @return [Google::Cloud::Bigtable::RowFilter::SimpleFilter]
|
|
290
|
+
#
|
|
291
|
+
# @example
|
|
292
|
+
# require "google/cloud/bigtable"
|
|
293
|
+
#
|
|
294
|
+
# filter = Google::Cloud::Bigtable::RowFilter.pass
|
|
295
|
+
#
|
|
296
|
+
def self.pass
|
|
297
|
+
PASS
|
|
298
|
+
end
|
|
299
|
+
|
|
300
|
+
##
|
|
301
|
+
# Creates a block-all filter instance.
|
|
302
|
+
#
|
|
303
|
+
# Does not match any cells, regardless of input. Useful for temporarily
|
|
304
|
+
# disabling just part of a filter.
|
|
305
|
+
#
|
|
306
|
+
# @return [Google::Cloud::Bigtable::RowFilter::SimpleFilter]
|
|
307
|
+
#
|
|
308
|
+
# @example
|
|
309
|
+
# require "google/cloud/bigtable"
|
|
310
|
+
#
|
|
311
|
+
# filter = Google::Cloud::Bigtable::RowFilter.block
|
|
312
|
+
#
|
|
313
|
+
def self.block
|
|
314
|
+
BLOCK
|
|
315
|
+
end
|
|
316
|
+
|
|
317
|
+
##
|
|
318
|
+
# Creates a sink filter instance.
|
|
319
|
+
#
|
|
320
|
+
# Outputs all cells directly to the output of the read rather than to any
|
|
321
|
+
# parent filter.
|
|
322
|
+
#
|
|
323
|
+
# @return [Google::Cloud::Bigtable::RowFilter::SimpleFilter]
|
|
324
|
+
#
|
|
325
|
+
# @example
|
|
326
|
+
# require "google/cloud/bigtable"
|
|
327
|
+
#
|
|
328
|
+
# filter = Google::Cloud::Bigtable::RowFilter.sink
|
|
329
|
+
#
|
|
330
|
+
def self.sink
|
|
331
|
+
SINK
|
|
332
|
+
end
|
|
333
|
+
|
|
334
|
+
##
|
|
335
|
+
# Creates a strip value filter instance.
|
|
336
|
+
#
|
|
337
|
+
# Replaces each cell's value with an empty string.
|
|
338
|
+
#
|
|
339
|
+
# @return [Google::Cloud::Bigtable::RowFilter::SimpleFilter]
|
|
340
|
+
#
|
|
341
|
+
# @example
|
|
342
|
+
# require "google/cloud/bigtable"
|
|
343
|
+
#
|
|
344
|
+
# filter = Google::Cloud::Bigtable::RowFilter.strip_value
|
|
345
|
+
#
|
|
346
|
+
def self.strip_value
|
|
347
|
+
STRIP_VALUE
|
|
348
|
+
end
|
|
349
|
+
|
|
350
|
+
##
|
|
351
|
+
# Creates a key filter instance to match a row key using a regular expression.
|
|
352
|
+
#
|
|
353
|
+
# Matches only cells from rows whose row keys satisfy the given RE2 regex. In
|
|
354
|
+
# other words, passes through the entire row when the key matches, and
|
|
355
|
+
# otherwise produces an empty row.
|
|
356
|
+
# Note that, since row keys can contain arbitrary bytes, the `\C` escape
|
|
357
|
+
# sequence must be used if a true wildcard is desired. The `.` character
|
|
358
|
+
# will not match the new line character `\n`, which may be present in a
|
|
359
|
+
# binary key.
|
|
360
|
+
#
|
|
361
|
+
# @see https://github.com/google/re2/wiki/Syntax Regex syntax
|
|
362
|
+
#
|
|
363
|
+
# @param regex [String] Regex to match row keys.
|
|
364
|
+
# @return [Google::Cloud::Bigtable::RowFilter::SimpleFilter]
|
|
365
|
+
#
|
|
366
|
+
# @example
|
|
367
|
+
# require "google/cloud/bigtable"
|
|
368
|
+
#
|
|
369
|
+
# filter = Google::Cloud::Bigtable::RowFilter.key("user-.*")
|
|
370
|
+
#
|
|
371
|
+
def self.key regex
|
|
372
|
+
SimpleFilter.new.key regex
|
|
373
|
+
end
|
|
374
|
+
|
|
375
|
+
##
|
|
376
|
+
# Creates a sample probability filter instance.
|
|
377
|
+
#
|
|
378
|
+
# Matches all cells from a row with probability p, and matches no cells
|
|
379
|
+
# from the row with probability 1-p.
|
|
380
|
+
#
|
|
381
|
+
# @param probability [Float] Probability value.
|
|
382
|
+
# Probability must be greater than 0 and less than 1.0.
|
|
383
|
+
# @return [Google::Cloud::Bigtable::RowFilter::SimpleFilter]
|
|
384
|
+
#
|
|
385
|
+
# @example
|
|
386
|
+
# require "google/cloud/bigtable"
|
|
387
|
+
#
|
|
388
|
+
# filter = Google::Cloud::Bigtable::RowFilter.sample(0.5)
|
|
389
|
+
#
|
|
390
|
+
def self.sample probability
|
|
391
|
+
SimpleFilter.new.sample probability
|
|
392
|
+
end
|
|
393
|
+
|
|
394
|
+
##
|
|
395
|
+
# Creates a family name match filter using a regular expression.
|
|
396
|
+
#
|
|
397
|
+
# Matches only cells from columns whose families satisfy the given RE2
|
|
398
|
+
# regex. For technical reasons, the regex must not contain the `:`
|
|
399
|
+
# character, even if it is not being used as a literal.
|
|
400
|
+
# Note that, since column families cannot contain the new line character
|
|
401
|
+
# `\n`, it is sufficient to use `.` as a full wildcard when matching
|
|
402
|
+
# column family names.
|
|
403
|
+
#
|
|
404
|
+
# @see https://github.com/google/re2/wiki/Syntax Regex syntax
|
|
405
|
+
#
|
|
406
|
+
# @param regex [String] Regex to match family name.
|
|
407
|
+
# @return [Google::Cloud::Bigtable::RowFilter::SimpleFilter]
|
|
408
|
+
#
|
|
409
|
+
# @example
|
|
410
|
+
# require "google/cloud/bigtable"
|
|
411
|
+
#
|
|
412
|
+
# filter = Google::Cloud::Bigtable::RowFilter.family("cf-.*")
|
|
413
|
+
#
|
|
414
|
+
def self.family regex
|
|
415
|
+
SimpleFilter.new.family regex
|
|
416
|
+
end
|
|
417
|
+
|
|
418
|
+
##
|
|
419
|
+
# Creates a column qualifier match filter using a regular expression.
|
|
420
|
+
#
|
|
421
|
+
# Matches only cells from columns whose qualifiers satisfy the given RE2
|
|
422
|
+
# regex.
|
|
423
|
+
# Note that, since column qualifiers can contain arbitrary bytes, the `\C`
|
|
424
|
+
# escape sequence must be used if a true wildcard is desired. The `.`
|
|
425
|
+
# character will not match the new line character `\n`, which may be
|
|
426
|
+
# present in a binary qualifier.
|
|
427
|
+
#
|
|
428
|
+
# @see https://github.com/google/re2/wiki/Syntax Regex syntax
|
|
429
|
+
#
|
|
430
|
+
# @param regex [String] Regex to match column qualifier name.
|
|
431
|
+
# @return [Google::Cloud::Bigtable::RowFilter::SimpleFilter]
|
|
432
|
+
#
|
|
433
|
+
# @example
|
|
434
|
+
# require "google/cloud/bigtable"
|
|
435
|
+
#
|
|
436
|
+
# filter = Google::Cloud::Bigtable::RowFilter.qualifier("user-name.*")
|
|
437
|
+
#
|
|
438
|
+
def self.qualifier regex
|
|
439
|
+
SimpleFilter.new.qualifier regex
|
|
440
|
+
end
|
|
441
|
+
|
|
442
|
+
##
|
|
443
|
+
# Creates a value match filter using a regular expression.
|
|
444
|
+
#
|
|
445
|
+
# Matches only cells with values that satisfy the given regular expression.
|
|
446
|
+
# Note that, since cell values can contain arbitrary bytes, the `\C` escape
|
|
447
|
+
# sequence must be used if a true wildcard is desired. The `.` character
|
|
448
|
+
# will not match the new line character `\n`, which may be present in a
|
|
449
|
+
# binary value.
|
|
450
|
+
#
|
|
451
|
+
# @see https://github.com/google/re2/wiki/Syntax Regex syntax
|
|
452
|
+
#
|
|
453
|
+
# @param regex [String] Regex to match cell value.
|
|
454
|
+
# @return [Google::Cloud::Bigtable::RowFilter::SimpleFilter]
|
|
455
|
+
#
|
|
456
|
+
# @example
|
|
457
|
+
# require "google/cloud/bigtable"
|
|
458
|
+
#
|
|
459
|
+
# filter = Google::Cloud::Bigtable::RowFilter.value("abc.*")
|
|
460
|
+
#
|
|
461
|
+
def self.value regex
|
|
462
|
+
SimpleFilter.new.value regex
|
|
463
|
+
end
|
|
464
|
+
|
|
465
|
+
##
|
|
466
|
+
# Creates a label filter instance to apply a label based on the result of
|
|
467
|
+
# read rows.
|
|
468
|
+
#
|
|
469
|
+
# Applies the given label to all cells in the output row. This allows
|
|
470
|
+
# the client to determine which results were produced from which part of
|
|
471
|
+
# the filter.
|
|
472
|
+
#
|
|
473
|
+
# Values must be at most 15 characters and match the RE2
|
|
474
|
+
# pattern `[a-z0-9\\-]+`
|
|
475
|
+
#
|
|
476
|
+
# Due to a technical limitation, it is not possible to apply
|
|
477
|
+
# multiple labels to a cell. As a result, a chain may have no more than
|
|
478
|
+
# one sub-filter that contains an `apply_label_transformer`. It is okay for
|
|
479
|
+
# an interleave to contain multiple `apply_label_transformers`, as they
|
|
480
|
+
# will be applied to separate copies of the input.
|
|
481
|
+
#
|
|
482
|
+
# @param value [String] Label name
|
|
483
|
+
# @return [Google::Cloud::Bigtable::RowFilter::SimpleFilter]
|
|
484
|
+
#
|
|
485
|
+
# @example
|
|
486
|
+
# require "google/cloud/bigtable"
|
|
487
|
+
#
|
|
488
|
+
# filter = Google::Cloud::Bigtable::RowFilter.label("user-detail")
|
|
489
|
+
#
|
|
490
|
+
def self.label value
|
|
491
|
+
SimpleFilter.new.label value
|
|
492
|
+
end
|
|
493
|
+
|
|
494
|
+
##
|
|
495
|
+
# Creates a cell-per-row-offset filter instance to skip first N cells.
|
|
496
|
+
#
|
|
497
|
+
# Skips the first N cells of each row, matching all subsequent cells.
|
|
498
|
+
# If duplicate cells are present, as is possible when using an interleave,
|
|
499
|
+
# each copy of the cell is counted separately.
|
|
500
|
+
#
|
|
501
|
+
# @param offset [Integer] Offset value.
|
|
502
|
+
# @return [Google::Cloud::Bigtable::RowFilter::SimpleFilter]
|
|
503
|
+
#
|
|
504
|
+
# @example
|
|
505
|
+
# require "google/cloud/bigtable"
|
|
506
|
+
#
|
|
507
|
+
# filter = Google::Cloud::Bigtable::RowFilter.cells_per_row_offset(3)
|
|
508
|
+
#
|
|
509
|
+
def self.cells_per_row_offset offset
|
|
510
|
+
SimpleFilter.new.cells_per_row_offset offset
|
|
511
|
+
end
|
|
512
|
+
|
|
513
|
+
##
|
|
514
|
+
# Create a cells-per-row limit filter instance.
|
|
515
|
+
#
|
|
516
|
+
# Matches only the first N cells of each row.
|
|
517
|
+
# If duplicate cells are present, as is possible when using an interleave,
|
|
518
|
+
# each copy of the cell is counted separately.
|
|
519
|
+
#
|
|
520
|
+
# @param limit [String] Max cell match per row limit
|
|
521
|
+
# @return [Google::Cloud::Bigtable::RowFilter::SimpleFilter]
|
|
522
|
+
#
|
|
523
|
+
# @example
|
|
524
|
+
# require "google/cloud/bigtable"
|
|
525
|
+
#
|
|
526
|
+
# filter = Google::Cloud::Bigtable::RowFilter.cells_per_row(5)
|
|
527
|
+
#
|
|
528
|
+
def self.cells_per_row limit
|
|
529
|
+
SimpleFilter.new.cells_per_row limit
|
|
530
|
+
end
|
|
531
|
+
|
|
532
|
+
##
|
|
533
|
+
# Creates cells-per-column filter instance.
|
|
534
|
+
#
|
|
535
|
+
# Matches only the most recent N cells within each column.
|
|
536
|
+
# If duplicate cells are present, as is possible when using an interleave,
|
|
537
|
+
# each copy of the cell is counted separately.
|
|
538
|
+
#
|
|
539
|
+
# @param limit [String] Max cell match per column limit
|
|
540
|
+
# @return [Google::Cloud::Bigtable::RowFilter::SimpleFilter]
|
|
541
|
+
#
|
|
542
|
+
# @example
|
|
543
|
+
# require "google/cloud/bigtable"
|
|
544
|
+
#
|
|
545
|
+
# filter = Google::Cloud::Bigtable::RowFilter.cells_per_column(5)
|
|
546
|
+
#
|
|
547
|
+
def self.cells_per_column limit
|
|
548
|
+
SimpleFilter.new.cells_per_column limit
|
|
549
|
+
end
|
|
550
|
+
|
|
551
|
+
##
|
|
552
|
+
# Creates a timestamp-range filter instance.
|
|
553
|
+
#
|
|
554
|
+
# Matches only cells with timestamps within the given range.
|
|
555
|
+
# Specifies a contiguous range of timestamps.
|
|
556
|
+
#
|
|
557
|
+
# @param from [Integer] Inclusive lower bound. If left empty, interpreted as 0.
|
|
558
|
+
# @param to [Integer] Exclusive upper bound. If left empty, interpreted as infinity.
|
|
559
|
+
# @return [Google::Cloud::Bigtable::RowFilter::SimpleFilter]
|
|
560
|
+
#
|
|
561
|
+
# @example
|
|
562
|
+
# require "google/cloud/bigtable"
|
|
563
|
+
#
|
|
564
|
+
# timestamp_micros = (Time.now.to_f * 1000000).round(-3)
|
|
565
|
+
# from = timestamp_micros - 300000000
|
|
566
|
+
# to = timestamp_micros
|
|
567
|
+
#
|
|
568
|
+
# filter = Google::Cloud::Bigtable::RowFilter.timestamp_range(from: from, to: to)
|
|
569
|
+
#
|
|
570
|
+
# # From to infinity
|
|
571
|
+
# filter = Google::Cloud::Bigtable::RowFilter.timestamp_range(from: from)
|
|
572
|
+
#
|
|
573
|
+
# # From 0 value to `to`
|
|
574
|
+
# filter = Google::Cloud::Bigtable::RowFilter.timestamp_range(to: to)
|
|
575
|
+
#
|
|
576
|
+
def self.timestamp_range from: nil, to: nil
|
|
577
|
+
SimpleFilter.new.timestamp_range from, to
|
|
578
|
+
end
|
|
579
|
+
|
|
580
|
+
##
|
|
581
|
+
# Creates a value-range filter instance.
|
|
582
|
+
#
|
|
583
|
+
# Matches only cells with values that fall within the given range.
|
|
584
|
+
#
|
|
585
|
+
# See {Google::Cloud::Bigtable::ValueRange#from} and { Google::Cloud::Bigtable::ValueRange#to} for range
|
|
586
|
+
# option inclusive/exclusive options
|
|
587
|
+
#
|
|
588
|
+
# * The value at which to start the range. If neither field is set, interpreted
|
|
589
|
+
# as an empty string, inclusive.
|
|
590
|
+
# * The value at which to end the range. If neither field is set, interpreted
|
|
591
|
+
# as an infinite string, exclusive.
|
|
592
|
+
#
|
|
593
|
+
# @param range [Google::Cloud::Bigtable::ValueRange]
|
|
594
|
+
# @return [Google::Cloud::Bigtable::RowFilter::SimpleFilter]
|
|
595
|
+
#
|
|
596
|
+
# @example Start to end range.
|
|
597
|
+
# require "google/cloud/bigtable"
|
|
598
|
+
#
|
|
599
|
+
# bigtable = Google::Cloud::Bigtable.new
|
|
600
|
+
# table = bigtable.table("my-instance", "my-table")
|
|
601
|
+
#
|
|
602
|
+
# range = table.new_value_range.from("value-001", inclusive: false)
|
|
603
|
+
# filter = Google::Cloud::Bigtable::RowFilter.value_range(range)
|
|
604
|
+
#
|
|
605
|
+
# @example Start exclusive to infinite end range.
|
|
606
|
+
# require "google/cloud/bigtable"
|
|
607
|
+
#
|
|
608
|
+
# bigtable = Google::Cloud::Bigtable.new
|
|
609
|
+
# table = bigtable.table("my-instance", "my-table")
|
|
610
|
+
#
|
|
611
|
+
# range = table.new_value_range.from("value-001", inclusive: false)
|
|
612
|
+
# filter = Google::Cloud::Bigtable::RowFilter.value_range(range)
|
|
613
|
+
#
|
|
614
|
+
def self.value_range range
|
|
615
|
+
SimpleFilter.new.value_range range
|
|
616
|
+
end
|
|
617
|
+
|
|
618
|
+
##
|
|
619
|
+
# Creates a column-range filter instance.
|
|
620
|
+
#
|
|
621
|
+
# Matches only cells from columns within the given range.
|
|
622
|
+
#
|
|
623
|
+
# @param range [Google::Cloud::Bigtable::ColumnRange]
|
|
624
|
+
# @return [Google::Cloud::Bigtable::RowFilter::SimpleFilter]
|
|
625
|
+
#
|
|
626
|
+
# @example
|
|
627
|
+
# require "google/cloud/bigtable"
|
|
628
|
+
#
|
|
629
|
+
# range = Google::Cloud::Bigtable::ColumnRange.new("cf").from("field0").to("field5")
|
|
630
|
+
#
|
|
631
|
+
# filter = Google::Cloud::Bigtable::RowFilter.column_range(range)
|
|
632
|
+
#
|
|
633
|
+
def self.column_range range
|
|
634
|
+
SimpleFilter.new.column_range range
|
|
635
|
+
end
|
|
636
|
+
end
|
|
637
|
+
end
|
|
638
|
+
end
|
|
639
|
+
end
|