使用 Java 将 spark RDD 保存到本地文件系统 [英] Save a spark RDD to the local file system using Java

查看:72
本文介绍了使用 Java 将 spark RDD 保存到本地文件系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 Spark 生成的 RDD.现在,如果我将此 RDD 写入 csv 文件,则会提供一些方法,例如saveAsTextFile()",该方法将 csv 文件输出到 HDFS.

I have a RDD that is generated using Spark. Now if I write this RDD to a csv file, I am provided with some methods like "saveAsTextFile()" which outputs a csv file to the HDFS.

我想将文件写入我的本地文件系统,以便我的 SSIS 进程可以从系统中选取文件并将它们加载到数据库中.

I want to write the file to my local file system so that my SSIS process can pick the files from the system and load them into the DB.

我目前无法使用 sqoop.

I am currently unable to use sqoop.

除了编写 shell 脚本之外,在 Java 中是否有可能做到这一点.

Is it somewhere possible in Java other than writing shell scripts to do that.

需要任何说明,请告知.

Any clarity needed, please let know.

推荐答案

saveAsTextFile 能够接收本地文件系统路径(例如 file:///tmp/magic/...).但是,如果您在分布式集群上运行,您很可能希望 collect() 将数据返回到集群,然后使用标准文件操作将其保存.

saveAsTextFile is able to take in local file system paths (e.g. file:///tmp/magic/...). However, if your running on a distributed cluster, you most likely want to collect() the data back to the cluster and then save it with standard file operations.

这篇关于使用 Java 将 spark RDD 保存到本地文件系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