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 TypeInfo getCommonClass(TypeInfo a, TypeInfo b)
          Find a common class that objects of both TypeInfo a and TypeInfo b can convert to.
static TypeInfo getCommonClassForComparison(TypeInfo a, TypeInfo b)
          Find a common class that objects of both TypeInfo a and TypeInfo b can convert to.
static FunctionInfo getFunctionInfo(String functionName)
           
static Set<String> getFunctionNames()
          Returns a set of registered function names.
static Set<String> getFunctionNames(String funcPatternStr)
          Returns a set of registered function names.
static GenericUDAFEvaluator getGenericUDAFEvaluator(String name, List<TypeInfo> argumentTypeInfos)
          Get the GenericUDAF evaluator for the name and argumentClasses.
static GenericUDAFResolver getGenericUDAFResolver(String functionName)
           
static Class<? extends GenericUDF> getGenericUDFClassForIndex()
          A shortcut to get the index GenericUDFClass.
static Method getMethodInternal(ArrayList<Method> mlist, boolean exact, List<TypeInfo> argumentsPassed)
          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<TypeInfo> argumentClasses)
          This method is shared between UDFRegistry and UDAFRegistry.
static Class<? extends UDF> getUDFClass(String functionName)
           
static FunctionInfo getUDFInfo(Class<?> fClass)
           
static Method getUDFMethod(String name, List<TypeInfo> argumentTypeInfos)
          Get the UDF method for the name and argumentClasses.
static Method getUDFMethod(String name, TypeInfo... argumentClasses)
           
static boolean implicitConvertable(TypeInfo from, TypeInfo 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 registerGenericUDAF(boolean isNative, String functionName, GenericUDAFResolver genericUDAFResolver)
           
static void registerGenericUDF(boolean isNative, String functionName, Class<? extends GenericUDF> genericUDFClass)
           
static void registerTemporaryGenericUDAF(String functionName, GenericUDAFResolver genericUDAFResolver)
           
static void registerTemporaryGenericUDF(String functionName, Class<? extends GenericUDF> genericUDFClass)
           
static void registerTemporaryUDAF(String functionName, Class<? extends UDAF> udafClass)
           
static void registerTemporaryUDF(String functionName, Class<? extends UDF> UDFClass, FunctionInfo.OperatorType opt, boolean isOperator)
           
static void registerUDAF(boolean isNative, String functionName, Class<? extends UDAF> udafClass)
           
static void registerUDF(boolean isNative, 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)
           
static void unregisterTemporaryUDF(String functionName)
           
 
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

getUDFInfo

public static FunctionInfo getUDFInfo(Class<?> fClass)

registerTemporaryUDF

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

registerUDF

public static void registerUDF(boolean isNative,
                               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)

registerTemporaryGenericUDF

public static void registerTemporaryGenericUDF(String functionName,
                                               Class<? extends GenericUDF> genericUDFClass)

registerGenericUDF

public static void registerGenericUDF(boolean isNative,
                                      String functionName,
                                      Class<? extends GenericUDF> genericUDFClass)

getFunctionInfo

public static FunctionInfo getFunctionInfo(String functionName)

getFunctionNames

public static Set<String> getFunctionNames()
Returns a set of registered function names. This is used for the CLI command "SHOW FUNCTIONS;"

Returns:
set of strings contains function names

getFunctionNames

public static Set<String> getFunctionNames(String funcPatternStr)
Returns a set of registered function names. This is used for the CLI command "SHOW FUNCTIONS 'regular expression';" Returns an empty set when the regular expression is not valid.

Parameters:
funcPatternStr - regular expression of the intersted function names
Returns:
set of strings contains function names

getUDFClass

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

getCommonClassForComparison

public static TypeInfo getCommonClassForComparison(TypeInfo a,
                                                   TypeInfo b)
Find a common class that objects of both TypeInfo a and TypeInfo b can convert to. This is used for comparing objects of type a and type b. When we are comparing string and double, we will always convert both of them to double and then compare.

Returns:
null if no common class could be found.

getCommonClass

public static TypeInfo getCommonClass(TypeInfo a,
                                      TypeInfo b)
Find a common class that objects of both TypeInfo a and TypeInfo b can convert to. This is used for places other than comparison. The common class of string and double is string.

Returns:
null if no common class could be found.

implicitConvertable

public static boolean implicitConvertable(TypeInfo from,
                                          TypeInfo 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<TypeInfo> argumentTypeInfos)
Get the UDF method for the name and argumentClasses.

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

getGenericUDAFEvaluator

public static GenericUDAFEvaluator getGenericUDAFEvaluator(String name,
                                                           List<TypeInfo> argumentTypeInfos)
                                                    throws SemanticException
Get the GenericUDAF evaluator for the name and argumentClasses.

Parameters:
name - the name of the UDAF
argumentTypeInfos -
Returns:
The UDAF evaluator
Throws:
SemanticException

getMethodInternal

public static <T> Method getMethodInternal(Class<? extends T> udfClass,
                                           String methodName,
                                           boolean exact,
                                           List<TypeInfo> 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,
                                  TypeInfo... argumentClasses)

registerTemporaryGenericUDAF

public static void registerTemporaryGenericUDAF(String functionName,
                                                GenericUDAFResolver genericUDAFResolver)

registerGenericUDAF

public static void registerGenericUDAF(boolean isNative,
                                       String functionName,
                                       GenericUDAFResolver genericUDAFResolver)

registerTemporaryUDAF

public static void registerTemporaryUDAF(String functionName,
                                         Class<? extends UDAF> udafClass)

registerUDAF

public static void registerUDAF(boolean isNative,
                                String functionName,
                                Class<? extends UDAF> udafClass)

unregisterTemporaryUDF

public static void unregisterTemporaryUDF(String functionName)
                                   throws HiveException
Throws:
HiveException

getGenericUDAFResolver

public static GenericUDAFResolver getGenericUDAFResolver(String functionName)

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<TypeInfo> argumentsPassed)
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.
argumentsPassed - The classes for the argument.
Returns:
The matching method.

getGenericUDFClassForIndex

public static Class<? extends GenericUDF> getGenericUDFClassForIndex()
A shortcut to get the index GenericUDFClass. This is used for getting elements out of array and getting values out of map.



Copyright © 2009 The Apache Software Foundation