private List<TsFileResource> filterResourcesByFileTimeIndexInOverlapValidation(
      List<TsFileResource> timePartitionSeqFiles, List<TsFileResource> targetFiles) {
    if (targetFiles.isEmpty()) {
      return timePartitionSeqFiles;
    }
    TsFileResource firstTargetResource = targetFiles.get(0);
    TsFileResource lastTargetResource = targetFiles.get(targetFiles.size() - 1);
    long minStartTimeInTargetFiles =
        targetFiles.stream().mapToLong(TsFileResource::getFileStartTime).min().getAsLong();
    long maxEndTimeInTargetFiles =
        targetFiles.stream().mapToLong(TsFileResource::getFileEndTime).max().getAsLong();
    List<TsFileResource> result = new ArrayList<>(timePartitionSeqFiles.size());
    int idx;
    for (idx = 0; idx < timePartitionSeqFiles.size(); idx++) {
      TsFileResource resource = timePartitionSeqFiles.get(idx);
      if (resource == firstTargetResource) {
        break;
      }
      if (resource.getFileEndTime() >= minStartTimeInTargetFiles) {
        result.add(resource);
      }
    }
    for (; idx < timePartitionSeqFiles.size(); idx++) {
      TsFileResource resource = timePartitionSeqFiles.get(idx);
      result.add(resource);
      if (resource == lastTargetResource) {
        break;
      }
    }
    for (idx += 1; idx < timePartitionSeqFiles.size(); idx++) {
      TsFileResource resource = timePartitionSeqFiles.get(idx);
      if (resource.getFileStartTime() <= maxEndTimeInTargetFiles) {
        result.add(resource);
      }
    }
    return result;
  }
This method find the File object of given filePath by searching it in every data directory. If
the file is not found, it will return null.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/execute/task/AbstractCompactionTask.java