Github user rezasafi commented on a diff in the pull request:
https://github.com/apache/spark/pull/16977#discussion_r102350887
--- Diff:
core/src/main/scala/org/apache/spark/rdd/ParallelCollectionRDD.scala ---
@@ -105,6 +105,17 @@ private[spark] class ParallelCollectionRDD[T:
ClassTag](
override def getPreferredLocations(s: Partition): Seq[String] = {
locationPrefs.getOrElse(s.index, Nil)
}
+
+ override def collect(): Array[T] = toArray(data)
+
+ override def take(num: Int): Array[T] = toArray(data.take(num))
+
+ private def toArray(data: Seq[T]): Array[T] = {
+ // We serialize the data and deserialize it back, to simulate the
behavior of sending it to
+ // remote executors and collect it back.
+ val ser = sc.env.closureSerializer.newInstance()
+ ser.deserialize[Seq[T]](ser.serialize(data)).toArray
+ }
--- End diff --
If data is there why we just cannot call data.toArray instead of
serializing and then deserializing data?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]