我对scala和spark有点新意。现在我想在每个worker上生成一个向量。当我使用这一行时,我遇到了两个错误:
val b = sc.parallelize(1 to n, n).map( i => DenseVector[Double]](10.0,20.0,30.0,40.0))
No ClassTag available for Vec[Double]
not enough arguments for method map: (implicit evidence$3: scala.reflect.ClassTag[Vec[Double]])org.apache.spark.rdd.RDD[Vec[Double]]. Unspecified value parameter evidence$3.
有人可以帮我这个吗?
答案 0 :(得分:0)
以下为我工作
scala> import breeze.linalg._
scala> val n = 2
n: Int = 2
scala> val b = sc.parallelize(1 to n, n).map( i => DenseVector[Double](10.0,20.0,30.0,40.0))
b: org.apache.spark.rdd.RDD[breeze.linalg.DenseVector[Double]] = MapPartitionsRDD[1] at map at <console>:24
以下是rdd中的一些数据:
scala> b.take(1)
res1: Array[breeze.linalg.DenseVector[Double]] = Array(DenseVector(10.0, 20.0, 30.0, 40.0))