简体   繁体   English

Scala 中的 saveasTextFile("path")

[英]saveasTextFile("path") in scala

I used Scala in Spark, and I tried to save my file in HDFS file, but I got an error.我在 Spark 中使用了 Scala,并尝试将我的文件保存在 HDFS 文件中,但出现错误。

I have tried rdd.saveAsTextFile("path"); sc.saveAsTextFile("pathe"); saveAsTextFile("path")我试过rdd.saveAsTextFile("path"); sc.saveAsTextFile("pathe"); saveAsTextFile("path") rdd.saveAsTextFile("path"); sc.saveAsTextFile("pathe"); saveAsTextFile("path")

scala> inputJPG.map(x=>x.split("")).map(array=>array(0)).sc.saveAsTextFile("/loudacre/iplist")
    <console>:28: error: value sc is not a member of Array[String]
                  inputJPG.map(x=>x.split("")).map(array=>array(0)).sc.saveAsTextFile("/loudacre/iplist")

I'm a new student and still learning Scala, so not familiar with RDD and Scala function.我是一个新学生,还在学习Scala,所以不熟悉RDD和Scala函数。 Turn to my problem.I found that is because I have val xx=data.collect() before which is not RDD, so I can't do data.saveAsTextFile in Spark.转向我的问题。我发现那是因为我之前有val xx=data.collect()不是 RDD,所以我不能在 Spark 中做 data.saveAsTextFile。 So I moved the .collect() function => val xx=data Then data.savaAsTextFile("path") works.所以我移动了.collect()函数 => val xx=data然后 data.savaAsTextFile("path") 工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM