> and so on (arbitrary levels of nesting). 4. It
can do short-circuit evaluations using DeferedObject.
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.
configure
public void configure(MapredContext context)
- Additionally setup GenericUDF with MapredContext before initializing.
This is only called in runtime of MapRedTask.
- Parameters:
context
- context
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.
close
public void close()
throws IOException
- Close GenericUDF.
This is only called in runtime of MapRedTask.
- Specified by:
close
in interface Closeable
- Throws:
IOException
flip
public GenericUDF flip()
- Some functions are affected by appearing order of arguments (comparisons, for example)
getUdfName
public String getUdfName()
copyToNewInstance
public void copyToNewInstance(Object newInstance)
throws UDFArgumentException
- Some information may be set during initialize() which needs to be saved when the UDF is copied.
This will be called by FunctionRegistry.cloneGenericUDF()
- Throws:
UDFArgumentException
Copyright © 2014 The Apache Software Foundation. All rights reserved.