Class: ActiveRecord::Materialized::DeltaMaintainer
- Inherits:
-
Object
- Object
- ActiveRecord::Materialized::DeltaMaintainer
- 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.
9 10 11 12 |
# File 'lib/activerecord/materialized/delta_maintainer.rb', line 9 def initialize(view_class) @view_class = view_class @analysis = AggregateAnalysis.new(view_class.resolved_source) end |
Instance Method Details
#apply!(summary) ⇒ Object
14 15 16 17 |
# File 'lib/activerecord/materialized/delta_maintainer.rb', line 14 def apply!(summary) summary.buckets.each { |key_tuple, column_deltas| apply_partition(key_tuple, column_deltas) } summary.buckets.size # partitions applied; row-count reporting is the caller's job, outside the lock end |