public static List<HiveSourceSplit> createInputSplits(
            int minNumSplits,
            List<HiveTablePartition> partitions,
            JobConf jobConf,
            boolean isForParallelismInfer)
            throws IOException {
        if (isForParallelismInfer) {
            // it's for parallelism inference, we will try to use the configuration
            // "table.exec.hive.infer-source-parallelism.max" as the min split num
            // to split the Hive files to improve the parallelism
            setSplitMaxSize(
                    partitions,
                    jobConf,
                    Integer.parseInt(
                            jobConf.get(
                                    HiveOptions.TABLE_EXEC_HIVE_INFER_SOURCE_PARALLELISM_MAX
                                            .key())));

        } else {
            setSplitMaxSize(partitions, jobConf, minNumSplits);
        }
        int threadNum = getThreadNumToSplitHiveFile(jobConf);
        List<HiveSourceSplit> hiveSplits = new ArrayList<>();
        try (MRSplitsGetter splitsGetter = new MRSplitsGetter(threadNum)) {
            for (HiveTablePartitionSplits partitionSplits :
                    splitsGetter.getHiveTablePartitionMRSplits(minNumSplits, partitions, jobConf)) {
                HiveTablePartition partition = partitionSplits.getHiveTablePartition();
                for (InputSplit inputSplit : partitionSplits.getInputSplits()) {
                    Preconditions.checkState(
                            inputSplit instanceof FileSplit,
                            "Unsupported InputSplit type: " + inputSplit.getClass().getName());
                    hiveSplits.add(new HiveSourceSplit((FileSplit) inputSplit, partition, null));
                }
            }
        }
        return hiveSplits;
    }
@Test
    public void testCreateInputSplits() throws Exception {
        int numSplits = 1000;
        // create a jobConf with default configuration
        JobConf jobConf = new JobConf();
        jobConf.set(HiveOptions.TABLE_EXEC_HIVE_CALCULATE_PARTITION_SIZE_THREAD_NUM.key(), "1");
        File wareHouse = temporaryFolder.newFolder("testCreateInputSplits");
        // init the files for the partition
        StorageDescriptor sd = new StorageDescriptor();
        // set orc format
        SerDeInfo serdeInfo = new SerDeInfo();
        serdeInfo.setSerializationLib(OrcSerde.class.getName());
        sd.setSerdeInfo(serdeInfo);
        sd.setInputFormat(OrcInputFormat.class.getName());
        sd.setLocation(wareHouse.toString());
        String baseFilePath =
                Objects.requireNonNull(this.getClass().getResource("/orc/test.orc")).getPath();
        Files.copy(Paths.get(baseFilePath), Paths.get(wareHouse.toString(), "t.orc"));
        // use default configuration
        List<HiveSourceSplit> hiveSourceSplits =
                HiveSourceFileEnumerator.createInputSplits(
                        numSplits,
                        Collections.singletonList(new HiveTablePartition(sd, new Properties())),
                        jobConf,
                        false);
        // the single file is a single split
        assertThat(hiveSourceSplits.size()).isEqualTo(1);

        // set split max size and verify it works
        jobConf = new JobConf();
        jobConf.set(HiveOptions.TABLE_EXEC_HIVE_CALCULATE_PARTITION_SIZE_THREAD_NUM.key(), "1");
        jobConf.set(HiveOptions.TABLE_EXEC_HIVE_SPLIT_MAX_BYTES.key(), "10");
        // the splits should be more than the number of files
        hiveSourceSplits =
                HiveSourceFileEnumerator.createInputSplits(
                        numSplits,
                        Collections.singletonList(new HiveTablePartition(sd, new Properties())),
                        jobConf,
                        false);
        // the single file should be enumerated into two splits
        assertThat(hiveSourceSplits.size()).isEqualTo(2);

        jobConf = new JobConf();
        jobConf.set(HiveOptions.TABLE_EXEC_HIVE_CALCULATE_PARTITION_SIZE_THREAD_NUM.key(), "1");
        // set open cost and verify it works
        jobConf.set(HiveOptions.TABLE_EXEC_HIVE_FILE_OPEN_COST.key(), "1");
        hiveSourceSplits =
                HiveSourceFileEnumerator.createInputSplits(
                        numSplits,
                        Collections.singletonList(new HiveTablePartition(sd, new Properties())),
                        jobConf,
                        false);
        // the single file should be enumerated into two splits
        assertThat(hiveSourceSplits.size()).isEqualTo(2);
    }