change to select_k_best


Project: http://git-wip-us.apache.org/repos/asf/incubator-hivemall/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-hivemall/commit/89c81aac
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hivemall/tree/89c81aac
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hivemall/diff/89c81aac

Branch: refs/heads/JIRA-22/pr-385
Commit: 89c81aacf5b13f6e125723cb5c703333574c10ae
Parents: be1ea37
Author: amaya <g...@sapphire.in.net>
Authored: Wed Sep 21 10:56:59 2016 +0900
Committer: amaya <g...@sapphire.in.net>
Committed: Wed Sep 21 13:35:16 2016 +0900

----------------------------------------------------------------------
 .../tools/array/ArrayTopKIndicesUDF.java        | 115 ---------------
 .../hivemall/tools/array/SelectKBestUDF.java    | 143 +++++++++++++++++++
 .../tools/array/SubarrayByIndicesUDF.java       | 111 --------------
 resources/ddl/define-all-as-permanent.hive      |   9 +-
 resources/ddl/define-all.hive                   |   9 +-
 resources/ddl/define-all.spark                  |   7 +-
 resources/ddl/define-udfs.td.hql                |   3 +-
 7 files changed, 152 insertions(+), 245 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/89c81aac/core/src/main/java/hivemall/tools/array/ArrayTopKIndicesUDF.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/hivemall/tools/array/ArrayTopKIndicesUDF.java 
