Github user JoshRosen commented on a diff in the pull request:
https://github.com/apache/spark/pull/1639#discussion_r15567618
--- 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 --
Would there be any performance impact of running `mapPartitions(identity,
preservesPartitioning = true)(classTag)`? If we have an RDD that's persisted
in a serialized format, wouldn't this extra map force an unnecessary
deserialization?
---
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.
---