code: public static <KeyType> int requiredBufferCapacity(
        KeySerde<KeyType> keySerde,
        AggregatorFactory[] aggregatorFactories
    )
    {
      int recordSize = keySerde.keySize();
      for (AggregatorFactory aggregatorFactory : aggregatorFactories) {
        recordSize += aggregatorFactory.getMaxIntermediateSizeWithNulls();
      }
      return recordSize * 3;
    }
docs: Returns the minimum buffer capacity required for this grouper.  This grouper keeps track read/write indexes
  and they cannot point the same array slot at the same time.  Since the read/write indexes move circularly, one
  extra slot is needed in addition to the read/write slots.  Finally, the required minimum buffer capacity is
  3 * record size.
  
  @return required minimum buffer capacity