Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 99786200C3D for ; Tue, 28 Feb 2017 02:36:19 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 98056160B6C; Tue, 28 Feb 2017 01:36:19 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id E1CB4160B60 for ; Tue, 28 Feb 2017 02:36:18 +0100 (CET) Received: (qmail 2226 invoked by uid 500); 28 Feb 2017 01:36:18 -0000 Mailing-List: contact reviews-help@impala.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list reviews@impala.incubator.apache.org Received: (qmail 2215 invoked by uid 99); 28 Feb 2017 01:36:17 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Feb 2017 01:36:17 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 600E2C0ABA for ; Tue, 28 Feb 2017 01:36:17 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.363 X-Spam-Level: X-Spam-Status: No, score=0.363 tagged_above=-999 required=6.31 tests=[RDNS_DYNAMIC=0.363, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id LZKnW--1VVdm for ; Tue, 28 Feb 2017 01:36:16 +0000 (UTC) Received: from ip-10-146-233-104.ec2.internal (ec2-75-101-130-251.compute-1.amazonaws.com [75.101.130.251]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id 92D205F2C5 for ; Tue, 28 Feb 2017 01:36:15 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by ip-10-146-233-104.ec2.internal (8.14.4/8.14.4) with ESMTP id v1S1aBn7027223; Tue, 28 Feb 2017 01:36:11 GMT Message-Id: <201702280136.v1S1aBn7027223@ip-10-146-233-104.ec2.internal> Date: Tue, 28 Feb 2017 01:36:11 +0000 From: "Zach Amsden (Code Review)" To: impala-cr@cloudera.com, reviews@impala.incubator.apache.org CC: Dan Hecht Reply-To: zamsden@cloudera.com X-Gerrit-MessageType: comment Subject: =?UTF-8?Q?=5BImpala-ASF-CR=5D_IMPALA-4813=3A_Round_on_divide_and_multiply=0A?= X-Gerrit-Change-Id: Ie6bfcbe37555b74598d409c6f84f06b0ae5c4312 X-Gerrit-ChangeURL: X-Gerrit-Commit: 4cf8c6619d1686764be308eca18071ed0aaf08c0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Content-Disposition: inline User-Agent: Gerrit/2.12.7 archived-at: Tue, 28 Feb 2017 01:36:19 -0000 Zach Amsden has posted comments on this change. Change subject: IMPALA-4813: Round on divide and multiply ...................................................................... Patch Set 4: (11 comments) http://gerrit.cloudera.org:8080/#/c/6132/4/be/src/runtime/decimal-value.h File be/src/runtime/decimal-value.h: PS4, Line 122: /* round */ false > this should pass 'round' Done http://gerrit.cloudera.org:8080/#/c/6132/4/be/src/runtime/decimal-value.inline.h File be/src/runtime/decimal-value.inline.h: Line 194: namespace detail { > add a function comment. Done PS4, Line 198: be > garbled Done Line 205: // here that it is a power of two. > I think you mean "even" (or "power of ten"), not "power of two". Done Line 283: *overflow |= abs(result) > DecimalUtil::MAX_UNSCALED_DECIMAL16; > shouldn't this have the: Done PS4, Line 311: 2 * remainder > do we know this can't overflow? can you comment on that (and maybe add DCHE Yes, because the maximum value is at most the 128 bit int scaled up by 10**38 (in reality our scales can't get that high). I don't know of a way to do bitwise asserts with an int256_t, I'll see if it works. DCHECK_EQ is almost certain to throw up all over itself. Line 327: if (abs(2 * remainder) >= abs(y)) { This is where I'm worried about overflow. Patient and grueling testing has not been able to produce one yet. We should be able to compute a value that overflows into the sign bit when doubled, but to do so requires an actual value that should round away from zero. The compiler seems to be using an unsigned test here between the abs() comparisons, so despite the undefined behavior, it appears to still get the right answer. Still investigating this a bit more thoroughly. http://gerrit.cloudera.org:8080/#/c/6132/4/be/src/util/bit-util-test.cc File be/src/util/bit-util-test.cc: Line 37: EXPECT_EQ(BitUtil::UnsignedWidth(), 7); > this is implementation dependent. maybe say "signed char" to remove that de Done Line 42: EXPECT_GT(BitUtil::UnsignedWidth(), 256); Oh, this was the test I mentioned. BitUtil::IncrementAwayFromZero is undefined for non compiler implemented types. Line 60: EXPECT_EQ(BitUtil::IncrementAwayFromZero(-200), -201); > what happens with the 256 bit type we use in decimal code? does this work? I had a test for that but it seems to have run away. It gives larger than 256 bit values because the implementation is non-compact (and also not two's complement, so increment away from zero won't have any possibility to work anyway). http://gerrit.cloudera.org:8080/#/c/6132/4/fe/src/main/java/org/apache/impala/analysis/TypesUtil.java File fe/src/main/java/org/apache/impala/analysis/TypesUtil.java: Line 266: // } > please remove this from this diff. it should go in IMPALA-4940 change. (als Done -- To view, visit http://gerrit.cloudera.org:8080/6132 To unsubscribe, visit http://gerrit.cloudera.org:8080/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ie6bfcbe37555b74598d409c6f84f06b0ae5c4312 Gerrit-PatchSet: 4 Gerrit-Project: Impala-ASF Gerrit-Branch: master Gerrit-Owner: Zach Amsden Gerrit-Reviewer: Dan Hecht Gerrit-Reviewer: Michael Ho Gerrit-Reviewer: Zach Amsden Gerrit-HasComments: Yes