srowen commented on a change in pull request #26548: [SPARK-29918][SQL]
RecordBinaryComparator should check endianness when compared by long
URL: https://github.com/apache/spark/pull/26548#discussion_r347019987
##########
File path:
sql/core/src/main/java/org/apache/spark/sql/execution/RecordBinaryComparator.java
##########
@@ -49,9 +51,13 @@ public int compare(
// for architectures that support unaligned accesses, chew it up 8 bytes
at a time
if (Platform.unaligned() || (((leftOff + i) % 8 == 0) && ((rightOff + i) %
8 == 0))) {
while (i <= leftLen - 8) {
- final long v1 = Platform.getLong(leftObj, leftOff + i);
- final long v2 = Platform.getLong(rightObj, rightOff + i);
+ long v1 = Platform.getLong(leftObj, leftOff + i);
+ long v2 = Platform.getLong(rightObj, rightOff + i);
if (v1 != v2) {
+ if (ByteOrder.nativeOrder().equals(ByteOrder.LITTLE_ENDIAN)) {
+ v1 = Long.reverseBytes(v1);
+ v2 = Long.reverseBytes(v2);
+ }
return v1 > v2 ? 1 : -1;
Review comment:
Pulling together my comment with
https://github.com/apache/spark/pull/25491#issuecomment-551957225 - maybe this
also has to be `Long.compareUnsigned`?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]