@SuppressWarnings("squid:S3776") // Suppress high Cognitive Complexity warning
  public static void modifyChunkMetaData(
      List<? extends IChunkMetadata> chunkMetaData, List<ModEntry> modifications) {
    for (IChunkMetadata metaData : chunkMetaData) {
      for (ModEntry modification : modifications) {
        doModifyChunkMetaData(modification, metaData);
      }
    }
    // remove chunks that are completely deleted
    chunkMetaData.removeIf(
        metaData -> {
          if (metaData.getDeleteIntervalList() != null) {
            for (TimeRange range : metaData.getDeleteIntervalList()) {
              if (range.contains(metaData.getStartTime(), metaData.getEndTime())) {
                return true;
              } else {
                if (range.overlaps(new TimeRange(metaData.getStartTime(), metaData.getEndTime()))) {
                  metaData.setModified(true);
                }
              }
            }
          }
          return false;
        });
  }
modifyChunkMetaData iterates the chunkMetaData and applies all available modifications on it to
generate a ModifiedChunkMetadata. <br>
the caller should guarantee that chunkMetaData and modifications refer to the same time series
paths.

@param chunkMetaData the original chunkMetaData.
@param modifications all possible modifications.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/ModificationUtils.java