Github user JoshRosen commented on a diff in the pull request:
https://github.com/apache/spark/pull/9241#discussion_r43459132
--- Diff:
core/src/main/java/org/apache/spark/shuffle/sort/ShuffleInMemorySorter.java ---
@@ -37,33 +37,52 @@ public int compare(PackedRecordPointer left,
PackedRecordPointer right) {
* {@link PackedRecordPointer}. The sort operates on this array instead
of directly manipulating
* records.
*/
- private long[] pointerArray;
+ private long[] array;
/**
* The position in the pointer array where new records can be inserted.
*/
- private int pointerArrayInsertPosition = 0;
+ private int pos = 0;
public ShuffleInMemorySorter(int initialSize) {
assert (initialSize > 0);
- this.pointerArray = new long[initialSize];
- this.sorter = new Sorter<PackedRecordPointer,
long[]>(ShuffleSortDataFormat.INSTANCE);
+ this.array = new long[initialSize];
+ this.sorter = new Sorter<>(ShuffleSortDataFormat.INSTANCE);
}
- public void expandPointerArray() {
- final long[] oldArray = pointerArray;
+ public int numRecords() {
+ return pos;
+ }
+
+ public void reset() {
+ pos = 0;
+ }
+
+ private int newLength() {
// Guard against overflow:
- final int newLength = oldArray.length * 2 > 0 ? (oldArray.length * 2)
: Integer.MAX_VALUE;
- pointerArray = new long[newLength];
- System.arraycopy(oldArray, 0, pointerArray, 0, oldArray.length);
+ return array.length <= Integer.MAX_VALUE / 2 ?
+ (array.length * 2) : Integer.MAX_VALUE;
--- End diff --
Don't necessarily have to wrap this line.
---
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]