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

    https://github.com/apache/spark/pull/14737#discussion_r75602575
  
    --- Diff: 
core/src/main/scala/org/apache/spark/ui/scope/RDDOperationGraph.scala ---
    @@ -119,18 +119,47 @@ private[ui] object RDDOperationGraph extends Logging {
           { if (stage.attemptId == 0) "" else s" (attempt ${stage.attemptId})" 
}
         val rootCluster = new RDDOperationCluster(stageClusterId, 
stageClusterName)
     
    +    var rootNodeCount = 0
    +    val addRDDIds = new mutable.HashSet[Int]()
    +    val dropRDDIds = new mutable.HashSet[Int]()
    +
    +    def isAllowed(ids: mutable.HashSet[Int], rdd: RDDInfo): Boolean = {
    +      val parentIds = rdd.parentIds
    +      if (parentIds.size == 0) {
    +        rootNodeCount < retainedNodes
    +      } else {
    +        if (ids.size > 0) {
    +            parentIds.exists(id => ids.contains(id) || 
!dropRDDIds.contains(id))
    +        } else {
    +            true
    +        }
    +      }
    +    }
    +
         // Find nodes, edges, and operation scopes that belong to this stage
    -    stage.rddInfos.foreach { rdd =>
    -      edges ++= rdd.parentIds.map { parentId => RDDOperationEdge(parentId, 
rdd.id) }
    +    stage.rddInfos.sortBy(_.id).foreach { rdd =>
    +      val keepNode: Boolean = isAllowed(addRDDIds, rdd)
    +      if (keepNode) {
    +        addRDDIds.add(rdd.id)
    +        edges ++= rdd.parentIds.filter(id => !dropRDDIds.contains(id))
    +          .map { parentId => RDDOperationEdge(parentId, rdd.id) }
    --- End diff --
    
    This isn't just a question of whether `{ }` is necessary, but also whether 
using them to delimit closures with `map`, `filter`, etc. has become the 
defacto and accepted style in Spark code.  It has -- for just one of many, many 
examples, see the code that this diff is replacing.  Delimiting closures in 
this way even when not strictly necessary improves consistency and readability 
by not requiring more parsing of parentheses levels.  I wouldn't have 
recommended that this diff be changed. 


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

Reply via email to