-
-
Notifications
You must be signed in to change notification settings - Fork 31
Rollup Architecture
Best viewed via this link or by clicking the image:

apex-rollup is broken into two distinct sections, by default:
- the operations performed synchronously
- the operations performed asynchronously (unless
RollupControl__mdt.ShouldRunAs__cis set toSYNCHRONOUSLY)
The operations that run sync are primarily marshalled by Rollup - this class is the backbone of the application, as well as its primary entrance point (the sole exception being RollupFlowBulkProcessor and RollupFlowBulkSaver, which are delegates that call into Rollup itself).
All instances of Rollup have a member list, rollups of type List<RollupAsyncProcessor>: an actual rollup operation that is cleared to run asynchronously will also be of type RollupAsyncProcessor. The "outer" rollup, or "rollup conductor" is either:
-
an instance of
Rollup- it has no inner rollups; itsrollupslist is empty, and no asynchronous operation is performed -
an instance of
RollupAsyncProcessor, whose innerrollupscan have many different forms:-
RollupAsyncProcessor- the most standard type; each instance creates aRollupCalculatorand runs through the appropriate rollup calculation -
RollupFullBatchRecalculator- usesDatabase.Batchableto create the equivalent of a for loop for a given set of rollup operations -
RollupDeferredFullRecalcProcessor- essentially a Queueable version ofRollupFullBatchRecalculator -
RollupParentResetProcessor- a specialized subclass ofRollupFullBatchRecalculatorthat resets parent-level values when there are no children records for a given parent or set of parents
RollupAsyncProcessoritself has two different implementations:- the outer class is a
Database.Batchableimplementation, for when the number of parent records retrieved would exceed the limit defined byRollupControl__mdt.MaxLookupRowsBeforeBatching__c -
RollupAsyncProcessor.QueueableProcessorwhich is the default implementation, unlessRollupControl__mdt.ShouldRunAs__cis tweaked. Acts the same as the outer class's batchable implementation, but as a queueable instead
-