0
我想知道如何将键值对转换为输出字符串。目前,我的代码是这样的:星号键值对字符串
object Task2 {
def main(args: Array[String]) {
val sc = new SparkContext(new SparkConf().setAppName("Task2"))
// read the file
val file = sc.textFile("hdfs://localhost:8020" + args(0))
val split = file
.map(line => (line.split("\t")(1), line.split("\t")(2)))
.reduceByKey(_ + _)
// store output on given HDFS path.
fin.saveAsTextFile("hdfs://localhost:8020" + args(1))
}
}
分割输出给我键值对像(X,Y),但我想他们是由制表符分隔X Y对。我试过使用map和mkString无济于事。我该怎么办?