@Override
    public void close(boolean aborted) throws HiveException {
      super.close(aborted);

      reusableAggregationBufferRows.clear();
      if (reusableKeyWrapperBuffer != null) {
        reusableKeyWrapperBuffer.clear();
      }
      if (!aborted) {
        flush(true);
      }
      if (!aborted && sumBatchSize == 0 && GroupByOperator.shouldEmitSummaryRow(conf)) {
        // in case the empty grouping set is preset; but no output has done
        // the "summary row" still needs to be emitted
        VectorHashKeyWrapperBase kw = keyWrappersBatch.getVectorHashKeyWrappers()[0];
        kw.setNull();
        int pos = conf.getGroupingSetPosition();
        if (pos >= 0) {
          long val = (1L << pos) - 1;
          keyWrappersBatch.setLongValue(kw, pos, val);
        }
        VectorAggregationBufferRow groupAggregators = allocateAggregationBuffer();
        finishAggregators(groupAggregators, false);
        writeSingleRow(kw, groupAggregators);
      }

    }
Adjust for grouping sets. For grouping sets, input records are processed 'n' number of times.
Ref processBatch(). Ensure that reduction is super effective, otherwise they become
memory intensive.
ql/src/java/org/apache/hadoop/hive/ql/exec/vector/VectorGroupByOperator.java