static List<SortedSet<RegionInfo>> calculateMerges(int maxMergeCount,
    List<Pair<RegionInfo, RegionInfo>> overlaps) {
    if (overlaps.isEmpty()) {
      LOG.debug("No overlaps.");
      return Collections.emptyList();
    }
    List<SortedSet<RegionInfo>> merges = new ArrayList<>();
    // First group overlaps by table then calculate merge table by table.
    ListMultimap<TableName, Pair<RegionInfo, RegionInfo>> overlapGroups =
      ArrayListMultimap.create();
    for (Pair<RegionInfo, RegionInfo> pair : overlaps) {
      overlapGroups.put(pair.getFirst().getTable(), pair);
    }
    for (Map.Entry<TableName, Collection<Pair<RegionInfo, RegionInfo>>> entry : overlapGroups
      .asMap().entrySet()) {
      calculateTableMerges(maxMergeCount, merges, entry.getValue());
    }
    return merges;
  }
Run through <code>overlaps</code> and return a list of merges to run. Presumes overlaps are
ordered (which they are coming out of the CatalogJanitor consistency report).
@param maxMergeCount Maximum regions to merge at a time (avoid merging 100k regions in one go!)
hbase-server/src/main/java/org/apache/hadoop/hbase/master/janitor/MetaFixer.java