diff options
author | Steven Phillips <sphillips@maprtech.com> | 2014-05-12 02:56:25 -0700 |
---|---|---|
committer | Aditya Kishore <aditya@maprtech.com> | 2014-05-12 18:18:43 -0700 |
commit | 63b0346761692f0a4c851e7910791c028dc3cded (patch) | |
tree | 65564280c1d9040781154731fd694e21115d172f /common | |
parent | 14c628ccd69caeea70754eafb525ca2d3d2f1401 (diff) |
DRILL-694: Implement parquet writer.
Enable "CREATE TABLE AS" with parquet as the output format.
Add decimal metadata support to parquet reader and writer.
Diffstat (limited to 'common')
-rw-r--r-- | common/src/main/java/org/apache/drill/common/types/Types.java | 4 | ||||
-rw-r--r-- | common/src/main/java/org/apache/drill/common/util/DecimalUtility.java | 11 |
2 files changed, 13 insertions, 2 deletions
diff --git a/common/src/main/java/org/apache/drill/common/types/Types.java b/common/src/main/java/org/apache/drill/common/types/Types.java index c6ac82e68..a6ec29b57 100644 --- a/common/src/main/java/org/apache/drill/common/types/Types.java +++ b/common/src/main/java/org/apache/drill/common/types/Types.java @@ -271,6 +271,10 @@ public class Types { return MajorType.newBuilder().setMode(mode).setMinorType(type).build(); } + public static MajorType withScaleAndPrecision(MinorType type, DataMode mode, int scale, int precision) { + return MajorType.newBuilder().setMinorType(type).setMode(mode).setScale(scale).setPrecision(precision).build(); + } + public static MajorType required(MinorType type){ return MajorType.newBuilder().setMode(DataMode.REQUIRED).setMinorType(type).build(); } diff --git a/common/src/main/java/org/apache/drill/common/util/DecimalUtility.java b/common/src/main/java/org/apache/drill/common/util/DecimalUtility.java index dbfd6ac96..0cacc59d3 100644 --- a/common/src/main/java/org/apache/drill/common/util/DecimalUtility.java +++ b/common/src/main/java/org/apache/drill/common/util/DecimalUtility.java @@ -17,8 +17,7 @@ */ package org.apache.drill.common.util; -import java.math.BigDecimal; -import java.math.BigInteger; +import java.math.*; import io.netty.buffer.Unpooled; @@ -26,6 +25,7 @@ import io.netty.buffer.ByteBuf; import java.math.BigDecimal; import java.math.BigInteger; +import java.util.Arrays; public class DecimalUtility { @@ -486,5 +486,12 @@ public class DecimalUtility { return 0; } + + public static BigDecimal getBigDecimalFromByteArray(byte[] bytes, int start, int length, int scale) { + byte[] value = Arrays.copyOfRange(bytes, start, start + length); + BigInteger unscaledValue = new BigInteger(value); + return new BigDecimal(unscaledValue, scale); + } + } |