public class UDF extends Object
New UDF classes need to inherit from this UDF class (or from GenericUDF
which provides more flexibility at
the cost of more complexity).
Requirements for all classes extending this UDF are:
evaluate
which will be called by Hive (the exact
way in which Hive resolves the method to call can be configured by setting a custom UDFMethodResolver
). The following are some examples:
public int evaluate();
public int evaluate(int a);
public double evaluate(int a, double b);
public String evaluate(String a, int b, Text c);
public Text evaluate(String a);
public String evaluate(List<Integer> a);
(Note that Hive Arrays are represented as
Lists
in Hive.
So an ARRAY<int>
column would be passed in as a List<Integer>
.)evaluate
should never be a void method. However it can return null
if
needed.
Writable
class.Description
,
UDFType
Modifier | Constructor and Description |
---|---|
|
UDF()
The constructor.
|
protected |
UDF(UDFMethodResolver rslv)
The constructor with user-provided
UDFMethodResolver . |
Modifier and Type | Method and Description |
---|---|
String[] |
getRequiredFiles()
This can be overridden to include files required by this UDF.
|
String[] |
getRequiredJars()
This can be overridden to include JARs required by this UDF.
|
UDFMethodResolver |
getResolver()
Get the method resolver.
|
void |
setResolver(UDFMethodResolver rslv)
Sets the resolver.
|
public UDF()
protected UDF(UDFMethodResolver rslv)
UDFMethodResolver
.public void setResolver(UDFMethodResolver rslv)
rslv
- The method resolver to use for method resolution.public UDFMethodResolver getResolver()
public String[] getRequiredJars()
null
by default.GenericUDF.getRequiredJars()
public String[] getRequiredFiles()
null
by default.GenericUDF.getRequiredFiles()
Copyright © 2017 The Apache Software Foundation. All rights reserved.