org.apache.hadoop.hive.ql.udf.generic
Class GenericUDF
java.lang.Object
org.apache.hadoop.hive.ql.udf.generic.GenericUDF
- Direct Known Subclasses:
- GenericUDFCase, GenericUDFCoalesce, GenericUDFElt, GenericUDFHash, GenericUDFIf, GenericUDFIndex, GenericUDFInstr, GenericUDFLocate, GenericUDFOPNotNull, GenericUDFOPNull, GenericUDFSize, GenericUDFSplit, GenericUDFWhen
public abstract class GenericUDF
- extends Object
A Generic User-defined function (GenericUDF) for the use with Hive.
New GenericUDF classes need to inherit from this GenericUDF class.
The GenericUDF are superior to normal UDFs in the following ways:
1. It can accept arguments of complex types, and return complex types.
2. It can accept variable length of arguments.
3. It can accept an infinite number of function signature - for example,
it's easy to write a GenericUDF that accepts array,
array> and so on (arbitrary levels of nesting).
4. It can do short-circuit evaluations using DeferedObject.
Nested Class Summary |
static interface |
GenericUDF.DeferredObject
A Defered Object allows us to do lazy-evaluation
and short-circuiting. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
GenericUDF
public GenericUDF()
- The constructor
initialize
public abstract ObjectInspector initialize(ObjectInspector[] arguments)
throws UDFArgumentException
- Initialize this GenericUDF. This will be called once and only once per
GenericUDF instance.
- Parameters:
arguments
- The ObjectInspector for the arguments
- Returns:
- The ObjectInspector for the return value
- Throws:
UDFArgumentException
- Thrown when arguments have wrong types, wrong length, etc.
evaluate
public abstract Object evaluate(GenericUDF.DeferredObject[] arguments)
throws HiveException
- Evaluate the GenericUDF with the arguments.
- Parameters:
arguments
- The arguments as DeferedObject, use DeferedObject.get() to
get the actual argument Object. The Objects can be inspected
by the ObjectInspectors passed in the initialize call.
- Returns:
- The
- Throws:
HiveException
getDisplayString
public abstract String getDisplayString(String[] children)
- Get the String to be displayed in explain.
Copyright © 2009 The Apache Software Foundation