Class: ActiveRecord::Materialized::MaintenanceDelta Private
- Inherits:
-
Object
- Object
- ActiveRecord::Materialized::MaintenanceDelta
- Extended by:
- T::Sig
- 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.
T.let(:scoped, Symbol)
- 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.
T.let(:full_partition, Symbol)
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
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.
22 23 24 25 |
# File 'lib/activerecord/materialized/maintenance_delta.rb', line 22 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.
19 20 21 |
# File 'lib/activerecord/materialized/maintenance_delta.rb', line 19 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.
16 17 18 |
# File 'lib/activerecord/materialized/maintenance_delta.rb', line 16 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.
67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/activerecord/materialized/maintenance_delta.rb', line 67 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 = T.cast(payload["key_tuples"], T.nilable(T::Array[T::Array[String]])) || [] 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.
33 34 35 |
# File 'lib/activerecord/materialized/maintenance_delta.rb', line 33 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.
28 29 30 |
# File 'lib/activerecord/materialized/maintenance_delta.rb', line 28 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.
38 39 40 |
# File 'lib/activerecord/materialized/maintenance_delta.rb', line 38 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.
50 51 52 53 54 55 56 |
# File 'lib/activerecord/materialized/maintenance_delta.rb', line 50 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.
59 60 61 62 63 64 |
# File 'lib/activerecord/materialized/maintenance_delta.rb', line 59 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.
45 46 47 |
# File 'lib/activerecord/materialized/maintenance_delta.rb', line 45 def tracked_partition_count full_partition? ? 0 : key_tuples.size end |