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

    https://github.com/apache/spark/pull/13318#discussion_r64781946
  
    --- Diff: 
sql/core/src/main/java/org/apache/spark/sql/execution/UnsafeKVExternalSorter.java
 ---
    @@ -86,14 +88,16 @@ public UnsafeKVExternalSorter(
             prefixComparator,
             /* initialSize */ 4096,
             pageSizeBytes,
    -        keySchema.length() == 1 && 
SortPrefixUtils.canSortFullyWithPrefix(keySchema.apply(0)));
    +        canUseRadixSort);
         } else {
    +      // The array will be used to do in-place sort, which require half of 
the space to be empty.
    +      assert(map.numKeys() <= map.getArray().size() / 2);
           // During spilling, the array in map will not be used, so we can 
borrow that and use it
           // as the underline array for in-memory sorter (it's always large 
enough).
           // Since we will not grow the array, it's fine to pass `null` as 
consumer.
           final UnsafeInMemorySorter inMemSorter = new UnsafeInMemorySorter(
             null, taskMemoryManager, recordComparator, prefixComparator, 
map.getArray(),
    -        false /* TODO(ekl) we can only radix sort if the BytesToBytes load 
factor is <= 0.5 */);
    +        canUseRadixSort);
    --- End diff --
    
    We only need to make sure that only half of array could be used. The load 
factor could be different. For example, we could move the check into 
TungstenAggregate without changing the load factor of BytesToBytesMap.


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