@@ -27,7 +27,7 @@ public final class RecordBinaryComparator extends RecordComparator {
2727 public int compare (
2828 Object leftObj , long leftOff , int leftLen , Object rightObj , long rightOff , int rightLen ) {
2929 int i = 0 ;
30- int res = 0 ;
30+ long res = 0 ;
3131
3232 // If the arrays have different length, the longer one is larger.
3333 if (leftLen != rightLen ) {
@@ -42,16 +42,16 @@ public int compare(
4242 while ((leftOff + i ) % 8 != 0 && i < leftLen ) {
4343 res = (Platform .getByte (leftObj , leftOff + i ) & 0xff ) -
4444 (Platform .getByte (rightObj , rightOff + i ) & 0xff );
45- if (res != 0 ) return res ;
45+ if (res != 0 ) return ( int ) res ;
4646 i += 1 ;
4747 }
4848 }
4949 // for architectures that support unaligned accesses, chew it up 8 bytes at a time
5050 if (Platform .unaligned () || (((leftOff + i ) % 8 == 0 ) && ((rightOff + i ) % 8 == 0 ))) {
5151 while (i <= leftLen - 8 ) {
52- res = ( int ) (( Platform .getLong (leftObj , leftOff + i ) -
53- Platform .getLong (rightObj , rightOff + i )) % Integer . MAX_VALUE ) ;
54- if (res != 0 ) return res ;
52+ res = Platform .getLong (leftObj , leftOff + i ) -
53+ Platform .getLong (rightObj , rightOff + i );
54+ if (res != 0 ) return res > 0 ? 1 : - 1 ;
5555 i += 8 ;
5656 }
5757 }
@@ -60,7 +60,7 @@ public int compare(
6060 while (i < leftLen ) {
6161 res = (Platform .getByte (leftObj , leftOff + i ) & 0xff ) -
6262 (Platform .getByte (rightObj , rightOff + i ) & 0xff );
63- if (res != 0 ) return res ;
63+ if (res != 0 ) return ( int ) res ;
6464 i += 1 ;
6565 }
6666
0 commit comments