add HiveUtils.asDoubleOI
Project: http://git-wip-us.apache.org/repos/asf/incubator-hivemall/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-hivemall/commit/56adf2d4 Tree: http://git-wip-us.apache.org/repos/asf/incubator-hivemall/tree/56adf2d4 Diff: http://git-wip-us.apache.org/repos/asf/incubator-hivemall/diff/56adf2d4 Branch: refs/heads/JIRA-22/pr-385 Commit: 56adf2d4e8b2591c31b846b8980016d3dafdbacc Parents: 2dc176a Author: amaya <g...@sapphire.in.net> Authored: Fri Sep 16 15:48:33 2016 +0900 Committer: amaya <g...@sapphire.in.net> Committed: Fri Sep 16 15:48:33 2016 +0900 ---------------------------------------------------------------------- core/src/main/java/hivemall/utils/hadoop/HiveUtils.java | 9 +++++++++ 1 file changed, 9 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/56adf2d4/core/src/main/java/hivemall/utils/hadoop/HiveUtils.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/utils/hadoop/HiveUtils.java b/core/src/main/java/hivemall/utils/hadoop/HiveUtils.java index 32b60d0..7e8ea7b 100644 --- a/core/src/main/java/hivemall/utils/hadoop/HiveUtils.java +++ b/core/src/main/java/hivemall/utils/hadoop/HiveUtils.java @@ -57,6 +57,7 @@ import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorUtils; import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector; import org.apache.hadoop.hive.serde2.objectinspector.primitive.BinaryObjectInspector; import org.apache.hadoop.hive.serde2.objectinspector.primitive.BooleanObjectInspector; +import org.apache.hadoop.hive.serde2.objectinspector.primitive.DoubleObjectInspector; import org.apache.hadoop.hive.serde2.objectinspector.primitive.IntObjectInspector; import org.apache.hadoop.hive.serde2.objectinspector.primitive.LongObjectInspector; import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils; @@ -675,6 +676,14 @@ public final class HiveUtils { return (LongObjectInspector) argOI; } + public static DoubleObjectInspector asDoubleOI(@Nonnull final ObjectInspector argOI) + throws UDFArgumentException { + if (!DOUBLE_TYPE_NAME.equals(argOI.getTypeName())) { + throw new UDFArgumentException("Argument type must be DOUBLE: " + argOI.getTypeName()); + } + return (DoubleObjectInspector) argOI; + } + public static PrimitiveObjectInspector asIntCompatibleOI(@Nonnull final ObjectInspector argOI) throws UDFArgumentTypeException { if (argOI.getCategory() != Category.PRIMITIVE) {