-
-
Notifications
You must be signed in to change notification settings - Fork 30
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__c
is 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; itsrollups
list is empty, and no asynchronous operation is performed -
an instance of
RollupAsyncProcessor
, whose innerrollups
can have many different forms:-
RollupAsyncProcessor
- the most standard type; each instance creates aRollupCalculator
and runs through the appropriate rollup calculation -
RollupFullBatchRecalculator
- usesDatabase.Batchable
to create the equivalent of a for loop for a given set of rollup operations -
RollupDeferredFullRecalcProcessor
- essentially a Queueable version ofRollupFullBatchRecalculator
-
RollupParentResetProcessor
- a specialized subclass ofRollupFullBatchRecalculator
that resets parent-level values when there are no children records for a given parent or set of parents
RollupAsyncProcessor
itself has two different implementations:- the outer class is a
Database.Batchable
implementation, for when the number of parent records retrieved would exceed the limit defined byRollupControl__mdt.MaxLookupRowsBeforeBatching__c
-
RollupAsyncProcessor.QueueableProcessor
which is the default implementation, unlessRollupControl__mdt.ShouldRunAs__c
is tweaked. Acts the same as the outer class's batchable implementation, but as a queueable instead
-