use of org.apache.hadoop.hive.ql.udf.UDFType in project drill by apache.
the class HiveFunctionRegistry method register.
private <C, I> void register(Class<? extends I> clazz, ArrayListMultimap<String, Class<? extends I>> methods) {
Description desc = clazz.getAnnotation(Description.class);
String[] names;
if (desc != null) {
names = desc.name().split(",");
for (int i = 0; i < names.length; i++) {
names[i] = names[i].trim();
}
} else {
names = new String[] { clazz.getName().replace('.', '_') };
}
UDFType type = clazz.getAnnotation(UDFType.class);
if (type != null && !type.deterministic()) {
nonDeterministicUDFs.add(clazz);
}
for (int i = 0; i < names.length; i++) {
methods.put(names[i].toLowerCase(), clazz);
}
}
use of org.apache.hadoop.hive.ql.udf.UDFType in project drill by axbaretto.
the class HiveFunctionRegistry method register.
private <C, I> void register(Class<? extends I> clazz, ArrayListMultimap<String, Class<? extends I>> methods) {
Description desc = clazz.getAnnotation(Description.class);
String[] names;
if (desc != null) {
names = desc.name().split(",");
for (int i = 0; i < names.length; i++) {
names[i] = names[i].trim();
}
} else {
names = new String[] { clazz.getName().replace('.', '_') };
}
UDFType type = clazz.getAnnotation(UDFType.class);
if (type != null && !type.deterministic()) {
nonDeterministicUDFs.add(clazz);
}
for (int i = 0; i < names.length; i++) {
methods.put(names[i].toLowerCase(), clazz);
}
}
use of org.apache.hadoop.hive.ql.udf.UDFType in project drill by apache.
the class HiveFunctionRegistry method register.
private <I> void register(Class<? extends I> clazz, Multimap<String, Class<? extends I>> methods) {
Description desc = clazz.getAnnotation(Description.class);
Stream<String> namesStream;
if (desc != null) {
namesStream = Stream.of(desc.name().split(",")).map(String::trim);
} else {
namesStream = Stream.of(clazz).map(Class::getName).map(name -> name.replace('.', '_'));
}
// Checks specified array of function names whether they should be replaced
// using FUNCTION_REPLACE_MAP map.
namesStream.map(String::toLowerCase).map(functionName -> FUNCTION_REPLACE_MAP.getOrDefault(functionName, functionName)).forEach(name -> methods.put(name, clazz));
UDFType type = clazz.getAnnotation(UDFType.class);
if (type != null && !type.deterministic()) {
nonDeterministicUDFs.add(clazz);
}
}
use of org.apache.hadoop.hive.ql.udf.UDFType in project hive by apache.
the class FunctionRegistry method isRuntimeConstant.
/**
* Returns whether a GenericUDF is a runtime constant or not.
*/
public static boolean isRuntimeConstant(GenericUDF genericUDF) {
UDFType genericUDFType = AnnotationUtils.getAnnotation(genericUDF.getClass(), UDFType.class);
if (genericUDFType != null && genericUDFType.runtimeConstant()) {
return true;
}
if (genericUDF instanceof GenericUDFBridge) {
GenericUDFBridge bridge = (GenericUDFBridge) genericUDF;
UDFType bridgeUDFType = AnnotationUtils.getAnnotation(bridge.getUdfClass(), UDFType.class);
if (bridgeUDFType != null && bridgeUDFType.runtimeConstant()) {
return true;
}
}
if (genericUDF instanceof GenericUDFMacro) {
GenericUDFMacro macro = (GenericUDFMacro) (genericUDF);
return macro.isRuntimeConstant();
}
return false;
}
use of org.apache.hadoop.hive.ql.udf.UDFType in project hive by apache.
the class FunctionRegistry method isStateful.
/**
* Returns whether a GenericUDF is stateful or not.
*/
public static boolean isStateful(GenericUDF genericUDF) {
UDFType genericUDFType = AnnotationUtils.getAnnotation(genericUDF.getClass(), UDFType.class);
if (genericUDFType != null && genericUDFType.stateful()) {
return true;
}
if (genericUDF instanceof GenericUDFBridge) {
GenericUDFBridge bridge = (GenericUDFBridge) genericUDF;
UDFType bridgeUDFType = AnnotationUtils.getAnnotation(bridge.getUdfClass(), UDFType.class);
if (bridgeUDFType != null && bridgeUDFType.stateful()) {
return true;
}
}
if (genericUDF instanceof GenericUDFMacro) {
GenericUDFMacro macro = (GenericUDFMacro) (genericUDF);
return macro.isStateful();
}
return false;
}
Aggregations