private void updateParamTableInBatch(String paramTable, String idColumn, List<Long> ids,
                                       Map<Long, Optional<Map<String, String>>> newParamsOpt) throws MetaException {
    Map<Long, Map<String, String>> oldParams = getParams(paramTable, idColumn, ids);

    List<Pair<Long, String>> paramsToDelete = new ArrayList<>();
    List<Pair<Long, Pair<String, String>>> paramsToUpdate = new ArrayList<>();
    List<Pair<Long, Pair<String, String>>> paramsToAdd = new ArrayList<>();

    for (Long id : ids) {
      Map<String, String> oldParam = oldParams.getOrDefault(id, new HashMap<>());
      Map<String, String> newParam = newParamsOpt.get(id).orElseGet(HashMap::new);
      for (Map.Entry<String, String> entry : oldParam.entrySet()) {
        String key = entry.getKey();
        String oldValue = entry.getValue();
        if (!newParam.containsKey(key)) {
          paramsToDelete.add(Pair.of(id, key));
        } else if (!oldValue.equals(newParam.get(key))) {
          paramsToUpdate.add(Pair.of(id, Pair.of(key, newParam.get(key))));
        }
      }
      List<Pair<Long, Pair<String, String>>> newlyParams = newParam.entrySet().stream()
          .filter(entry -> !oldParam.containsKey(entry.getKey()))
          .map(entry -> Pair.of(id, Pair.of(entry.getKey(), entry.getValue())))
          .collect(Collectors.toList());
      paramsToAdd.addAll(newlyParams);
    }

    deleteParams(paramTable, idColumn, paramsToDelete);
    updateParams(paramTable, idColumn, paramsToUpdate);
    insertParams(paramTable, idColumn, paramsToAdd);
  }
Gets the next CS id from sequence MPartitionColumnStatistics and increment the CS id by numStats.
@return The CD id before update.
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/DirectSqlUpdatePart.java