小编Gua*_*Shu的帖子

如何在 Spark/Scala 中将 Array[String] 转换为 Array[Any]

我正在尝试为 Graphframes 内的 parallelPersonalizedPageRank 算法生成 sourceIds 并调用该算法,如下所示:

val PPRIdCS = studentCS.select("id").collect.map(row => row.getString(0))
val ranksCS = studentGraph
  .parallelPersonalizedPageRank
  .resetProbability(0.15)
  .maxIter(10)
  .sourceIds(PPRIdCS)
  .run()
Run Code Online (Sandbox Code Playgroud)

我得到的错误信息如下:

Message: <console>:46: error: type mismatch;
found   : Array[String]
required: Array[Any]
Note: String <: Any, but class Array is invariant in type T.
You may wish to investigate a wildcard type such as `_ <: Any`. (SLS 
3.2.10).sourceIds(PPRIdCS)
Run Code Online (Sandbox Code Playgroud)

我无法弄清楚将 String 类型转换为 Any 类型的方法是什么,或者在生成 PPRIdCS 时将 String 映射到 Any 的方法。谢谢!

arrays scala graph apache-spark graphframes

1
推荐指数
1
解决办法
4967
查看次数

标签 统计

apache-spark ×1

arrays ×1

graph ×1

graphframes ×1

scala ×1