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.
311 312 313 314 315 |
# File 'lib/google/cloud/bigtable/gc_rule.rb', line 311 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.
259 260 261 262 263 |
# File 'lib/google/cloud/bigtable/gc_rule.rb', line 259 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.
238 239 240 241 242 |
# File 'lib/google/cloud/bigtable/gc_rule.rb', line 238 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.
285 286 287 288 289 |
# File 'lib/google/cloud/bigtable/gc_rule.rb', line 285 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.
175 176 177 178 179 180 |
# File 'lib/google/cloud/bigtable/gc_rule.rb', line 175 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.
150 151 152 |
# File 'lib/google/cloud/bigtable/gc_rule.rb', line 150 def intersection= rules @grpc.intersection = Google::Cloud::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.
140 141 142 |
# File 'lib/google/cloud/bigtable/gc_rule.rb', line 140 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.
117 118 119 |
# File 'lib/google/cloud/bigtable/gc_rule.rb', line 117 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.
104 105 106 |
# File 'lib/google/cloud/bigtable/gc_rule.rb', line 104 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.
83 84 85 |
# File 'lib/google/cloud/bigtable/gc_rule.rb', line 83 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.
216 217 218 219 220 221 |
# File 'lib/google/cloud/bigtable/gc_rule.rb', line 216 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.
190 191 192 |
# File 'lib/google/cloud/bigtable/gc_rule.rb', line 190 def union= rules @grpc.union = Google::Cloud::Bigtable::Admin::V2::GcRule::Union.new rules: rules.map(&:to_grpc) end |