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

    https://github.com/apache/spark/pull/6652#discussion_r31782208
  
    --- Diff: core/src/main/scala/org/apache/spark/MapOutputTracker.scala ---
    @@ -284,6 +291,41 @@ private[spark] class MapOutputTrackerMaster(conf: 
SparkConf)
         cachedSerializedStatuses.contains(shuffleId) || 
mapStatuses.contains(shuffleId)
       }
     
    +  /**
    +   * Return a list of locations which have the largest map outputs given a 
shuffleId
    +   * and a reducerId.
    +   *
    +   * This method is not thread-safe
    +   */
    +  def getLocationsWithLargestOutputs(
    +      shuffleId: Int,
    +      reducerId: Int,
    +      numReducers: Int,
    +      numTopLocs: Int)
    +    : Option[Array[BlockManagerId]] = {
    +    if (!shuffleIdToReduceLocations.contains(shuffleId) && 
mapStatuses.contains(shuffleId)) {
    +      // Pre-compute the top locations for each reducer and cache it
    +      val statuses = mapStatuses(shuffleId)
    +      if (statuses.nonEmpty) {
    +        val ordering = Ordering.by[(BlockManagerId, Long), 
Long](_._2).reverse
    +        shuffleIdToReduceLocations(shuffleId) = new HashMap[Int, 
Array[BlockManagerId]]
    +        var r = 0
    +        while (r < numReducers) {
    +          // Add up sizes of all blocks at the same location
    +          val locs = statuses.map { s =>
    +            (s.location, s.getSizeForBlock(r))
    +          }.groupBy(_._1).mapValues { sizes =>
    +            sizes.map(_._2).reduceLeft(_ + _)
    --- End diff --
    
    I made this imperative now per Josh's comment below. I think the new 
version is pretty readable, but let me now if you think its good


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