Github user JoshRosen commented on a diff in the pull request:
https://github.com/apache/spark/pull/9241#discussion_r43460397
--- Diff:
core/src/main/java/org/apache/spark/util/collection/unsafe/sort/UnsafeInMemorySorter.java
---
@@ -83,37 +83,43 @@ public UnsafeInMemorySorter(
final PrefixComparator prefixComparator,
int initialSize) {
assert (initialSize > 0);
- this.pointerArray = new long[initialSize * 2];
+ this.array = new long[initialSize * 2];
this.memoryManager = memoryManager;
this.sorter = new Sorter<>(UnsafeSortDataFormat.INSTANCE);
this.sortComparator = new SortComparator(recordComparator,
prefixComparator, memoryManager);
}
+ public void reset() {
+ pos = 0;
+ }
+
/**
* @return the number of records that have been inserted into this
sorter.
*/
public int numRecords() {
- return pointerArrayInsertPosition / 2;
+ return pos / 2;
}
- public long getMemoryUsage() {
- return pointerArray.length * 8L;
+ private int newLength() {
+ return array.length < Integer.MAX_VALUE / 2 ? (array.length * 2) :
Integer.MAX_VALUE;
+ }
+
+ public long getMemoryToExpand() {
+ return (long) (newLength() - array.length) * 8L;
--- End diff --
Discussed offline; this is actually accounted for at the call site.
---
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]