@Override
      public List<Partition> next() {
        List<Partition> result = new ArrayList<>();
        if (mapEntry == null && iterator.hasNext()) {
          mapEntry = iterator.next();
        }
        if (current == null) {
          current = mapEntry.getValue().iterator();
        } else if (!current.hasNext() && iterator.hasNext()) {
          mapEntry = iterator.next();
          current = mapEntry.getValue().iterator();
        }

        int i = 0;
        while (current != null && current.hasNext() &&
            (batchSize <= 0 || i++ < batchSize)) {
          result.add(current.next());
        }
        return result;
      }
The partitions might have different write ids, groups the partitions by write id first,
then iterate each group, for each iteration, there is a maximum number(e.g, the batchSize)
of the partitions returned.
@param partitions partitions in this alter event
@param batchSize the maximum number of partitions returned in each iteration
@return iterator of partitions in bulk
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/events/AlterPartitionsEvent.java