private void checkArgs() {
        // At most two modes, and must either be sub set of [Partial, PartialMerge] or [Final, Complete].
        Preconditions.checkState(modes.size() <= 2);
        Preconditions.checkState(
                Sets.difference(modes, Sets.newHashSet(AggregateMode.Partial, AggregateMode.PartialMerge)).isEmpty()
                        || Sets.difference(modes, Sets.newHashSet(AggregateMode.Final, AggregateMode.Complete)).isEmpty());
    }
The base class of [[SortBasedAggregationIterator]] and [[TungstenAggregationIterator]].
It mainly contains two parts:
1. It initializes aggregate functions.
2. It creates two functions, `processRow` and `generateOutput` based on [[AggregateMode]] of
its aggregate functions. `processRow` is the function to handle an input. `generateOutput`
is used to generate result.
indexr-query-opt/src/main/java/org/apache/spark/sql/execution/aggregate/AggregationIterator.java