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

    https://github.com/apache/spark/pull/17596#discussion_r113599198
  
    --- Diff: core/src/main/scala/org/apache/spark/executor/TaskMetrics.scala 
---
    @@ -308,16 +305,17 @@ private[spark] object TaskMetrics extends Logging {
        */
       def fromAccumulators(accums: Seq[AccumulatorV2[_, _]]): TaskMetrics = {
         val tm = new TaskMetrics
    -    val (internalAccums, externalAccums) =
    -      accums.partition(a => a.name.isDefined && 
tm.nameToAccums.contains(a.name.get))
    -
    -    internalAccums.foreach { acc =>
    -      val tmAcc = 
tm.nameToAccums(acc.name.get).asInstanceOf[AccumulatorV2[Any, Any]]
    -      tmAcc.metadata = acc.metadata
    -      tmAcc.merge(acc.asInstanceOf[AccumulatorV2[Any, Any]])
    +    for (acc <- accums) {
    +      val name = AccumulatorContext.get(acc.id).flatMap(_.name)
    +      if (name.isDefined && tm.nameToAccums.contains(name.get)) {
    +        val tmAcc = 
tm.nameToAccums(name.get).asInstanceOf[AccumulatorV2[Any, Any]]
    +        tmAcc.metadata = acc.metadata
    +        tmAcc.merge(acc.asInstanceOf[AccumulatorV2[Any, Any]])
    +      } else {
    +        acc.metadata = acc.metadata.copy(name = name)
    --- End diff --
    
    Oh right. Another question is, since name is coming from acc.name, why we 
copy it back to acc.metadata?


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