LuciferYang commented on a change in pull request #33260:
URL: https://github.com/apache/spark/pull/33260#discussion_r666015990
##########
File path:
core/src/main/java/org/apache/spark/shuffle/sort/ShuffleInMemorySorter.java
##########
@@ -31,9 +31,7 @@
private static final class SortComparator implements
Comparator<PackedRecordPointer> {
@Override
public int compare(PackedRecordPointer left, PackedRecordPointer right) {
- int leftId = left.getPartitionId();
- int rightId = right.getPartitionId();
- return leftId < rightId ? -1 : (leftId > rightId ? 1 : 0);
+ return Integer.compare(left.getPartitionId(), right.getPartitionId());
Review comment:
```
/**
* Compares two {@code int} values numerically.
* The value returned is identical to what would be returned by:
* <pre>
* Integer.valueOf(x).compareTo(Integer.valueOf(y))
* </pre>
*
* @param x the first {@code int} to compare
* @param y the second {@code int} to compare
* @return the value {@code 0} if {@code x == y};
* a value less than {@code 0} if {@code x < y}; and
* a value greater than {@code 0} if {@code x > y}
* @since 1.7
*/
public static int compare(int x, int y) {
return (x < y) ? -1 : ((x == y) ? 0 : 1);
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]