Github user ConeyLiu commented on a diff in the pull request: https://github.com/apache/spark/pull/17936#discussion_r117427240 --- Diff: core/src/main/scala/org/apache/spark/rdd/CartesianRDD.scala --- @@ -71,9 +72,92 @@ class CartesianRDD[T: ClassTag, U: ClassTag]( } override def compute(split: Partition, context: TaskContext): Iterator[(T, U)] = { + val blockManager = SparkEnv.get.blockManager val currSplit = split.asInstanceOf[CartesianPartition] - for (x <- rdd1.iterator(currSplit.s1, context); - y <- rdd2.iterator(currSplit.s2, context)) yield (x, y) + val blockId2 = RDDBlockId(rdd2.id, currSplit.s2.index) + var cachedInLocal = false + var holdReadLock = false + + // Try to get data from the local, otherwise it will be cached to the local. + def getOrElseCache( + rdd: RDD[U], + partition: Partition, + context: TaskContext, + level: StorageLevel): Iterator[U] = { + getLocalValues() match { + case Some(result) => + return result + case None => if (holdReadLock) { + throw new SparkException(s"get() failed for block $blockId2 even though we held a lock") + } + } + + val iterator = rdd.iterator(partition, context) + if (rdd.getStorageLevel != StorageLevel.NONE || rdd.isCheckpointedAndMaterialized) { + // If the block is cached in local, wo shouldn't cache it again. --- End diff -- Ok, I'll change it, thanks very much.
--- 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