You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@spark.apache.org by wxhsdp <wx...@gmail.com> on 2014/04/20 05:50:27 UTC
questions about toArray and ClassTag
Hi, all
i'am quite new in scala, i do some tests in spark shell
val b = a.mapPartitions{D =>
val p = D.toArray
.....
p.toIterator
}
when a is an RDD of type RDD[Int], b.collect() works. but when i change a to
RDD[MyOwnType], b.collect() returns error:
14/04/20 10:14:46 ERROR OneForOneStrategy:
[L$line5.$read$$iwC$$iwC$$iwC$$iwC$InputMatrix;
java.lang.ArrayStoreException:
[L$line5.$read$$iwC$$iwC$$iwC$$iwC$InputMatrix;
at scala.runtime.ScalaRunTime$.array_update(ScalaRunTime.scala:88)
i figure out the question is about toArray
def toArray[B >: A](implicit arg0: ClassTag[B]): Array[B]
an array containing all elements of this traversable or iterator. An
ClassTag must be available for the element type of this traversable or
iterator.
but i do not know how to do this, how to define an ClassTag, and give it to
toArray? i tried to set implicit
arg0 like this:
val p = D.toArray(classTag[MyOwnType])
but it doesn't work
thanks for your help
--
View this message in context: http://apache-spark-user-list.1001560.n3.nabble.com/questions-about-toArray-and-ClassTag-tp4496.html
Sent from the Apache Spark User List mailing list archive at Nabble.com.