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

    https://github.com/apache/spark/pull/1639#discussion_r15568992
  
    --- Diff: core/src/main/scala/org/apache/spark/rdd/RDD.scala ---
    @@ -1239,6 +1239,28 @@ abstract class RDD[T: ClassTag](
       /** The [[org.apache.spark.SparkContext]] that this RDD was created on. 
*/
       def context = sc
     
    +  /**
    +   * Private API for changing an RDD's ClassTag.
    +   * Used for internal Java <-> Scala API compatibility.
    +   */
    +  private[spark] def retag(cls: Class[T]): RDD[T] = {
    +    val classTag: ClassTag[T] = ClassTag.apply(cls)
    +    this.retag(classTag)
    +  }
    +
    +  /**
    +   * Private API for changing an RDD's ClassTag.
    +   * Used for internal Java <-> Scala API compatibility.
    +   */
    +  private[spark] def retag(classTag: ClassTag[T]): RDD[T] = {
    +    val oldRDD = this
    +    new RDD[T](sc, Seq(new OneToOneDependency(this)))(classTag) {
    +      override protected def getPartitions: Array[Partition] = 
oldRDD.getPartitions
    +      override def compute(split: Partition, context: TaskContext): 
Iterator[T] =
    +        oldRDD.compute(split, context)
    +    }
    --- End diff --
    
    Actually compute just works at the iterator level, so I don't think 
mapPartitions would hurt. All you do is pass through the parent's iterator. 
When you call compute() you're already deserializing the RDD, this won't create 
extra work.


---
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.
---

Reply via email to