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

    https://github.com/apache/spark/pull/18251#discussion_r122326018
  
    --- Diff: 
core/src/main/java/org/apache/spark/util/collection/unsafe/sort/UnsafeExternalSorter.java
 ---
    @@ -61,9 +61,10 @@
     
       /**
        * Force this sorter to spill when there are this many elements in 
memory. The default value is
    -   * 1024 * 1024 * 1024 / 2 which allows the maximum size of the pointer 
array to be 8G.
    +   * 1024 * 1024 * 1024 / 4 which allows the maximum size of the pointer 
array(including the
    --- End diff --
    
    Instead of explaining things this way, which is what caused the bug 
originally, how about doing the calculation the opposite way? e.g.
    
    ```
    private final static long ENTRY_SIZE = Long.BYTES * 4;
    private final static long MAX_ARRAY_SIZE = ByteUnit.GiB.toBytes(8L);
    public final static long DEFAULT_NUM_ELEMENTS_FOR_SPILL_THRESHOLD = 
MAX_ARRAY_SIZE / ENTRY_SIZE;
    ```
    
    Results in the same value, but the code is self-explanatory (assuming 
`ENTRY_SIZE` is correct).


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