RDD 到 in.file 到外部进程到 out.file 到 RDD

RDD to in.file to external process to out.file to RDD

我需要从我的 EMR Spark 作业调用外部进程。我看到 rdd.pipe 允许我将 RDD 通过管道传输到进程。 (顺便说一句,是每个 RDD 一个进程,还是每个元素一个进程?)。

但是,我的外部进程需要一个文件名作为输入并生成一个文件作为输出。

如何调用此外部进程并随后将输出文件加载为 RDD?

is that one process per RDD, or one per element?

都没有。每个分区一个进程。

process requires a filename as input and generates a file as output. How can

最简单的解决方案是编写一个简单的包装器,它写入随机生成的路径、调用您的程序、读取文件并写入标准输出,这几乎就是 pipe 的全部内容。除非您写入分布式文件系统,否则您将无法检索输出。