Class: Google::Cloud::Bigtable::GcRule
- Inherits:
-
Object
- Object
- Google::Cloud::Bigtable::GcRule
- Defined in:
- lib/google/cloud/bigtable/gc_rule.rb
Overview
GcRule
A rule or rules for determining which cells to delete during garbage collection.
Garbage collection (GC) executes opportunistically in the background, so it is possible for reads to return a cell even if it matches the active GC expression for its column family.
GC Rule types:
max_num_versions
- A garbage-collection rule that explicitly states the maximum number of cells to keep for all columns in a column family.max_age
- A garbage-collection rule based on the timestamp for each cell. With this type of garbage-collection rule, you set the time to live (TTL) for data. Cloud Bigtable looks at each column family during garbage collection and removes any cells that have expired.union
- A union garbage-collection policy will remove all data matching any of a set of given rules.intersection
- An intersection garbage-collection policy will remove all data matching all of a set of given rules.
Class Method Summary collapse
-
.intersection(*rules) ⇒ Google::Cloud::Bigtable::GcRule
Creates a intersection GCRule instance.
-
.max_age(age) ⇒ Google::Cloud::Bigtable::GcRule
Creates a GcRule instance with max age.
-
.max_versions(versions) ⇒ Google::Cloud::Bigtable::GcRule
Creates a GcRule instance with max number of versions.
-
.union(*rules) ⇒ Google::Cloud::Bigtable::GcRule
Creates a union GcRule instance.
Instance Method Summary collapse
-
#intersection ⇒ Array<Google::Cloud::Bigtable::GcRule>?
Gets the intersection rules collection for this GcRule.
-
#intersection=(rules) ⇒ Object
Sets the intersection rules collection for this GcRule.
-
#max_age ⇒ Numeric?
Gets the garbage-collection rule based on the timestamp for each cell.
-
#max_age=(age) ⇒ Object
Sets a garbage-collection rule based on the timestamp for each cell.
-
#max_versions ⇒ Integer?
Gets the garbage-collection rule that explicitly states the maximum number of cells to keep for all columns in a column family.
-
#max_versions=(versions) ⇒ Object
Sets a garbage-collection rule that explicitly states the maximum number of cells to keep for all columns in a column family.
-
#union ⇒ Array<Google::Cloud::Bigtable::GcRule>?
Gets the union rules collection for this GcRule.
-
#union=(rules) ⇒ Object
Sets the union rules collection for this GcRule.
Class Method Details
.intersection(*rules) ⇒ Google::Cloud::Bigtable::GcRule
Creates a intersection GCRule instance.
309 310 311 312 313 |
# File 'lib/google/cloud/bigtable/gc_rule.rb', line 309 def self.intersection *rules new.tap do |gc_rule| gc_rule.intersection = rules end end |
.max_age(age) ⇒ Google::Cloud::Bigtable::GcRule
Creates a GcRule instance with max age.
257 258 259 260 261 |
# File 'lib/google/cloud/bigtable/gc_rule.rb', line 257 def self.max_age age new.tap do |gc_rule| gc_rule.max_age = age end end |
.max_versions(versions) ⇒ Google::Cloud::Bigtable::GcRule
Creates a GcRule instance with max number of versions.
236 237 238 239 240 |
# File 'lib/google/cloud/bigtable/gc_rule.rb', line 236 def self.max_versions versions new.tap do |gc_rule| gc_rule.max_versions = versions end end |
.union(*rules) ⇒ Google::Cloud::Bigtable::GcRule
Creates a union GcRule instance.
283 284 285 286 287 |
# File 'lib/google/cloud/bigtable/gc_rule.rb', line 283 def self.union *rules new.tap do |gc_rule| gc_rule.union = rules end end |
Instance Method Details
#intersection ⇒ Array<Google::Cloud::Bigtable::GcRule>?
Gets the intersection rules collection for this GcRule.
173 174 175 176 177 178 |
# File 'lib/google/cloud/bigtable/gc_rule.rb', line 173 def intersection return nil unless @grpc.intersection @grpc.intersection.rules.map do |gc_rule_grpc| self.class.from_grpc gc_rule_grpc end end |
#intersection=(rules) ⇒ Object
Sets the intersection rules collection for this GcRule.
148 149 150 |
# File 'lib/google/cloud/bigtable/gc_rule.rb', line 148 def intersection= rules @grpc.intersection = Google::Bigtable::Admin::V2::GcRule::Intersection.new rules: rules.map(&:to_grpc) end |
#max_age ⇒ Numeric?
Gets the garbage-collection rule based on the timestamp for each cell. With this type of garbage-collection rule, you set the time to live (TTL) for data. Cloud Bigtable looks at each column family during garbage collection and removes any cells that have expired.
138 139 140 |
# File 'lib/google/cloud/bigtable/gc_rule.rb', line 138 def max_age Convert.duration_to_number @grpc.max_age end |
#max_age=(age) ⇒ Object
Sets a garbage-collection rule based on the timestamp for each cell. With this type of garbage-collection rule, you set the time to live (TTL) for data. Cloud Bigtable looks at each column family during garbage collection and removes any cells that have expired.
115 116 117 |
# File 'lib/google/cloud/bigtable/gc_rule.rb', line 115 def max_age= age @grpc.max_age = Convert.number_to_duration age end |
#max_versions ⇒ Integer?
Gets the garbage-collection rule that explicitly states the maximum number of cells to keep for all columns in a column family.
102 103 104 |
# File 'lib/google/cloud/bigtable/gc_rule.rb', line 102 def max_versions @grpc.max_num_versions end |
#max_versions=(versions) ⇒ Object
Sets a garbage-collection rule that explicitly states the maximum number of cells to keep for all columns in a column family.
81 82 83 |
# File 'lib/google/cloud/bigtable/gc_rule.rb', line 81 def max_versions= versions @grpc.max_num_versions = versions end |
#union ⇒ Array<Google::Cloud::Bigtable::GcRule>?
Gets the union rules collection for this GcRule. A union garbage-collection policy will remove all data matching any of its set of given rules.
214 215 216 217 218 219 |
# File 'lib/google/cloud/bigtable/gc_rule.rb', line 214 def union return nil unless @grpc.union @grpc.union.rules.map do |gc_rule_grpc| self.class.from_grpc gc_rule_grpc end end |
#union=(rules) ⇒ Object
Sets the union rules collection for this GcRule. A union garbage-collection policy will remove all data matching any of its set of given rules.
188 189 190 |
# File 'lib/google/cloud/bigtable/gc_rule.rb', line 188 def union= rules @grpc.union = Google::Bigtable::Admin::V2::GcRule::Union.new rules: rules.map(&:to_grpc) end |