Github user ericl commented on a diff in the pull request: https://github.com/apache/spark/pull/12490#discussion_r60327131 --- Diff: sql/core/src/main/java/org/apache/spark/sql/execution/UnsafeKVExternalSorter.java --- @@ -85,13 +85,15 @@ public UnsafeKVExternalSorter( recordComparator, prefixComparator, /* initialSize */ 4096, - pageSizeBytes); + pageSizeBytes, + keySchema.length() == 1 && SortPrefixUtils.canSortFullyWithPrefix(keySchema.apply(0))); } else { // 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()); + null, taskMemoryManager, recordComparator, prefixComparator, map.getArray(), + false /* TODO(ekl) is there enough existing memory to do radix sort here? */); --- End diff -- So we hit this case when `BytesToBytesMap` is unable to acquire more memory for rehashing. In this situation we can never use radix sort, since the default load factor of `BytesToBytesMap` is 0.75. One possibility is to decrease the `BytesToBytesMap` load factor used by `TungstenAggregate` to 0.5. Thoughts?
--- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org