@SuppressWarnings("squid:S1319")
    private LinkedList<Pair<TsFileSequenceReader, List<ChunkMetadata>>>
        calculateMetadataListForCurrentSeries() throws IllegalPathException {
      if (seriesInThisIteration.isEmpty()) {
        return new LinkedList<>();
      }
      IDeviceID device = currentDevice.getLeft();
      currentCompactingSeries = seriesInThisIteration.removeFirst();

      LinkedList<Pair<TsFileSequenceReader, List<ChunkMetadata>>>
          readerAndChunkMetadataForThisSeries = new LinkedList<>();

      for (TsFileResource resource : tsFileResourcesSortedByAsc) {
        TsFileSequenceReader reader = readerMap.get(resource);
        Map<String, List<ChunkMetadata>> chunkMetadataListMap = chunkMetadataCacheMap.get(reader);

        ModEntry ttlDeletion = null;
        Optional<Long> startTime = resource.getStartTime(device);
        if (startTime.isPresent() && startTime.get() < timeLowerBoundForCurrentDevice) {
          ttlDeletion =
              new TreeDeletionEntry(
                  new MeasurementPath(device, IoTDBConstant.ONE_LEVEL_PATH_WILDCARD),
                  Long.MIN_VALUE,
                  timeLowerBoundForCurrentDevice);
        }

        if (chunkMetadataListMap.containsKey(currentCompactingSeries)) {
          // get the chunk metadata list and modification list of current series in this tsfile
          List<ChunkMetadata> chunkMetadataListInThisResource =
              chunkMetadataListMap.get(currentCompactingSeries);
          chunkMetadataListMap.remove(currentCompactingSeries);

          List<ModEntry> modificationsInThisResource =
              modificationCache.computeIfAbsent(
                  resource, r -> new ArrayList<>(r.getAllModEntries()));
          LinkedList<ModEntry> modificationForCurrentSeries = new LinkedList<>();
          // collect the modifications for current series
          for (ModEntry modification : modificationsInThisResource) {
            if (modification.affects(device) && modification.affects(currentCompactingSeries)) {
              modificationForCurrentSeries.add(modification);
            }
          }
          // add ttl deletion for current series
          if (ttlDeletion != null) {
            modificationForCurrentSeries.add(ttlDeletion);
          }

          // if there are modifications of current series, apply them to the chunk metadata
          if (!modificationForCurrentSeries.isEmpty()) {
            ModificationUtils.modifyChunkMetaData(
                chunkMetadataListInThisResource, modificationForCurrentSeries);
          }

          readerAndChunkMetadataForThisSeries.add(
              new Pair<>(reader, chunkMetadataListInThisResource));
        }
      }
      return readerAndChunkMetadataForThisSeries;
    }
Collect all the chunk metadata of current series from the source files.

<p>If there are any modifications for these chunk, we will apply them to the metadata. Use
`ChunkMetadata.getDeleteIntervalList() == null` to judge if the chunk is modified.

@return all the chunk metadata of current series
@throws IllegalPathException if path is illegal
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/execute/utils/MultiTsFileDeviceIterator.java