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

    https://github.com/apache/spark/pull/7753#discussion_r43805729
  
    --- Diff: 
core/src/main/scala/org/apache/spark/scheduler/EventLoggingListener.scala ---
    @@ -228,6 +260,40 @@ private[spark] class EventLoggingListener(
         fileSystem.rename(new Path(logPath + IN_PROGRESS), target)
       }
     
    +  /**
    +   * According to the updated event to modify the maintained event's 
metrics
    +   * @param executorId  the executor whose metrics will be modified
    +   */
    +  private def updateModifiedMetrics(executorId: String): Unit = {
    +    val toBeModifiedEvent = executorIdToModifiedMaxMetrics.get(executorId)
    +    val latestEvent = executorIdToLatestMetrics.get(executorId)
    +    if (toBeModifiedEvent.isEmpty) {
    +      if (latestEvent.isDefined) 
executorIdToModifiedMaxMetrics.update(executorId, latestEvent.get)
    +    } else {
    +      val toBeModifiedMetrics = 
toBeModifiedEvent.get.executorMetrics.transportMetrics
    +      if (toBeModifiedMetrics.isDefined) {
    --- End diff --
    
    won't `latestEvent` always be defined?  In fact, at the one call site, you 
could even just pass in `latestEvent` directly so you avoid another lookup.  I 
also think this becomes slightly cleaner w/ pattern matching:
    
    ```scala
    private def updateModifiedMetrics(executorId: String, latestEvent: 
SparkListenerExecutorMetricsUpdate): Unit = {
      executorIdToModifiedMaxMetrics.get(executorId) match {
        case None => executorIdToModifiedMaxMetrics.update(executorId, 
latestEvent)
        case Some(toBeModEvent) =>
          val toBeModMetrics = toBeModEvent.executorMetrics.transportMetrics
          ...
      }
    }
    ```
    
    and depending on whether or not we need to keep `tranportMetrics` as an 
option, we may need to handle the else case here, right?


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

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to