private boolean loadTsFileToUnSequence(
      final File tsFileToLoad,
      final TsFileResource tsFileResource,
      final long filePartitionId,
      final boolean deleteOriginFile,
      boolean isGeneratedByPipe)
      throws LoadFileException, DiskSpaceInsufficientException {
    final int targetTierLevel = 0;
    final File targetFile =
        (tsFileResource.isGeneratedByPipeConsensus() || tsFileResource.isGeneratedByPipe())
            ? pipeAndIoTV2LoadDiskSelector.getTargetFile(
                tsFileToLoad,
                databaseName,
                dataRegionId,
                filePartitionId,
                tsFileResource.getTsFile().getName(),
                targetTierLevel)
            : ordinaryLoadDiskSelector.getTargetFile(
                tsFileToLoad,
                databaseName,
                dataRegionId,
                filePartitionId,
                tsFileResource.getTsFile().getName(),
                targetTierLevel);

    tsFileResource.setFile(targetFile);
    if (tsFileManager.contains(tsFileResource, false)) {
      logger.warn("The file {} has already been loaded in unsequence list", tsFileResource);
      return false;
    }

    logger.info(
        "Load tsfile in unsequence list, move file from {} to {}",
        tsFileToLoad.getAbsolutePath(),
        targetFile.getAbsolutePath());

    LoadTsFileRateLimiter.getInstance().acquire(tsFileResource.getTsFile().length());

    // move file from sync dir to data dir
    if (!targetFile.getParentFile().exists()) {
      targetFile.getParentFile().mkdirs();
    }
    try {
      if (deleteOriginFile) {
        RetryUtils.retryOnException(
            () -> {
              FileUtils.moveFile(tsFileToLoad, targetFile);
              return null;
            });
      } else {
        RetryUtils.retryOnException(
            () -> {
              Files.copy(tsFileToLoad.toPath(), targetFile.toPath());
              return null;
            });
      }
    } catch (final IOException e) {
      logger.warn(
          "File renaming failed when loading tsfile. Origin: {}, Target: {}",
          tsFileToLoad.getAbsolutePath(),
          targetFile.getAbsolutePath(),
          e);
      throw new LoadFileException(
          String.format(
              "File renaming failed when loading tsfile. Origin: %s, Target: %s, because %s",
              tsFileToLoad.getAbsolutePath(), targetFile.getAbsolutePath(), e.getMessage()));
    }

    final File resourceFileToLoad =
        fsFactory.getFile(tsFileToLoad.getAbsolutePath() + RESOURCE_SUFFIX);
    final File targetResourceFile =
        fsFactory.getFile(targetFile.getAbsolutePath() + RESOURCE_SUFFIX);
    try {
      if (deleteOriginFile) {
        RetryUtils.retryOnException(
            () -> {
              FileUtils.moveFile(resourceFileToLoad, targetResourceFile);
              return null;
            });
      } else {
        RetryUtils.retryOnException(
            () -> {
              Files.copy(resourceFileToLoad.toPath(), targetResourceFile.toPath());
              return null;
            });
      }
    } catch (final IOException e) {
      logger.warn(
          "File renaming failed when loading .resource file. Origin: {}, Target: {}",
          resourceFileToLoad.getAbsolutePath(),
          targetResourceFile.getAbsolutePath(),
          e);
      throw new LoadFileException(
          String.format(
              "File renaming failed when loading .resource file. Origin: %s, Target: %s, because %s",
              resourceFileToLoad.getAbsolutePath(),
              targetResourceFile.getAbsolutePath(),
              e.getMessage()));
    }

    loadModFile(tsFileToLoad, targetFile, deleteOriginFile, tsFileResource);

    // Listen before the tsFile is added into tsFile manager to avoid it being compacted
    PipeInsertionDataNodeListener.getInstance()
        .listenToTsFile(dataRegionId, databaseName, tsFileResource, true, isGeneratedByPipe);

    tsFileManager.add(tsFileResource, false);

    return true;
  }
Execute the loading process by the type.

@param tsFileResource tsfile resource to be loaded
@param filePartitionId the partition id of the new file
@param deleteOriginFile whether to delete the original file
@return load the file successfully @UsedBy sync module, load external tsfile module.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/DataRegion.java