Class: ActiveRecord::Materialized::MaintenanceDelta Private
- Inherits:
-
Object
- Object
- ActiveRecord::Materialized::MaintenanceDelta
- Defined in:
- lib/activerecord/materialized/maintenance_delta.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Pending scoped-recompute maintenance: the affected partition keys, or a full-partition marker.
Constant Summary collapse
- SCOPED =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
:scoped- FULL =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
:full_partition
Instance Attribute Summary collapse
- #key_tuples ⇒ Object readonly private
- #scope ⇒ Object readonly private
Class Method Summary collapse
- .deserialize(payload) ⇒ Object private
- .full_partition ⇒ Object private
- .scoped(key_tuples) ⇒ Object private
Instance Method Summary collapse
- #full_partition? ⇒ Boolean private
-
#initialize(scope:, key_tuples: []) ⇒ MaintenanceDelta
constructor
private
A new instance of MaintenanceDelta.
- #merge(other) ⇒ Object private
- #serialize ⇒ Object private
-
#tracked_partition_count ⇒ Object
private
How many distinct partitions this pending maintenance tracks.
Constructor Details
#initialize(scope:, key_tuples: []) ⇒ MaintenanceDelta
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of MaintenanceDelta.
14 15 16 17 |
# File 'lib/activerecord/materialized/maintenance_delta.rb', line 14 def initialize(scope:, key_tuples: []) @scope = scope @key_tuples = key_tuples end |
Instance Attribute Details
#key_tuples ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
12 13 14 |
# File 'lib/activerecord/materialized/maintenance_delta.rb', line 12 def key_tuples @key_tuples end |
#scope ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
12 13 14 |
# File 'lib/activerecord/materialized/maintenance_delta.rb', line 12 def scope @scope end |
Class Method Details
.deserialize(payload) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/activerecord/materialized/maintenance_delta.rb', line 52 def self.deserialize(payload) return nil if payload.blank? scope_name = payload["scope"]&.to_sym return nil if scope_name.nil? if scope_name == FULL full_partition else tuples = payload["key_tuples"] || [] scoped(tuples) end end |
.full_partition ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
23 24 25 |
# File 'lib/activerecord/materialized/maintenance_delta.rb', line 23 def self.full_partition new(scope: FULL) end |
.scoped(key_tuples) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
19 20 21 |
# File 'lib/activerecord/materialized/maintenance_delta.rb', line 19 def self.scoped(key_tuples) new(scope: SCOPED, key_tuples: key_tuples) end |
Instance Method Details
#full_partition? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
27 28 29 |
# File 'lib/activerecord/materialized/maintenance_delta.rb', line 27 def full_partition? scope == FULL end |
#merge(other) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
37 38 39 40 41 42 43 |
# File 'lib/activerecord/materialized/maintenance_delta.rb', line 37 def merge(other) return other if other.full_partition? return self if full_partition? combined = (key_tuples + other.key_tuples).uniq self.class.scoped(combined) end |
#serialize ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
45 46 47 48 49 50 |
# File 'lib/activerecord/materialized/maintenance_delta.rb', line 45 def serialize { "scope" => scope.to_s, "key_tuples" => key_tuples } end |
#tracked_partition_count ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
How many distinct partitions this pending maintenance tracks. A full-partition recompute tracks none — it is already the collapsed form.
33 34 35 |
# File 'lib/activerecord/materialized/maintenance_delta.rb', line 33 def tracked_partition_count full_partition? ? 0 : key_tuples.size end |