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 016C5200CB9 for ; Sun, 2 Jul 2017 22:29:04 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 009B2160BEE; Sun, 2 Jul 2017 20:29:04 +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 47747160BDD for ; Sun, 2 Jul 2017 22:29:03 +0200 (CEST) Received: (qmail 67111 invoked by uid 500); 2 Jul 2017 20:29:02 -0000 Mailing-List: contact issues-help@carbondata.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@carbondata.apache.org Delivered-To: mailing list issues@carbondata.apache.org Received: (qmail 67102 invoked by uid 99); 2 Jul 2017 20:29:02 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 02 Jul 2017 20:29:02 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 4B636E037F; Sun, 2 Jul 2017 20:29:02 +0000 (UTC) From: sounakr To: issues@carbondata.apache.org Reply-To: issues@carbondata.apache.org References: In-Reply-To: Subject: [GitHub] carbondata pull request #1079: [WIP]Measure Filter implementation Content-Type: text/plain Message-Id: <20170702202902.4B636E037F@git1-us-west.apache.org> Date: Sun, 2 Jul 2017 20:29:02 +0000 (UTC) archived-at: Sun, 02 Jul 2017 20:29:04 -0000 Github user sounakr commented on a diff in the pull request: https://github.com/apache/carbondata/pull/1079#discussion_r125191772 --- Diff: core/src/main/java/org/apache/carbondata/core/util/DataTypeUtil.java --- @@ -113,6 +115,143 @@ public static Object getMeasureValueBasedOnDataType(String msrValue, DataType da } } + public static Object getMeasureObjectFromDataType(byte[] data, DataType dataType) { + ByteBuffer bb = ByteBuffer.wrap(data); + switch (dataType) { + case SHORT: + case INT: + case LONG: + return bb.getLong(); + case DECIMAL: + return byteToBigDecimal(data); + default: + return bb.getDouble(); + } + } + + /** + * This method will convert a given ByteArray to its specific type + * + * @param msrValue + * @param dataType + * @param carbonMeasure + * @return + */ + // public static byte[] getMeasureByteArrayBasedOnDataType(String msrValue, DataType dataType, + // CarbonMeasure carbonMeasure) { + // switch (dataType) { + // case DECIMAL: + // BigDecimal bigDecimal = + // new BigDecimal(msrValue).setScale(carbonMeasure.getScale(), RoundingMode.HALF_UP); + // return ByteUtil.toBytes(normalizeDecimalValue(bigDecimal, carbonMeasure.getPrecision())); + // case SHORT: + // return ByteUtil.toBytes((Short.parseShort(msrValue))); + // case INT: + // return ByteUtil.toBytes(Integer.parseInt(msrValue)); + // case LONG: + // return ByteUtil.toBytes(Long.valueOf(msrValue)); + // default: + // Double parsedValue = Double.valueOf(msrValue); + // if (Double.isInfinite(parsedValue) || Double.isNaN(parsedValue)) { + // return null; + // } + // return ByteUtil.toBytes(parsedValue); + // } + // } + public static byte[] getMeasureByteArrayBasedOnDataTypes(String msrValue, DataType dataType, + CarbonMeasure carbonMeasure) { + ByteBuffer b; + switch (dataType) { + case BYTE: + case SHORT: + case INT: + case LONG: + b = ByteBuffer.allocate(8); + b.putLong(Long.valueOf(msrValue)); + b.flip(); + return b.array(); + case DOUBLE: + b = ByteBuffer.allocate(8); + b.putDouble(Double.valueOf(msrValue)); + b.flip(); + return b.array(); + case DECIMAL: + BigDecimal bigDecimal = + new BigDecimal(msrValue).setScale(carbonMeasure.getScale(), RoundingMode.HALF_UP); + return DataTypeUtil + .bigDecimalToByte(normalizeDecimalValue(bigDecimal, carbonMeasure.getPrecision())); + default: + throw new IllegalArgumentException("Invalid data type: " + dataType); + } + } + + /** + * This method will convert a given ByteArray to its specific type + * + * @param msrValue + * @param dataType + * @param carbonMeasure + * @return + */ + public static byte[] getMeasureByteArrayBasedOnDataType(ColumnPage measurePage, int index, --- End diff -- Done --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastructure@apache.org or file a JIRA ticket with INFRA. ---