本文整理汇总了Java中org.apache.hadoop.hive.ql.exec.Description类的典型用法代码示例。如果您正苦于以下问题:Java Description类的具体用法?Java Description怎么用?Java Description使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Description类属于org.apache.hadoop.hive.ql.exec包,在下文中一共展示了Description类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: register
import org.apache.hadoop.hive.ql.exec.Description; //导入依赖的package包/类
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);
}
}
示例2: register
import org.apache.hadoop.hive.ql.exec.Description; //导入依赖的package包/类
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);
}
}
示例3: parseOptions
import org.apache.hadoop.hive.ql.exec.Description; //导入依赖的package包/类
@Nonnull
protected final CommandLine parseOptions(String optionValue) throws UDFArgumentException {
String[] args = optionValue.split("\\s+");
Options opts = getOptions();
opts.addOption("help", false, "Show function help");
CommandLine cl = CommandLineUtils.parseOptions(args, opts);
if (cl.hasOption("help")) {
Description funcDesc = getClass().getAnnotation(Description.class);
final String cmdLineSyntax;
if (funcDesc == null) {
cmdLineSyntax = getClass().getSimpleName();
} else {
String funcName = funcDesc.name();
cmdLineSyntax = funcName == null ? getClass().getSimpleName()
: funcDesc.value().replace("_FUNC_", funcDesc.name());
}
StringWriter sw = new StringWriter();
sw.write('\n');
PrintWriter pw = new PrintWriter(sw);
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp(pw, HelpFormatter.DEFAULT_WIDTH, cmdLineSyntax, null, opts,
HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD, null, true);
pw.flush();
String helpMsg = sw.toString();
throw new UDFArgumentException(helpMsg);
}
return cl;
}
示例4: parseOptions
import org.apache.hadoop.hive.ql.exec.Description; //导入依赖的package包/类
@Nonnull
protected final CommandLine parseOptions(@Nonnull String optionValue)
throws UDFArgumentException {
String[] args = optionValue.split("\\s+");
Options opts = getOptions();
opts.addOption("help", false, "Show function help");
CommandLine cl = CommandLineUtils.parseOptions(args, opts);
if (cl.hasOption("help")) {
Description funcDesc = getClass().getAnnotation(Description.class);
final String cmdLineSyntax;
if (funcDesc == null) {
cmdLineSyntax = getClass().getSimpleName();
} else {
String funcName = funcDesc.name();
cmdLineSyntax = funcName == null ? getClass().getSimpleName()
: funcDesc.value().replace("_FUNC_", funcDesc.name());
}
StringWriter sw = new StringWriter();
sw.write('\n');
PrintWriter pw = new PrintWriter(sw);
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp(pw, HelpFormatter.DEFAULT_WIDTH, cmdLineSyntax, null, opts,
HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD, null, true);
pw.flush();
String helpMsg = sw.toString();
throw new UDFArgumentException(helpMsg);
}
return cl;
}
示例5: buildFunctionsFromUDF
import org.apache.hadoop.hive.ql.exec.Description; //导入依赖的package包/类
static void buildFunctionsFromUDF(Set<Class<? extends UDF>> classes, List<FunctionDesc> list, String jarurl) {
for (Class<? extends UDF> clazz: classes) {
String [] names;
String value = null, extended = null;
Description desc = clazz.getAnnotation(Description.class);
// Check @Description annotation (if exists)
if (desc != null) {
names = desc.name().split(",");
for (int i=0; i<names.length; i++) {
names[i] = names[i].trim();
}
value = desc.value();
extended = desc.extended();
}
else {
names = new String [] {clazz.getName().replace('.','_')};
}
// actual function descriptor building
FunctionDescBuilder builder = new FunctionDescBuilder();
UDFType type = clazz.getDeclaredAnnotation(UDFType.class);
if (type != null) {
builder.setDeterministic(type.deterministic());
}
builder.setFunctionType(CatalogProtos.FunctionType.UDF);
if (value != null) {
builder.setDescription(value);
}
if (extended != null) {
builder.setExample(extended);
}
UDFInvocationDesc udfInvocation = new UDFInvocationDesc(CatalogProtos.UDFtype.HIVE, clazz.getName(), jarurl, true);
// verify 'evaluate' method and extract return type and parameter types
for (Method method: clazz.getMethods()) {
if (method.getName().equals("evaluate")) {
registerMethod(method, names, udfInvocation, builder, list);
}
}
}
}