Github user pwendell commented on a diff in the pull request:
https://github.com/apache/spark/pull/469#discussion_r11838597
--- Diff: core/src/main/scala/org/apache/spark/rdd/RDD.scala ---
@@ -236,6 +236,21 @@ abstract class RDD[T: ClassTag](
}
/**
+ * Return the ancestors of the given RDD that are related to it only
through a sequence of
+ * narrow dependencies. This traverses the given RDD's dependency tree
using DFS.
+ */
+ private[spark] def getNarrowAncestors(
+ ancestors: ArrayBuffer[RDD[_]] = ArrayBuffer.empty): Seq[RDD[_]] = {
+ val narrowDependencies = dependencies.collect { case d:
NarrowDependency[_] => d }
+ val narrowParents = narrowDependencies.map(_.rdd)
+ narrowParents.foreach { parent =>
+ ancestors += parent
--- End diff --
Since users can define their own (potentially invalid) RDD classes, it
might make sense to check for cycles here, otherwise this will hang. Would it
be sufficient to just check if `parent == this` and then throw an
`IllegalStateException` if it's encountered? It might also be nice to add a
unit test for this case.
Indeed, you could encounter an RDD that is its own grandfather, thus
defying the laws of time an space.
---
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.
---