org.apache.hadoop.hive.ql.exec
Class FunctionRegistry

java.lang.Object
  extended by org.apache.hadoop.hive.ql.exec.FunctionRegistry

public class FunctionRegistry
extends Object


Constructor Summary
FunctionRegistry()
           
 
Method Summary
static Class<?> getCommonClass(Class<?> a, Class<?> b)
          Find a common class that objects of both Class a and Class b can convert to.
static FunctionInfo getInfo(Class<?> fClass)
           
static Method getMethodInternal(ArrayList<Method> mlist, boolean exact, List<Class<?>> argumentClasses)
          Gets the closest matching method corresponding to the argument list from a list of methods.
static
<T> Method
getMethodInternal(Class<? extends T> udfClass, String methodName, boolean exact, List<Class<?>> argumentClasses)
          This method is shared between UDFRegistry and UDAFRegistry.
static Class<? extends UDAF> getUDAF(String functionName)
           
static Method getUDAFEvaluateMethod(String name, groupByDesc.Mode mode)
          Returns the evaluate method for the UDAF based on the aggregation mode.
static Class<? extends UDAFEvaluator> getUDAFEvaluator(String name, List<Class<?>> argumentClasses)
          Get the UDAF evaluator for the name and argumentClasses.
static Method getUDAFMethod(String name, Class<?>... argumentClasses)
          Returns the "aggregate" method of the UDAF.
static Method getUDAFMethod(String name, List<Class<?>> argumentClasses)
          Returns the "aggregate" method of the UDAF.
static Class<? extends UDF> getUDFClass(String functionName)
           
static Method getUDFMethod(String name, Class<?>... argumentClasses)
           
static Method getUDFMethod(String name, List<Class<?>> argumentClasses)
          Get the UDF method for the name and argumentClasses.
static boolean implicitConvertable(Class<?> from, Class<?> to)
          Returns whether it is possible to implicitly convert an object of Class from to Class to.
static Object invoke(Method m, Object thisObject, Object[] arguments)
           
static void registerUDAF(String functionName, Class<? extends UDAF> UDAFClass)
           
static void registerUDF(String functionName, Class<? extends UDF> UDFClass, FunctionInfo.OperatorType opt, boolean isOperator)
           
static void registerUDF(String functionName, Class<? extends UDF> UDFClass, FunctionInfo.OperatorType opt, boolean isOperator, String displayName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FunctionRegistry

public FunctionRegistry()
Method Detail

getInfo

public static FunctionInfo getInfo(Class<?> fClass)

registerUDF

public static void registerUDF(String functionName,
                               Class<? extends UDF> UDFClass,
                               FunctionInfo.OperatorType opt,
                               boolean isOperator)

registerUDF

public static void registerUDF(String functionName,
                               Class<? extends UDF> UDFClass,
                               FunctionInfo.OperatorType opt,
                               boolean isOperator,
                               String displayName)

getUDFClass

public static Class<? extends UDF> getUDFClass(String functionName)

getCommonClass

public static Class<?> getCommonClass(Class<?> a,
                                      Class<?> b)
Find a common class that objects of both Class a and Class b can convert to.

Returns:
null if no common class could be found.

implicitConvertable

public static boolean implicitConvertable(Class<?> from,
                                          Class<?> to)
Returns whether it is possible to implicitly convert an object of Class from to Class to.


getUDFMethod

public static Method getUDFMethod(String name,
                                  List<Class<?>> argumentClasses)
Get the UDF method for the name and argumentClasses.

Parameters:
name - the name of the UDF
argumentClasses -
Returns:
The UDF method

getUDAFEvaluator

public static Class<? extends UDAFEvaluator> getUDAFEvaluator(String name,
                                                              List<Class<?>> argumentClasses)
Get the UDAF evaluator for the name and argumentClasses.

Parameters:
name - the name of the UDAF
argumentClasses -
Returns:
The UDAF evaluator

getMethodInternal

public static <T> Method getMethodInternal(Class<? extends T> udfClass,
                                           String methodName,
                                           boolean exact,
                                           List<Class<?>> argumentClasses)
This method is shared between UDFRegistry and UDAFRegistry. methodName will be "evaluate" for UDFRegistry, and "aggregate"/"evaluate"/"evaluatePartial" for UDAFRegistry.


getUDFMethod

public static Method getUDFMethod(String name,
                                  Class<?>... argumentClasses)

registerUDAF

public static void registerUDAF(String functionName,
                                Class<? extends UDAF> UDAFClass)

getUDAF

public static Class<? extends UDAF> getUDAF(String functionName)

getUDAFMethod

public static Method getUDAFMethod(String name,
                                   List<Class<?>> argumentClasses)
Returns the "aggregate" method of the UDAF.


getUDAFEvaluateMethod

public static Method getUDAFEvaluateMethod(String name,
                                           groupByDesc.Mode mode)
Returns the evaluate method for the UDAF based on the aggregation mode. See groupByDesc.Mode for details.

Parameters:
name - name of the UDAF
mode - the mode of the aggregation
Returns:
null if no such UDAF is found

getUDAFMethod

public static Method getUDAFMethod(String name,
                                   Class<?>... argumentClasses)
Returns the "aggregate" method of the UDAF.


invoke

public static Object invoke(Method m,
                            Object thisObject,
                            Object[] arguments)
                     throws HiveException
Throws:
HiveException

getMethodInternal

public static Method getMethodInternal(ArrayList<Method> mlist,
                                       boolean exact,
                                       List<Class<?>> argumentClasses)
Gets the closest matching method corresponding to the argument list from a list of methods.

Parameters:
mlist - The list of methods to inspect.
exact - Boolean to indicate whether this is an exact match or not.
argumentClasses - The classes for the argument.
Returns:
The matching method.


Copyright © 2009 The Apache Software Foundation