Class: ActiveRecord::Materialized::DeltaMaintainer
- Inherits:
-
Object
- Object
- ActiveRecord::Materialized::DeltaMaintainer
- Extended by:
- T::Sig
- Defined in:
- lib/activerecord/materialized/delta_maintainer.rb
Overview
Applies a SummaryDelta to a delta-maintainable view’s cache table without re-reading base rows: new partitions inserted, existing ones incremented in place (NULL-safe for SUM), and emptied partitions deleted.
Instance Method Summary collapse
- #apply!(summary) ⇒ Object
-
#initialize(view_class) ⇒ DeltaMaintainer
constructor
A new instance of DeltaMaintainer.
Constructor Details
#initialize(view_class) ⇒ DeltaMaintainer
Returns a new instance of DeltaMaintainer.
13 14 15 16 |
# File 'lib/activerecord/materialized/delta_maintainer.rb', line 13 def initialize(view_class) @view_class = view_class @analysis = T.let(AggregateAnalysis.new(view_class.resolved_source), AggregateAnalysis) end |
Instance Method Details
#apply!(summary) ⇒ Object
19 20 21 22 |
# File 'lib/activerecord/materialized/delta_maintainer.rb', line 19 def apply!(summary) summary.buckets.each { |key_tuple, column_deltas| apply_partition(key_tuple, column_deltas) } T.unsafe(@view_class).unscoped.count end |