Return-Path: X-Original-To: apmail-phoenix-dev-archive@minotaur.apache.org Delivered-To: apmail-phoenix-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 673B71888F for ; Fri, 7 Aug 2015 18:40:48 +0000 (UTC) Received: (qmail 73155 invoked by uid 500); 7 Aug 2015 18:40:48 -0000 Delivered-To: apmail-phoenix-dev-archive@phoenix.apache.org Received: (qmail 73095 invoked by uid 500); 7 Aug 2015 18:40:48 -0000 Mailing-List: contact dev-help@phoenix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@phoenix.apache.org Delivered-To: mailing list dev@phoenix.apache.org Received: (qmail 73084 invoked by uid 99); 7 Aug 2015 18:40:48 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Aug 2015 18:40:48 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 9EA5219E555 for ; Fri, 7 Aug 2015 18:40:47 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.77 X-Spam-Level: * X-Spam-Status: No, score=1.77 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, T_RP_MATCHES_RCVD=-0.01] autolearn=disabled Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id hv2iZgw5NRav for ; Fri, 7 Aug 2015 18:40:46 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with SMTP id 9A0B120F6D for ; Fri, 7 Aug 2015 18:40:46 +0000 (UTC) Received: (qmail 72971 invoked by uid 99); 7 Aug 2015 18:40:46 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Aug 2015 18:40:46 +0000 Date: Fri, 7 Aug 2015 18:40:46 +0000 (UTC) From: "James Taylor (JIRA)" To: dev@phoenix.incubator.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (PHOENIX-2171) DOUBLE and FLOAT DESC are stored as ASC MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/PHOENIX-2171?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] James Taylor updated PHOENIX-2171: ---------------------------------- Attachment: PHOENIX-2171.patch [~samarthjain] - please review this patch. Good call on writing more tests for PHOENIX-2137, as it turned up this nasty bug. The fix is pretty straight forward, but how to fix data that's already been written incorrectly is another story. Maybe no one has DOUBLE DESC row keys and we should just get a patch out quickly and release note it. > DOUBLE and FLOAT DESC are stored as ASC > --------------------------------------- > > Key: PHOENIX-2171 > URL: https://issues.apache.org/jira/browse/PHOENIX-2171 > Project: Phoenix > Issue Type: Bug > Reporter: James Taylor > Priority: Critical > Attachments: PHOENIX-2171.patch > > > Our PDouble.getCodec().decodeDouble() and PFloat.getCodec().decodeFloat() methods are updating the byte array in-place when the data is DESC which is a big no-no as it essentially corrupts data. The end effect is that data which is attempted to be stored as DESC is stored ASC instead, with the data appearing as being corruprt. Not sure if this is always the case for ingest paths, but a common UPSERT VALUES is impacted: > {code} > 0: jdbc:phoenix:localhost> create table dd (k double primary key desc); > No rows affected (1.356 seconds) > 0: jdbc:phoenix:localhost> upsert into dd values (1.0); > 1 row affected (0.054 seconds) > 0: jdbc:phoenix:localhost> upsert into dd values (2.0); > 1 row affected (0.005 seconds) > 0: jdbc:phoenix:localhost> select * from dd; > +------------------------------------------+ > | K | > +------------------------------------------+ > | -1.0000000000000004 | > | -2.000000000000001 | > +------------------------------------------+ > 2 rows selected (0.038 seconds) > {code} > Not sure how to fix this in terms of data that has already been written. One potential solution is to switch the column to be ASC instead of DESC (since that's how it is actually stored): > {code} > put 'SYSTEM.CATALOG', "\x00\x00DD\x00K", '0:SORT_ORDER', "\x80\x00\x00\x00" > {code} > And now the data is interpreted correctly: > {code} > 0: jdbc:phoenix:localhost> select * from dd; > +------------------------------------------+ > | K | > +------------------------------------------+ > | 1.0 | > | 2.0 | > +------------------------------------------+ > 2 rows selected (6.157 seconds) > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)