b/core/src/main/java/hivemall/tools/array/ArrayTopKIndicesUDF.java
deleted file mode 100644
index f895f9b..0000000
--- a/core/src/main/java/hivemall/tools/array/ArrayTopKIndicesUDF.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Hivemall: Hive scalable Machine Learning Library
- *
- * Copyright (C) 2016 Makoto YUI
- * Copyright (C) 2013-2015 National Institute of Advanced Industrial Science 
and Technology (AIST)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package hivemall.tools.array;
-
-import hivemall.utils.hadoop.HiveUtils;
-import hivemall.utils.lang.Preconditions;
-import org.apache.hadoop.hive.ql.exec.Description;
-import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
-import org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException;
-import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException;
-import org.apache.hadoop.hive.ql.metadata.HiveException;
-import org.apache.hadoop.hive.ql.udf.generic.GenericUDF;
-import org.apache.hadoop.hive.serde2.objectinspector.ListObjectInspector;
-import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
-import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorFactory;
-import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector;
-import 
org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory;
-import 
org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils;
-import org.apache.hadoop.io.IntWritable;
-
-import java.util.AbstractMap;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Map;
-
-@Description(
-        name = "array_top_k_indices",
-        value = "_FUNC_(array<number> array, const int k) - Returns indices 
array of top-k as array<int>")
-public class ArrayTopKIndicesUDF extends GenericUDF {
-    private ListObjectInspector arrayOI;
-    private PrimitiveObjectInspector elementOI;
-    private PrimitiveObjectInspector kOI;
-
-    @Override
-    public ObjectInspector initialize(ObjectInspector[] OIs) throws 
UDFArgumentException {
-        if (OIs.length != 2) {
-            throw new UDFArgumentLengthException("Specify two or three 
arguments.");
-        }
-
-        if (!HiveUtils.isNumberListOI(OIs[0])) {
-            throw new UDFArgumentTypeException(0,
-                "Only array<number> type argument is acceptable but " + 
OIs[0].getTypeName()
-                        + " was passed as `array`");
-        }
-        if (!HiveUtils.isIntegerOI(OIs[1])) {
-            throw new UDFArgumentTypeException(1, "Only int type argument is 
acceptable but "
-                    + OIs[1].getTypeName() + " was passed as `k`");
-        }
-
-        arrayOI = HiveUtils.asListOI(OIs[0]);
-        elementOI = 
HiveUtils.asDoubleCompatibleOI(arrayOI.getListElementObjectInspector());
-        kOI = HiveUtils.asIntegerOI(OIs[1]);
-
-        return 
ObjectInspectorFactory.getStandardListObjectInspector(PrimitiveObjectInspectorFactory.writableIntObjectInspector);
-    }
-
-    @Override
-    public Object evaluate(GenericUDF.DeferredObject[] dObj) throws 
HiveException {
-        final double[] array = HiveUtils.asDoubleArray(dObj[0].get(), arrayOI, 
elementOI);
-        final int k = PrimitiveObjectInspectorUtils.getInt(dObj[1].get(), kOI);
-
-        Preconditions.checkNotNull(array);
-        Preconditions.checkArgument(array.length >= k);
-
-        List<Map.Entry<Integer, Double>> list = new 
ArrayList<Map.Entry<Integer, Double>>();
-        for (int i = 0; i < array.length; i++) {
-            list.add(new AbstractMap.SimpleEntry<Integer, Double>(i, 
array[i]));
-        }
-        list.sort(new Comparator<Map.Entry<Integer, Double>>() {
-            @Override
-            public int compare(Map.Entry<Integer, Double> o1, 
Map.Entry<Integer, Double> o2) {
-                return o1.getValue() > o2.getValue() ? -1 : 1;
-            }
-        });
-
-        List<IntWritable> result = new ArrayList<IntWritable>();
-        for (int i = 0; i < k; i++) {
-            result.add(new IntWritable(list.get(i).getKey()));
-        }
-        return result;
-    }
-
-    @Override
-    public String getDisplayString(String[] children) {
-        StringBuilder sb = new StringBuilder();
-        sb.append("array_top_k_indices");
-        sb.append("(");
-        if (children.length > 0) {
-            sb.append(children[0]);
-            for (int i = 1; i < children.length; i++) {
-                sb.append(", ");
-                sb.append(children[i]);
-            }
-        }
-        sb.append(")");
-        return sb.toString();
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/89c81aac/core/src/main/java/hivemall/tools/array/SelectKBestUDF.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/hivemall/tools/array/SelectKBestUDF.java 
b/core/src/main/java/hivemall/tools/array/SelectKBestUDF.java
new file mode 100644
index 0000000..bdab5bb
--- /dev/null
+++ b/core/src/main/java/hivemall/tools/array/SelectKBestUDF.java
@@ -0,0 +1,143 @@
+/*
+ * Hivemall: Hive scalable Machine Learning Library
+ *
+ * Copyright (C) 2016 Makoto YUI
+ * Copyright (C) 2013-2015 National Institute of Advanced Industrial Science 
and Technology (AIST)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package hivemall.tools.array;
+
+import hivemall.utils.hadoop.HiveUtils;
+import hivemall.utils.lang.Preconditions;
+import org.apache.hadoop.hive.ql.exec.Description;
+import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
+import org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException;
+import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException;
+import org.apache.hadoop.hive.ql.metadata.HiveException;
+import org.apache.hadoop.hive.ql.udf.generic.GenericUDF;
+import org.apache.hadoop.hive.serde2.io.DoubleWritable;
+import org.apache.hadoop.hive.serde2.objectinspector.ListObjectInspector;
+import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
+import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorFactory;
+import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector;
+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.PrimitiveObjectInspectorFactory;
+import 
org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils;
+
+import java.util.AbstractMap;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Description(name = "select_k_best",
+        value = "_FUNC_(array<number> array, const array<number> 
importance_list, const int k)"
+                + " - Returns selected top-k elements as array<double>")
+public class SelectKBestUDF extends GenericUDF {
+    private ListObjectInspector featuresOI;
+    private PrimitiveObjectInspector featureOI;
+    private ListObjectInspector importanceListOI;
+    private PrimitiveObjectInspector importanceOI;
+    private PrimitiveObjectInspector kOI;
+
+    private int[] topKIndices;
+
+    @Override
+    public ObjectInspector initialize(ObjectInspector[] OIs) throws 
UDFArgumentException {
+        if (OIs.length != 3) {
+            throw new UDFArgumentLengthException("Specify three arguments.");
+        }
+
+        if (!HiveUtils.isNumberListOI(OIs[0])) {
+            throw new UDFArgumentTypeException(0,
+                "Only array<number> type argument is acceptable but " + 
OIs[0].getTypeName()
+                        + " was passed as `features`");
+        }
+        if (!HiveUtils.isNumberListOI(OIs[1])) {
+            throw new UDFArgumentTypeException(1,
+                "Only array<number> type argument is acceptable but " + 
OIs[1].getTypeName()
+                        + " was passed as `importance_list`");
+        }
+        if (!HiveUtils.isIntegerOI(OIs[2])) {
+            throw new UDFArgumentTypeException(2, "Only int type argument is 
acceptable but "
+                    + OIs[2].getTypeName() + " was passed as `k`");
+        }
+
+        featuresOI = HiveUtils.asListOI(OIs[0]);
+        featureOI = 
HiveUtils.asDoubleCompatibleOI(featuresOI.getListElementObjectInspector());
+        importanceListOI = HiveUtils.asListOI(OIs[1]);
+        importanceOI = 
HiveUtils.asDoubleCompatibleOI(importanceListOI.getListElementObjectInspector());
+        kOI = HiveUtils.asIntegerOI(OIs[2]);
+
+        return 
ObjectInspectorFactory.getStandardListObjectInspector(PrimitiveObjectInspectorFactory.writableDoubleObjectInspector);
+    }
+
+    @Override
+    public Object evaluate(GenericUDF.DeferredObject[] dObj) throws 
HiveException {
+        final double[] features = HiveUtils.asDoubleArray(dObj[0].get(), 
featuresOI, featureOI);
+        final double[] importanceList = HiveUtils.asDoubleArray(dObj[1].get(), 
importanceListOI,
+            importanceOI);
+        final int k = PrimitiveObjectInspectorUtils.getInt(dObj[2].get(), kOI);
+
+        Preconditions.checkNotNull(features);
+        Preconditions.checkNotNull(importanceList);
+        Preconditions.checkArgument(features.length == importanceList.length);
+        Preconditions.checkArgument(features.length >= k);
+
+        if (topKIndices == null) {
+            final List<Map.Entry<Integer, Double>> list = new 
ArrayList<Map.Entry<Integer, Double>>();
+            for (int i = 0; i < importanceList.length; i++) {
+                list.add(new AbstractMap.SimpleEntry<Integer, Double>(i, 
importanceList[i]));
+            }
+            Collections.sort(list, new Comparator<Map.Entry<Integer, 
Double>>() {
+                @Override
+                public int compare(Map.Entry<Integer, Double> o1, 
Map.Entry<Integer, Double> o2) {
+                    return o1.getValue() > o2.getValue() ? -1 : 1;
+                }
+            });
+
+            topKIndices = new int[k];
+            for (int i = 0; i < k; i++) {
+                topKIndices[i] = list.get(i).getKey();
+            }
+        }
+
+        final List<DoubleWritable> result = new ArrayList<DoubleWritable>();
+        for (int idx : topKIndices) {
+            result.add(new DoubleWritable(features[idx]));
+        }
+        return result;
+    }
+
+    @Override
+    public String getDisplayString(String[] children) {
+        final StringBuilder sb = new StringBuilder();
+        sb.append("select_k_best");
+        sb.append("(");
+        if (children.length > 0) {
+            sb.append(children[0]);
+            for (int i = 1; i < children.length; i++) {
+                sb.append(", ");
+                sb.append(children[i]);
+            }
+        }
+        sb.append(")");
+        return sb.toString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/89c81aac/core/src/main/java/hivemall/tools/array/SubarrayByIndicesUDF.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/hivemall/tools/array/SubarrayByIndicesUDF.java 
b/core/src/main/java/hivemall/tools/array/SubarrayByIndicesUDF.java
deleted file mode 100644
index 07e158a..0000000
--- a/core/src/main/java/hivemall/tools/array/SubarrayByIndicesUDF.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Hivemall: Hive scalable Machine Learning Library
- *
- * Copyright (C) 2016 Makoto YUI
- * Copyright (C) 2013-2015 National Institute of Advanced Industrial Science 
and Technology (AIST)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package hivemall.tools.array;
-
-import hivemall.utils.hadoop.HiveUtils;
-import hivemall.utils.lang.Preconditions;
-import org.apache.hadoop.hive.ql.exec.Description;
-import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
-import org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException;
-import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException;
-import org.apache.hadoop.hive.ql.metadata.HiveException;
-import org.apache.hadoop.hive.ql.udf.generic.GenericUDF;
-import org.apache.hadoop.hive.serde2.io.DoubleWritable;
-import org.apache.hadoop.hive.serde2.objectinspector.ListObjectInspector;
-import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
-import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorFactory;
-import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector;
-import 
org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory;
-import 
org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils;
-
-import java.util.ArrayList;
-import java.util.List;
-
-@Description(name = "subarray_by_indices",
-        value = "_FUNC_(array<number> input, array<int> indices)"
-                + " - Returns subarray selected by given indices as 
array<number>")
-public class SubarrayByIndicesUDF extends GenericUDF {
-    private ListObjectInspector inputOI;
-    private PrimitiveObjectInspector elementOI;
-    private ListObjectInspector indicesOI;
-    private PrimitiveObjectInspector indexOI;
-
-    @Override
-    public ObjectInspector initialize(ObjectInspector[] OIs) throws 
UDFArgumentException {
-        if (OIs.length != 2) {
-            throw new UDFArgumentLengthException("Specify two arguments.");
-        }
-
-        if (!HiveUtils.isListOI(OIs[0])) {
-            throw new UDFArgumentTypeException(0,
-                "Only array<number> type argument is acceptable but " + 
OIs[0].getTypeName()
-                        + " was passed as `input`");
-        }
-        if (!HiveUtils.isListOI(OIs[1])
-                || !HiveUtils.isIntegerOI(((ListObjectInspector) 
OIs[1]).getListElementObjectInspector())) {
-            throw new UDFArgumentTypeException(0,
-                "Only array<int> type argument is acceptable but " + 
OIs[0].getTypeName()
-                        + " was passed as `indices`");
-        }
-
-        inputOI = HiveUtils.asListOI(OIs[0]);
-        elementOI = 
HiveUtils.asDoubleCompatibleOI(inputOI.getListElementObjectInspector());
-        indicesOI = HiveUtils.asListOI(OIs[1]);
-        indexOI = 
HiveUtils.asIntegerOI(indicesOI.getListElementObjectInspector());
-
-        return 
ObjectInspectorFactory.getStandardListObjectInspector(PrimitiveObjectInspectorFactory.writableDoubleObjectInspector);
-    }
-
-    @Override
-    public Object evaluate(GenericUDF.DeferredObject[] dObj) throws 
HiveException {
-        final double[] input = HiveUtils.asDoubleArray(dObj[0].get(), inputOI, 
elementOI);
-        final List indices = indicesOI.getList(dObj[1].get());
-
-        Preconditions.checkNotNull(input);
-        Preconditions.checkNotNull(indices);
-
-        List<DoubleWritable> result = new ArrayList<DoubleWritable>();
-        for (Object indexObj : indices) {
-            int index = PrimitiveObjectInspectorUtils.getInt(indexObj, 
indexOI);
-            if (index > input.length - 1) {
-                throw new ArrayIndexOutOfBoundsException(index);
-            }
-
-            result.add(new DoubleWritable(input[index]));
-        }
-
-        return result;
-    }
-
-    @Override
-    public String getDisplayString(String[] children) {
-        StringBuilder sb = new StringBuilder();
-        sb.append("subarray_by_indices");
-        sb.append("(");
-        if (children.length > 0) {
-            sb.append(children[0]);
-            for (int i = 1; i < children.length; i++) {
-                sb.append(", ");
-                sb.append(children[i]);
-            }
-        }
-        sb.append(")");
-        return sb.toString();
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/89c81aac/resources/ddl/define-all-as-permanent.hive
----------------------------------------------------------------------
diff --git a/resources/ddl/define-all-as-permanent.hive 
b/resources/ddl/define-all-as-permanent.hive
index 52b73a0..adf6a14 100644
--- a/resources/ddl/define-all-as-permanent.hive
+++ b/resources/ddl/define-all-as-permanent.hive
@@ -371,9 +371,6 @@ CREATE FUNCTION subarray_endwith as 
'hivemall.tools.array.SubarrayEndWithUDF' US
 DROP FUNCTION IF EXISTS subarray_startwith;
 CREATE FUNCTION subarray_startwith as 
'hivemall.tools.array.SubarrayStartWithUDF' USING JAR '${hivemall_jar}';
 
-DROP FUNCTION IF EXISTS subarray_by_indices;
-CREATE FUNCTION subarray_by_indices as 
'hivemall.tools.array.SubarrayByIndicesUDF' USING JAR '${hivemall_jar}';
-
 DROP FUNCTION IF EXISTS array_concat;
 CREATE FUNCTION array_concat as 'hivemall.tools.array.ArrayConcatUDF' USING 
JAR '${hivemall_jar}';
 
@@ -390,15 +387,15 @@ CREATE FUNCTION array_avg as 
'hivemall.tools.array.ArrayAvgGenericUDAF' USING JA
 DROP FUNCTION IF EXISTS array_sum;
 CREATE FUNCTION array_sum as 'hivemall.tools.array.ArraySumUDAF' USING JAR 
'${hivemall_jar}';
 
-DROP FUNCTION array_top_k_indices;
-CREATE FUNCTION array_top_k_indices as 
'hivemall.tools.array.ArrayTopKIndicesUDF' USING JAR '${hivemall_jar}';
-
 DROP FUNCTION IF EXISTS to_string_array;
 CREATE FUNCTION to_string_array as 'hivemall.tools.array.ToStringArrayUDF' 
USING JAR '${hivemall_jar}';
 
 DROP FUNCTION IF EXISTS array_intersect;
 CREATE FUNCTION array_intersect as 'hivemall.tools.array.ArrayIntersectUDF' 
USING JAR '${hivemall_jar}';
 
+DROP FUNCTION IF EXISTS select_k_best;
+CREATE FUNCTION select_k_best as 'hivemall.tools.array.SelectKBestUDF' USING 
JAR '${hivemall_jar}';
+
 -----------------------------
 -- bit operation functions --
 -----------------------------

http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/89c81aac/resources/ddl/define-all.hive
----------------------------------------------------------------------
diff --git a/resources/ddl/define-all.hive b/resources/ddl/define-all.hive
index a70ae0f..1586d2e 100644
--- a/resources/ddl/define-all.hive
+++ b/resources/ddl/define-all.hive
@@ -367,9 +367,6 @@ create temporary function subarray_endwith as 
'hivemall.tools.array.SubarrayEndW
 drop temporary function subarray_startwith;
 create temporary function subarray_startwith as 
'hivemall.tools.array.SubarrayStartWithUDF';
 
-drop temporary function subarray_by_indices;
-create temporary function subarray_by_indices as 
'hivemall.tools.array.SubarrayByIndicesUDF';
-
 drop temporary function array_concat;
 create temporary function array_concat as 
'hivemall.tools.array.ArrayConcatUDF';
 
@@ -386,15 +383,15 @@ create temporary function array_avg as 
'hivemall.tools.array.ArrayAvgGenericUDAF
 drop temporary function array_sum;
 create temporary function array_sum as 'hivemall.tools.array.ArraySumUDAF';
 
-drop temporary function array_top_k_indices;
-create temporary function array_top_k_indices as 
'hivemall.tools.array.ArrayTopKIndicesUDF';
-
 drop temporary function to_string_array;
 create temporary function to_string_array as 
'hivemall.tools.array.ToStringArrayUDF';
 
 drop temporary function array_intersect;
 create temporary function array_intersect as 
'hivemall.tools.array.ArrayIntersectUDF';
 
+drop temporary function select_k_best;
+create temporary function select_k_best as 
'hivemall.tools.array.SelectKBestUDF';
+
 -----------------------------
 -- bit operation functions --
 -----------------------------

http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/89c81aac/resources/ddl/define-all.spark
----------------------------------------------------------------------
diff --git a/resources/ddl/define-all.spark b/resources/ddl/define-all.spark
index e009511..50d560b 100644
--- a/resources/ddl/define-all.spark
+++ b/resources/ddl/define-all.spark
@@ -316,9 +316,6 @@ sqlContext.sql("CREATE TEMPORARY FUNCTION subarray_endwith 
AS 'hivemall.tools.ar
 sqlContext.sql("DROP TEMPORARY FUNCTION IF EXISTS subarray_startwith")
 sqlContext.sql("CREATE TEMPORARY FUNCTION subarray_startwith AS 
'hivemall.tools.array.SubarrayStartWithUDF'")
 
-sqlContext.sql("DROP TEMPORARY FUNCTION IF EXISTS subarray_by_indices")
-sqlContext.sql("CREATE TEMPORARY FUNCTION subarray_by_indices AS 
'hivemall.tools.array.SubarrayByIndicesUDF'")
-
 sqlContext.sql("DROP TEMPORARY FUNCTION IF EXISTS collect_all")
 sqlContext.sql("CREATE TEMPORARY FUNCTION collect_all AS 
'hivemall.tools.array.CollectAllUDAF'")
 
@@ -331,8 +328,8 @@ sqlContext.sql("CREATE TEMPORARY FUNCTION subarray AS 
'hivemall.tools.array.Suba
 sqlContext.sql("DROP TEMPORARY FUNCTION IF EXISTS array_avg")
 sqlContext.sql("CREATE TEMPORARY FUNCTION array_avg AS 
'hivemall.tools.array.ArrayAvgGenericUDAF'")
 
-sqlContext.sql("DROP TEMPORARY FUNCTION IF EXISTS array_top_k_indices")
-sqlContext.sql("CREATE TEMPORARY FUNCTION array_top_k_indices AS 
'hivemall.tools.array.ArrayTopKIndicesUDF'")
+sqlContext.sql("DROP TEMPORARY FUNCTION IF EXISTS select_k_best")
+sqlContext.sql("CREATE TEMPORARY FUNCTION select_k_best AS 
'hivemall.tools.array.SelectKBestUDF'")
 
 /**
  * compression functions

http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/89c81aac/resources/ddl/define-udfs.td.hql
----------------------------------------------------------------------
diff --git a/resources/ddl/define-udfs.td.hql b/resources/ddl/define-udfs.td.hql
index 92e4003..601eead 100644
--- a/resources/ddl/define-udfs.td.hql
+++ b/resources/ddl/define-udfs.td.hql
@@ -95,14 +95,13 @@ create temporary function array_remove as 
'hivemall.tools.array.ArrayRemoveUDF';
 create temporary function sort_and_uniq_array as 
'hivemall.tools.array.SortAndUniqArrayUDF';
 create temporary function subarray_endwith as 
'hivemall.tools.array.SubarrayEndWithUDF';
 create temporary function subarray_startwith as 
'hivemall.tools.array.SubarrayStartWithUDF';
-create temporary function subarray_by_indices as 
'hivemall.tools.array.SubarrayByIndicesUDF';
 create temporary function array_concat as 
'hivemall.tools.array.ArrayConcatUDF';
 create temporary function subarray as 'hivemall.tools.array.SubarrayUDF';
 create temporary function array_avg as 
'hivemall.tools.array.ArrayAvgGenericUDAF';
 create temporary function array_sum as 'hivemall.tools.array.ArraySumUDAF';
-create temporary function array_top_k_indices as 
'hivemall.tools.array.ArrayTopKIndicesUDF';
 create temporary function to_string_array as 
'hivemall.tools.array.ToStringArrayUDF';
 create temporary function array_intersect as 
'hivemall.tools.array.ArrayIntersectUDF';
+create temporary function select_k_best as 
'hivemall.tools.array.SelectKBestUDF';
 create temporary function bits_collect as 
'hivemall.tools.bits.BitsCollectUDAF';
 create temporary function to_bits as 'hivemall.tools.bits.ToBitsUDF';
 create temporary function unbits as 'hivemall.tools.bits.UnBitsUDF';

Reply via email to