Github user cloud-fan commented on a diff in the pull request: https://github.com/apache/spark/pull/16977#discussion_r102357800 --- 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 -- to strictly follow the previous behavior: users may still have the reference to the `data` and change it, but the result of `collect` should not be affected.
--- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org