static CompactionTaskMetadataInfo collectMetadataInfoFromDisk(
      List<TsFileResource> resources, CompactionType taskType) throws IOException {
    CompactionEstimateUtils.addReadLock(resources);
    CompactionTaskMetadataInfo metadataInfo = new CompactionTaskMetadataInfo();
    long cost = 0L;
    Map<IDeviceID, Long> deviceMetadataSizeMap = new HashMap<>();
    try {
      for (TsFileResource resource : resources) {
        cost += resource.getTotalModSizeInByte();
        try (CompactionTsFileReader reader =
            new CompactionTsFileReader(resource.getTsFilePath(), taskType)) {
          for (Map.Entry<IDeviceID, Long> entry :
              getDeviceMetadataSizeMapAndCollectMetadataInfo(reader, metadataInfo).entrySet()) {
            deviceMetadataSizeMap.merge(entry.getKey(), entry.getValue(), Long::sum);
          }
        }
      }
      metadataInfo.metadataMemCost =
          cost + deviceMetadataSizeMap.values().stream().max(Long::compareTo).orElse(0L);
      return metadataInfo;
    } finally {
      CompactionEstimateUtils.releaseReadLock(resources);
    }
  }
Get the details of the tsfile, the returned array contains the following elements in sequence:

<p>total chunk num in this tsfile

<p>max chunk num of one timeseries in this tsfile

<p>max aligned series num in one device. If there is no aligned series in this file, then it
turns to be -1.

<p>max chunk num of one device in this tsfile

@throws IOException if io errors occurred
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/selector/estimator/CompactionEstimateUtils.java