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 GenericUDF cloneGenericUDF(GenericUDF genericUDF)
          Create a copy of an existing GenericUDF.
static GenericUDTF cloneGenericUDTF(GenericUDTF genericUDTF)
          Create a copy of an existing GenericUDTF.
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 Set<String> getFunctionSynonyms(String funcName)
          Returns the set of synonyms of the supplied function.
static GenericUDAFEvaluator getGenericUDAFEvaluator(String name, List<TypeInfo> argumentTypeInfos)
          Get the GenericUDAF evaluator for the name and argumentClasses.
static GenericUDAFResolver getGenericUDAFResolver(String functionName)
           
static GenericUDF getGenericUDFForAnd()
          A shortcut to get the "and" GenericUDF.
static GenericUDF getGenericUDFForIndex()
          A shortcut to get the "index" GenericUDF.
static
<T> Method
getMethodInternal(Class<? extends T> udfClass, String methodName, boolean exact, List<TypeInfo> argumentClasses)
          This method is shared between UDFRegistry and UDAFRegistry.
static Method getMethodInternal(List<Method> mlist, boolean exact, List<TypeInfo> argumentsPassed)
          Gets the closest matching method corresponding to the argument list from a list of methods.
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 boolean isDeterministic(GenericUDF genericUDF)
          Returns whether a GenericUDF is deterministic or not.
static boolean isOpAnd(exprNodeDesc desc)
          Returns whether the exprNodeDesc is a node of "and".
static boolean isOpAndOrNot(exprNodeDesc desc)
          Returns whether the exprNodeDesc is a node of "and", "or", "not".
static boolean isOpPositive(exprNodeDesc desc)
          Returns whether the exprNodeDesc is a node of "positive".
static int matchCost(TypeInfo argumentPassed, TypeInfo argumentAccepted, boolean exact)
          Returns -1 if passed does not match accepted.
static void registerGenericUDAF(boolean isNative, String functionName, GenericUDAFResolver genericUDAFResolver)
           
static void registerGenericUDF(boolean isNative, String functionName, Class<? extends GenericUDF> genericUDFClass)
           
static void registerGenericUDTF(boolean isNative, String functionName, Class<? extends GenericUDTF> genericUDTFClass)
           
static void registerTemporaryGenericUDAF(String functionName, GenericUDAFResolver genericUDAFResolver)
           
static void registerTemporaryGenericUDF(String functionName, Class<? extends GenericUDF> genericUDFClass)
           
static void registerTemporaryGenericUDTF(String functionName, Class<? extends GenericUDTF> genericUDTFClass)
           
static void registerTemporaryUDAF(String functionName, Class<? extends UDAF> udafClass)
           
static void registerTemporaryUDF(String functionName, Class<? extends UDF> UDFClass, boolean isOperator)
           
static void registerUDAF(boolean isNative, String functionName, Class<? extends UDAF> udafClass)
           
static void registerUDF(boolean isNative, String functionName, Class<? extends UDF> UDFClass, boolean isOperator)
           
static void registerUDF(boolean isNative, String functionName, Class<? extends UDF> UDFClass, boolean isOperator, String displayName)
           
static void registerUDF(String functionName, Class<? extends UDF> UDFClass, 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

registerTemporaryUDF

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

registerUDF

public static void registerUDF(boolean isNative,
                               String functionName,
                               Class<? extends UDF> UDFClass,
                               boolean isOperator)

registerUDF

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

registerUDF

public static void registerUDF(boolean isNative,
                               String functionName,
                               Class<? extends UDF> UDFClass,
                               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)

registerTemporaryGenericUDTF

public static void registerTemporaryGenericUDTF(String functionName,
                                                Class<? extends GenericUDTF> genericUDTFClass)

registerGenericUDTF

public static void registerGenericUDTF(boolean isNative,
                                       String functionName,
                                       Class<? extends GenericUDTF> genericUDTFClass)

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 interested function names
Returns:
set of strings contains function names

getFunctionSynonyms

public static Set<String> getFunctionSynonyms(String funcName)
Returns the set of synonyms of the supplied function.

Parameters:
funcName - the name of the function
Returns:
Set of synonyms for funcName

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.


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.


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

matchCost

public static int matchCost(TypeInfo argumentPassed,
                            TypeInfo argumentAccepted,
                            boolean exact)
Returns -1 if passed does not match accepted. Otherwise return the cost (usually 0 for no conversion and 1 for conversion).


getMethodInternal

public static Method getMethodInternal(List<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.

getGenericUDFForIndex

public static GenericUDF getGenericUDFForIndex()
A shortcut to get the "index" GenericUDF. This is used for getting elements out of array and getting values out of map.


getGenericUDFForAnd

public static GenericUDF getGenericUDFForAnd()
A shortcut to get the "and" GenericUDF.


cloneGenericUDF

public static GenericUDF cloneGenericUDF(GenericUDF genericUDF)
Create a copy of an existing GenericUDF.


cloneGenericUDTF

public static GenericUDTF cloneGenericUDTF(GenericUDTF genericUDTF)
Create a copy of an existing GenericUDTF.


isDeterministic

public static boolean isDeterministic(GenericUDF genericUDF)
Returns whether a GenericUDF is deterministic or not.


isOpAndOrNot

public static boolean isOpAndOrNot(exprNodeDesc desc)
Returns whether the exprNodeDesc is a node of "and", "or", "not".


isOpAnd

public static boolean isOpAnd(exprNodeDesc desc)
Returns whether the exprNodeDesc is a node of "and".


isOpPositive

public static boolean isOpPositive(exprNodeDesc desc)
Returns whether the exprNodeDesc is a node of "positive".



Copyright © 2009 The Apache Software Foundation