org.apache.hadoop.hive.ql.udf.generic
Class GenericUDF
java.lang.Object
org.apache.hadoop.hive.ql.udf.generic.GenericUDF
- Direct Known Subclasses:
- AbstractGenericUDFEWAHBitmapBop, GenericUDFArray, GenericUDFArrayContains, GenericUDFAssertTrue, GenericUDFBaseCompare, GenericUDFBridge, GenericUDFCase, GenericUDFCoalesce, GenericUDFConcatWS, GenericUDFElt, GenericUDFEWAHBitmapEmpty, GenericUDFField, GenericUDFFromUtcTimestamp, GenericUDFHash, GenericUDFIf, GenericUDFIn, GenericUDFIndex, GenericUDFInFile, GenericUDFInstr, GenericUDFLocate, GenericUDFMap, GenericUDFMapKeys, GenericUDFMapValues, GenericUDFNamedStruct, GenericUDFOPAnd, GenericUDFOPNot, GenericUDFOPNotNull, GenericUDFOPNull, GenericUDFOPOr, GenericUDFReflect, GenericUDFSentences, GenericUDFSize, GenericUDFSplit, GenericUDFStringToMap, GenericUDFStruct, GenericUDFTestGetJavaBoolean, GenericUDFTestGetJavaString, GenericUDFTestTranslate, GenericUDFTimestamp, GenericUDFToBinary, GenericUDFUnion, GenericUDFWhen, GenericUDFXPath
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.
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.
initializeAndFoldConstants
public ObjectInspector initializeAndFoldConstants(ObjectInspector[] arguments)
throws UDFArgumentException
- Initialize this GenericUDF. Additionally, if the arguments are constant
and the function is eligible to be folded, then the constant value
returned by this UDF will be computed and stored in the
ConstantObjectInspector returned. Otherwise, the function behaves exactly
like initialize().
- Throws:
UDFArgumentException
getRequiredJars
public String[] getRequiredJars()
- The following two functions can be overridden to automatically include
additional resources required by this UDF. The return types should be
arrays of paths.
getRequiredFiles
public String[] getRequiredFiles()
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 © 2011 The Apache Software Foundation