val 结果是一个火花 DataFram,其列是 [uid: Int, vector: Vector]。但是recomRes的类型是RDD[DataFrame],我如何将recomRes中的所有结果映射到一个DataFrame?
val recomRes = result.rdd.map(row => {
val uid = row.apply(0)
val vec = row.getAs[Vector](1)
brp
.approxNearestNeighbors(vectors, vec, 5)
.withColumn("uid", lit(uid))
.select("uid", "aid", "distCol")
}
我试过用for循环来处理,但是非常非常慢。