scala - value mkString is not a value of org.apache.spark.rdd.RDD[Int] -
i changed 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 giving me error hint: value mkstring not value of org.apache.spark.rdd.rdd[int]
what error mean?
val ratednum = rows.sortby(- _._2).map{case (user , ratednum) => ratednum} this returns org.apache.spark.rdd.rdd[int] not gentraversableonce. although has lot of methods defined makes scala collection of int, it not (abstract class rdd[t] extends serializable logging). it's bit promise of collection int. have poll collection out before mkstring results.
call .collect() on rdd[int] before perform mkstring.
val ratednum = rows.sortby(- _._2).map{case (user , ratednum) => ratednum}.collect.mkstring("::") or can add implicit conversion:
implicit def toarray[t](rdd: rdd[t]) = rdd.collect()