From reviews-return-970821-archive-asf-public=cust-asf.ponee.io@spark.apache.org Mon Nov 18 16:10:28 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id C13A5180657 for ; Mon, 18 Nov 2019 17:10:26 +0100 (CET) Received: (qmail 33411 invoked by uid 500); 18 Nov 2019 16:10:25 -0000 Mailing-List: contact reviews-help@spark.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list reviews@spark.apache.org Received: (qmail 33399 invoked by uid 99); 18 Nov 2019 16:10:25 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 18 Nov 2019 16:10:25 +0000 From: GitBox To: reviews@spark.apache.org Subject: [GitHub] [spark] cloud-fan commented on a change in pull request #26548: [SPARK-29918][SQL] RecordBinaryComparator should check endianness when compared by long Message-ID: <157409342569.31780.15058208154366399067.gitbox@gitbox.apache.org> Date: Mon, 18 Nov 2019 16:10:25 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit 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_r347469303 ########## 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: for better perf, shall we move the if out of the while loop? e.g. ``` if (LITTLE_ENDIAN) { while ... return Long.compareUnsigned(Long.reverseBytes(v1), Long.reverseBytes(v2)) } else { while ... return Long.compareUnsigned(v1, v2); } ``` ---------------------------------------------------------------- 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: users@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org For additional commands, e-mail: reviews-help@spark.apache.org