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

    https://github.com/apache/spark/pull/1039#discussion_r14642773
  
    --- Diff: core/src/main/scala/org/apache/spark/rdd/RDD.scala ---
    @@ -1235,11 +1235,43 @@ abstract class RDD[T: ClassTag](
     
       /** A description of this RDD and its recursive dependencies for 
debugging. */
       def toDebugString: String = {
    -    def debugString(rdd: RDD[_], prefix: String = ""): Seq[String] = {
    -      Seq(prefix + rdd + " (" + rdd.partitions.size + " partitions)") ++
    -        rdd.dependencies.flatMap(d => debugString(d.rdd, prefix + "  "))
    +    // Apply a different rule to the last child
    +    def debugChildren(rdd: RDD[_], prefix: String): Seq[String] = {
    +      val len = rdd.dependencies.length
    +      len match {
    +        case 0 => Seq.empty
    +        case 1 =>
    +          val d = rdd.dependencies.head
    +          debugString(d.rdd, prefix, 
d.isInstanceOf[ShuffleDependency[_,_]], true)
    +        case _ =>
    +          val frontDeps = rdd.dependencies.take(len - 1)
    +          val endDep = rdd.dependencies.takeRight(1).head
    +          (frontDeps.flatMap(d => debugString(d.rdd, prefix, 
d.isInstanceOf[ShuffleDependency[_,_]]))
    --- End diff --
    
    For this it would be better to avoid this complex expression:
    
    ```
    val frontDeps = rdd.dependencies.take(len - 1)
    val frontDepStrings = frontDeps.flatMap(d => debugString(d.rdd, prefix, 
d.isInstanceOf[ShuffleDependency[_,_]])
    
    val lastDep = rdd.dependencies.last
    val lastDepString = debugString(lastDep.rdd, prefix, 
endDep.isInstanceOf[ShuffleDependency[_,_]], true) 
    
    (frontDepStrings ++ lastDepString)
    ```


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

Reply via email to