2016-11-29 194 views
0

我有一个相对较小的RDD格式RDD[(Int, Double)],我希望写入一个csv文件。继Writing a RDD to a csv的逻辑,我结束了下面的代码:将RDD写入CSV文件

val myRdd.map{case(a, b) => 
    var line = a.toString + "," + b.toString 
    line 
}.saveAsTextFile 

不过,我收到以下错误:

Main.scala:111: ambiguous reference to overloaded definition, 
[error] both method saveAsTextFile in class RDD of type (path: String, codec: Class[_ <: org.apache.hadoop.io.compress.CompressionCodec])Unit 
[error] and method saveAsTextFile in class RDD of type (path: String)Unit 
[error] match expected type ? 
[error] }.saveAsTextFile 
[error] ^

有什么建议?

回答

2

必须提供路径:

val myRdd.map{case(a, b) => 
    var line = a.toString + "," + b.toString 
    line 
}.saveAsTextFile("path"); 

本地和HDFS路径是正确的。 Here是文档

+0

是的 - 从链接的问题的答案包含错误 –

+0

提供路径解决问题 - 欣赏建议。 – mongolol

+0

哈哈,六分钟,直到我可以:P – mongolol