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

    https://github.com/apache/spark/pull/16603#discussion_r96296239
  
    --- Diff: core/src/main/java/org/apache/spark/memory/TaskMemoryManager.java 
---
    @@ -53,6 +57,28 @@
      */
     public class TaskMemoryManager {
     
    +  /**
    +   * A internal class used to sort MemoryConsumer based on their memory 
usage.
    +   * Note: This sorts consumers by descending order, i.e., the consumers 
using more memory
    +   *       are sorted ahead of the consumers using less.
    +   */
    +  private static final class ConsumerComparator implements 
Comparator<MemoryConsumer> {
    +    @Override
    +    public int compare(MemoryConsumer consumer1, MemoryConsumer consumer2) 
{
    +      // We can only compare the consumers which use the same mode.
    +      assert (consumer1.getMode() == consumer2.getMode()) :
    +        "Try to compare two MemoryConsumers which are in different memory 
mode.";
    +      if (consumer1.getUsed() < consumer2.getUsed()) {
    +        return 1;
    +      } else if (consumer1.getUsed() > consumer2.getUsed()) {
    +        return -1;
    +      } else {
    +        return 0;
    +      }
    --- End diff --
    
    Long.compare(consumer2.getUsed, consumer1.getUsed) instead


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