private File generateTargetFile() throws IOException {
    String targetFileDir = sourceFile.getTsFile().getParentFile().getPath();
    TsFileNameGenerator.TsFileName sourceFileName =
        TsFileNameGenerator.getTsFileName(sourceFile.getTsFile().getName());
    String fileNameStr =
        String.format(
            "%d-%d-%d-%d" + IoTDBConstant.INNER_COMPACTION_TMP_FILE_SUFFIX,
            sourceFile.isSeq()
                ? lastAllocatedFileTimestamp.incrementAndGet()
                : sourceFileName.getTime(),
            sourceFile.isSeq() ? 0 : sourceFileName.getVersion(),
            sourceFileName.getInnerCompactionCnt() + 1,
            sourceFileName.getCrossCompactionCnt());
    // if source file is sequence, the sequence data targetFileDir should be replaced to unsequence
    if (sourceFile.isSeq()) {
      int pos = targetFileDir.lastIndexOf("sequence");
      targetFileDir =
          targetFileDir.substring(0, pos)
              + "unsequence"
              + targetFileDir.substring(pos + "sequence".length());
    }
    File targetFile = new File(targetFileDir + File.separator + fileNameStr);
    return targetFile;
  }
Repair the internal unsorted file by compaction and move it to unSequence space after compaction
whether the source TsFileResource is sequence or not.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/execute/task/RepairUnsortedFileCompactionTask.java