[ 
https://issues.apache.org/jira/browse/HIVEMALL-253?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16837109#comment-16837109
 ] 

ASF GitHub Bot commented on HIVEMALL-253:
-----------------------------------------

myui commented on pull request #192: [HIVEMALL-253]UDF map_roulette() created
URL: https://github.com/apache/incubator-hivemall/pull/192#discussion_r282198054
 
 

 ##########
 File path: core/src/main/java/hivemall/tools/map/MapRouletteUDF.java
 ##########
 @@ -0,0 +1,192 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.map;
+
+import hivemall.utils.hadoop.HiveUtils;
+import org.apache.hadoop.hive.ql.exec.*;
+import org.apache.hadoop.hive.ql.metadata.HiveException;
+import org.apache.hadoop.hive.ql.udf.UDFType;
+import org.apache.hadoop.hive.ql.udf.generic.GenericUDF;
+import org.apache.hadoop.hive.serde2.objectinspector.MapObjectInspector;
+import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
+import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector;
+import 
org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils;
+import java.util.*;
+import static hivemall.HivemallConstants.*;
+
+/**
+ * The map_roulette() can be use to do roulette, according to each map.entry 
's weight.
+ * 
+ * @author Wang, Yizheng
+ */
+@Description(name = "map_roulette", value = "_FUNC_(Map<K, number> map)"
+        + " - Returns the key K which determine to its weight , the bigger 
weight is ,the more probability K will return. "
+        + "Number is a probability value or a positive weight")
+@UDFType(deterministic = false) // it is false because it return value base on 
probability
 
 Review comment:
   `@UDFType(deterministic = false, stateful = false)`
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> UDF map_roulette() created
> --------------------------
>
>                 Key: HIVEMALL-253
>                 URL: https://issues.apache.org/jira/browse/HIVEMALL-253
>             Project: Hivemall
>          Issue Type: New Feature
>    Affects Versions: 0.6.0
>            Reporter: Aaron Wong
>            Assignee: Makoto Yui
>            Priority: Major
>
> In data processing process, we usually encounter the problem that we have 
> some selection and their probably(or weight), we should select one of them 
> according to their probably(or weight).
> UDF map_roulette() is a implement of roulette. It can select a Key from a map 
> according to key's weight  value.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to