DataStream api using readFile 仅以批处理方式从文件夹中读取一个文件

DataStream api using readFile only reads one file from the folder in batch mode

正在编写一个简单的批处理模式作业,我在其中指定了文件夹路径。然而,在本地模式下只读取一个文件,当部署到集群时,读取的文件数与并行设置相同。用于阅读的简单代码:

val env = StreamExecutionEnvironment.getExecutionEnvironment
    env.setRuntimeMode(RuntimeExecutionMode.BATCH)

    val trans_data: DataStream[MyClass] = env.readFile(
                                              RowCsvInputFormat.builder(
                                                MyClass.getRowTypeInformation(),
                                                new Path(salesPath)
                                              ).build(),
                                              salesPath
                                            ).map(x=>MyClass.convertFromRow(x))

StreamExecutionEnvironment#readFile 不支持新的统一 batch/streaming 源接口。您可能应该改用新的 FileSource