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

    https://github.com/apache/spark/pull/6652#discussion_r31782198
  
    --- 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 =>
    --- End diff --
    
    You are right. Its the same 3 lines of code imperatively as well. And 
create a bit less garbage I reuse the hashmap across reducers now.  Let me know 
if this looks okay


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