[英]value mkString is not a value of org.apache.spark.rdd.RDD[Int]
I changed this line: 我更改了这一行:
val ratedNum = rows.sortBy(- _._2).map{case (user , ratednum) => ratednum}.take(20).mkString("::")
to: 至:
val ratedNum = rows.sortBy(- _._2).map{case (user , ratednum) => ratednum}.mkString("::")
But Eclipse is giving me an error hint: value mkString is not a value of org.apache.spark.rdd.RDD[Int]
但是Eclipse给了我一个错误提示:
value mkString is not a value of org.apache.spark.rdd.RDD[Int]
What does this error mean? 这个错误是什么意思?
val ratedNum = rows.sortBy(- _._2).map{case (user , ratednum) => ratednum}
This returns an org.apache.spark.rdd.RDD[Int]
which is not GenTraversableOnce
. 这将返回不是
GenTraversableOnce
的org.apache.spark.rdd.RDD[Int]
。 Although it has a lot of methods defined which makes it like a Scala collection of Int
, it is not ( abstract class RDD[T] extends Serializable with Logging
). 尽管它定义了很多方法,使它像
Int
的Scala集合一样, 但不是 ( abstract class RDD[T] extends Serializable with Logging
)。 It's a bit like a promise of a collection Int
. 这有点像
Int
集合的承诺。 You have to poll the collection out before you mkString
with the results. 您必须先对集合进行轮询,然后
mkString
结果mkString
。
Call .collect()
on the RDD[Int]
before you perform mkString
. 在执行
mkString
之前,请在RDD[Int]
上调用.collect()
。
val ratedNum = rows.sortBy(- _._2).map{case (user , ratednum) => ratednum}.collect.mkString("::")
Or you can add an implicit conversion: 或者,您可以添加一个隐式转换:
implicit def toArray[T](rdd: RDD[T]) = rdd.collect()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.