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_r346996990
 
 

 ##########
 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)) {
 
 Review comment:
   Cant his check happen once and make it a constant rather than call each time?
   
   This is also the unfortunately the common case, little-endian architectures. 
Hm, I'm trying to think of an alternative that would introduce overhead only 
for big-endian, but not sure if it's possible. that said `reverseBytes` ought 
to be very fast. And I guess this only happens once before this terminates.

----------------------------------------------------------------
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]

Reply via email to