You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by uncleGen <gi...@git.apache.org> on 2017/02/20 06:34:32 UTC

[GitHub] spark pull request #16977: [SPARK-19651][CORE] ParallelCollectionRDD.collect...

Github user uncleGen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16977#discussion_r101954581
  
    --- 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 --
    
    Why should we simulate like this?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org