cloud-fan 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_r347501403
##########
File path:
sql/core/src/main/java/org/apache/spark/sql/execution/RecordBinaryComparator.java
##########
@@ -38,32 +43,39 @@ public int compare(
// check if stars align and we can get both offsets to be aligned
if ((leftOff % 8) == (rightOff % 8)) {
while ((leftOff + i) % 8 != 0 && i < leftLen) {
- final int v1 = Platform.getByte(leftObj, leftOff + i) & 0xff;
- final int v2 = Platform.getByte(rightObj, rightOff + i) & 0xff;
+ final int v1 = Platform.getByte(leftObj, leftOff + i);
+ final int v2 = Platform.getByte(rightObj, rightOff + i);
if (v1 != v2) {
- return v1 > v2 ? 1 : -1;
+ return (v1 & 0xff) > (v2 & 0xff) ? 1 : -1;
}
i += 1;
}
}
// 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) {
- return v1 > v2 ? 1 : -1;
+ if (LITTLE_ENDIAN) {
Review comment:
ah you are right. then nvm
----------------------------------------------------------------
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]