本文整理汇总了Scala中org.apache.hadoop.hive.ql.exec.UDF类的典型用法代码示例。如果您正苦于以下问题:Scala UDF类的具体用法?Scala UDF怎么用?Scala UDF使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UDF类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: lurlEncode
//设置package包名称以及导入依赖的类
package com.levent.hive.udfs
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDF
import java.net.URLEncoder
@Description(
name = "lurlEncode",
value = "_FUNC_(string) URLEncode - encodes a string into application/x-www-form-urlencoded type (UTF-8)",
extended = "SELECT lurlEncode(url) FROM test LIMIT 1;")
class lurlEncode extends UDF {
def evaluate(url: String ): String= {
if (url == null )
return null
val encodedURL= java.net.URLEncoder.encode(url, "UTF-8");
return (encodedURL)
}
}
示例2: liLIKE
//设置package包名称以及导入依赖的类
package com.levent.hive.udfs
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDF
import java.text.SimpleDateFormat
import org.joda.time.DateTime
import org.joda.time.Days
@Description(
name = "liLIKE",
value = "_FUNC_(string1,string2) in-case sensitive like between two strings returns boolean TRUE/FALSE",
extended = "SELECT liLIKE(string1,string2) FROM test LIMIT 1;")
class liLIKE extends UDF {
def evaluate(s1: String, s2: String): Boolean = {
if (s1 == null || s2 == null )
return false
return (s1.toUpperCase == s2.toUpperCase)
}
}
示例3: lcrc32
//设置package包名称以及导入依赖的类
package com.levent.hive.udfs
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDF
import java.util.zip.CRC32
@Description(
name = "lcrc32",
value = "_FUNC_(string) takes a string and returns crc32(long) value",
extended = "SELECT lcrc32('any string') FROM test LIMIT 1;")
class lcrc32 extends UDF {
def evaluate(myString: String): Long= {
if ( myString != null) {
val crc=new CRC32
crc.update(myString.getBytes())
return crc.getValue
}
return 0;
}
}
示例4: lurlDecode
//设置package包名称以及导入依赖的类
package com.levent.hive.udfs
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDF
import java.net.URLDecoder
@Description(
name = "lurlDecode",
value = "_FUNC_(string) URLDecode - decodes application/x-www-form-urlencoded type into string (UTF-8)",
extended = "SELECT lurlDecode(string) FROM test LIMIT 1;")
class lurlDecode extends UDF {
def evaluate(url: String ): String= {
if (url == null )
return null
val decodedURL= java.net.URLDecoder.decode(url, "UTF-8");
return (decodedURL)
}
}