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

    https://github.com/apache/spark/pull/17297#discussion_r107040190
  
    --- Diff: core/src/main/scala/org/apache/spark/MapOutputTracker.scala ---
    @@ -418,6 +424,15 @@ private[spark] class MapOutputTrackerMaster(conf: 
SparkConf,
         cachedSerializedStatuses.contains(shuffleId) || 
mapStatuses.contains(shuffleId)
       }
     
    +  /** Get the epoch for map output for a shuffle, if it is available */
    +  def getEpochForMapOutput(shuffleId: Int, mapId: Int): Option[Long] = {
    +    val arrayOpt = mapStatuses.get(shuffleId)
    +    if (arrayOpt.isDefined && arrayOpt.get != null && arrayOpt.get(mapId) 
!= null) {
    +       return Some(epochForMapStatus.get(shuffleId).get(mapId))
    +    }
    +    None
    +  }
    --- End diff --
    
    First, `arrayOpt.get != null` isn't necessary since we don't put `null` 
values into `mapStatuses`. Second, `epochForMapStatus.get(shuffleId).get` is 
the same as `epochForMapStatus(shuffleId)`. Third, I don't like all the 
explicit `get`s,`null` checks and the unnecessary non-local `return`. To my 
mind, this is better:
    ``` scala
      def getEpochForMapOutput(shuffleId: Int, mapId: Int): Option[Long] = {
        for {
          mapStatus <- mapStatuses.get(shuffleId).flatMap { mapStatusArray =>
            Option(mapStatusArray(mapId))
          }
        } yield epochForMapStatus(shuffleId)(mapId)
      }
    ``` 


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