org.apache.hadoop.hive.metastore.api.Function.getClassName()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(13.4k)|赞(0)|评价(0)|浏览(127)

本文整理了Java中org.apache.hadoop.hive.metastore.api.Function.getClassName()方法的一些代码示例,展示了Function.getClassName()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Function.getClassName()方法的具体详情如下:
包路径:org.apache.hadoop.hive.metastore.api.Function
类名称:Function
方法名:getClassName

Function.getClassName介绍

暂无

代码示例

代码示例来源:origin: apache/hive

for (Function fn : fns) {
 String fqfn = fn.getDbName() + "." + fn.getFunctionName();
 if (udfs.containsKey(fn.getClassName())) {
  LOG.warn("Duplicate function names found for " + fn.getClassName() + " with " + fqfn
    + " and " + udfs.get(fn.getClassName()));
 udfs.put(fn.getClassName(), fqfn);
 List<ResourceUri> resources = fn.getResourceUris();
 if (resources == null || resources.isEmpty()) {

代码示例来源:origin: apache/hive

public void reloadFunctions() throws HiveException {
 HashSet<String> registryFunctions = new HashSet<String>(
   FunctionRegistry.getFunctionNames(".+\\..+"));
 for (Function function : getAllFunctions()) {
  String functionName = function.getFunctionName();
  try {
   LOG.info("Registering function " + functionName + " " + function.getClassName());
   String qualFunc = FunctionUtils.qualifyFunctionName(functionName, function.getDbName());
   FunctionRegistry.registerPermanentFunction(qualFunc, function.getClassName(), false,
         FunctionTask.toFunctionResource(function.getResourceUris()));
   registryFunctions.remove(qualFunc);
  } catch (Exception e) {
   LOG.warn("Failed to register persistent function " +
       functionName + ":" + function.getClassName() + ". Ignore and continue.");
  }
 }
 // unregister functions from local system registry that are not in getAllFunctions()
 for (String functionName : registryFunctions) {
  try {
   FunctionRegistry.unregisterPermanentFunction(functionName);
  } catch (Exception e) {
   LOG.warn("Failed to unregister persistent function " +
     functionName + "on reload. Ignore and continue.");
  }
 }
}

代码示例来源:origin: apache/hive

/**
  * This is called outside of the lock. Some of the methods that are called transitively by
  * this (e.g. addFunction) will take the lock again and then release it, which is ok.
  */
 private FunctionInfo getFunctionInfoFromMetastoreNoLock(String functionName, HiveConf conf) {
  try {
   String[] parts = FunctionUtils.getQualifiedFunctionNameParts(functionName);
   Function func = Hive.get(conf).getFunction(parts[0].toLowerCase(), parts[1]);
   if (func == null) {
    return null;
   }
   // Found UDF in metastore - now add it to the function registry.
   FunctionInfo fi = registerPermanentFunction(functionName, func.getClassName(), true,
     FunctionTask.toFunctionResource(func.getResourceUris()));
   if (fi == null) {
    LOG.error(func.getClassName() + " is not a valid UDF class and was not registered");
    return null;
   }
   return fi;
  } catch (Throwable e) {
   LOG.info("Unable to look up " + functionName + " in metastore", e);
  }
  return null;
 }
}

代码示例来源:origin: apache/drill

public void reloadFunctions() throws HiveException {
 HashSet<String> registryFunctions = new HashSet<String>(
   FunctionRegistry.getFunctionNames(".+\\..+"));
 for (Function function : getAllFunctions()) {
  String functionName = function.getFunctionName();
  try {
   LOG.info("Registering function " + functionName + " " + function.getClassName());
   String qualFunc = FunctionUtils.qualifyFunctionName(functionName, function.getDbName());
   FunctionRegistry.registerPermanentFunction(qualFunc, function.getClassName(), false,
         FunctionTask.toFunctionResource(function.getResourceUris()));
   registryFunctions.remove(qualFunc);
  } catch (Exception e) {
   LOG.warn("Failed to register persistent function " +
       functionName + ":" + function.getClassName() + ". Ignore and continue.");
  }
 }
 // unregister functions from local system registry that are not in getAllFunctions()
 for (String functionName : registryFunctions) {
  try {
   FunctionRegistry.unregisterPermanentFunction(functionName);
  } catch (Exception e) {
   LOG.warn("Failed to unregister persistent function " +
     functionName + "on reload. Ignore and continue.");
  }
 }
}

代码示例来源:origin: apache/drill

/**
  * This is called outside of the lock. Some of the methods that are called transitively by
  * this (e.g. addFunction) will take the lock again and then release it, which is ok.
  */
 private FunctionInfo getFunctionInfoFromMetastoreNoLock(String functionName, HiveConf conf) {
  try {
   String[] parts = FunctionUtils.getQualifiedFunctionNameParts(functionName);
   Function func = Hive.get(conf).getFunction(parts[0].toLowerCase(), parts[1]);
   if (func == null) {
    return null;
   }
   // Found UDF in metastore - now add it to the function registry.
   FunctionInfo fi = registerPermanentFunction(functionName, func.getClassName(), true,
     FunctionTask.toFunctionResource(func.getResourceUris()));
   if (fi == null) {
    LOG.error(func.getClassName() + " is not a valid UDF class and was not registered");
    return null;
   }
   return fi;
  } catch (Throwable e) {
   LOG.info("Unable to look up " + functionName + " in metastore", e);
  }
  return null;
 }
}

代码示例来源:origin: apache/hive

private CreateFunctionDesc build() throws SemanticException {
  replCopyTasks.clear();
  PrimaryToReplicaResourceFunction conversionFunction =
    new PrimaryToReplicaResourceFunction(context, metadata, destinationDbName);
  // We explicitly create immutable lists here as it forces the guava lib to run the transformations
  // and not do them lazily. The reason being the function class used for transformations additionally
  // also creates the corresponding replCopyTasks, which cannot be evaluated lazily. since the query
  // plan needs to be complete before we execute and not modify it while execution in the driver.
  List<ResourceUri> transformedUris = ImmutableList.copyOf(
    Lists.transform(metadata.function.getResourceUris(), conversionFunction)
  );
  replCopyTasks.addAll(conversionFunction.replCopyTasks);
  String fullQualifiedFunctionName = FunctionUtils.qualifyFunctionName(
    metadata.function.getFunctionName(), destinationDbName
  );
  // For bootstrap load, the create function should be always performed.
  // Only for incremental load, need to validate if event is newer than the database.
  ReplicationSpec replSpec = (context.dmd == null) ? null : context.eventOnlyReplicationSpec();
  return new CreateFunctionDesc(
      fullQualifiedFunctionName, false, metadata.function.getClassName(),
      transformedUris, replSpec
  );
 }
}

代码示例来源:origin: apache/hive

public void startLocalizeAllFunctions() throws HiveException {
 Hive hive = Hive.get(false);
 // Do not allow embedded metastore in LLAP unless we are in test.
 try {
  hive.getMSC(HiveConf.getBoolVar(conf, ConfVars.HIVE_IN_TEST), true);
 } catch (MetaException e) {
  throw new HiveException(e);
 }
 List<Function> fns = hive.getAllFunctions();
 for (Function fn : fns) {
  String fqfn = fn.getDbName() + "." + fn.getFunctionName();
  List<ResourceUri> resources = fn.getResourceUris();
  if (resources == null || resources.isEmpty()) continue; // Nothing to localize.
  FnResources result = new FnResources();
  resourcesByFn.put(fqfn, result);
  workQueue.add(new LocalizeFn(fqfn, resources, result, fn.getClassName(), false));
 }
 workQueue.add(new RefreshClassloader());
}

代码示例来源:origin: apache/hive

public Object getFieldValue(_Fields field) {
 switch (field) {
 case FUNCTION_NAME:
  return getFunctionName();
 case DB_NAME:
  return getDbName();
 case CLASS_NAME:
  return getClassName();
 case OWNER_NAME:
  return getOwnerName();
 case OWNER_TYPE:
  return getOwnerType();
 case CREATE_TIME:
  return getCreateTime();
 case FUNCTION_TYPE:
  return getFunctionType();
 case RESOURCE_URIS:
  return getResourceUris();
 case CAT_NAME:
  return getCatName();
 }
 throw new IllegalStateException();
}

代码示例来源:origin: apache/hive

private MFunction convertToMFunction(Function func) throws InvalidObjectException {
 if (func == null) {
  return null;
 }
 MDatabase mdb = null;
 String catName = func.isSetCatName() ? func.getCatName() : getDefaultCatalog(conf);
 try {
  mdb = getMDatabase(catName, func.getDbName());
 } catch (NoSuchObjectException e) {
  LOG.error("Database does not exist", e);
  throw new InvalidObjectException("Database " + func.getDbName() + " doesn't exist.");
 }
 MFunction mfunc = new MFunction(func.getFunctionName(),
   mdb,
   func.getClassName(),
   func.getOwnerName(),
   func.getOwnerType().name(),
   func.getCreateTime(),
   func.getFunctionType().getValue(),
   convertToMResourceUriList(func.getResourceUris()));
 return mfunc;
}

代码示例来源:origin: apache/hive

assertEquals("function db name", dbName, func.getDbName());
assertEquals("function name", funcName, func.getFunctionName());
assertEquals("function class name", className, func.getClassName());
assertEquals("function owner name", owner, func.getOwnerName());
assertEquals("function owner type", PrincipalType.USER, func.getOwnerType());

代码示例来源:origin: apache/hive

private void validateFunctionInfo(Function func) throws InvalidObjectException, MetaException {
 if (func == null) {
  throw new MetaException("Function cannot be null.");
 }
 if (func.getFunctionName() == null) {
  throw new MetaException("Function name cannot be null.");
 }
 if (func.getDbName() == null) {
  throw new MetaException("Database name in Function cannot be null.");
 }
 if (!MetaStoreUtils.validateName(func.getFunctionName(), null)) {
  throw new InvalidObjectException(func.getFunctionName() + " is not a valid object name");
 }
 String className = func.getClassName();
 if (className == null) {
  throw new InvalidObjectException("Function class name cannot be null");
 }
 if (func.getOwnerType() == null) {
  throw new MetaException("Function owner type cannot be null.");
 }
 if (func.getFunctionType() == null) {
  throw new MetaException("Function type cannot be null.");
 }
}

代码示例来源:origin: apache/hive

assertEquals("function db name", dbName, func.getDbName());
assertEquals("function name", funcName + "_0", func.getFunctionName());
assertEquals("function class name", className, func.getClassName());
assertEquals("function owner name", owner, func.getOwnerName());
assertEquals("function owner type", PrincipalType.USER, func.getOwnerType());

代码示例来源:origin: apache/hive

Assert.assertEquals(function.getDbName(), createdFunction.getDbName());
Assert.assertEquals(expectedCatalog(), createdFunction.getCatName());
Assert.assertEquals(function.getClassName(), createdFunction.getClassName());
Assert.assertEquals(function.getOwnerName(), createdFunction.getOwnerName());
Assert.assertEquals(function.getOwnerType(), createdFunction.getOwnerType());

代码示例来源:origin: apache/hive

Assert.assertEquals("Comparing OwnerType", newFunction.getOwnerType(),
  alteredFunction.getOwnerType());
Assert.assertEquals("Comparing ClassName", newFunction.getClassName(),
  alteredFunction.getClassName());
Assert.assertEquals("Comparing FunctionType", newFunction.getFunctionType(),
  alteredFunction.getFunctionType());

代码示例来源:origin: org.apache.hive/hive-standalone-metastore

private void validateFunctionInfo(Function func) throws InvalidObjectException, MetaException {
 if (!MetaStoreUtils.validateName(func.getFunctionName(), null)) {
  throw new InvalidObjectException(func.getFunctionName() + " is not a valid object name");
 }
 String className = func.getClassName();
 if (className == null) {
  throw new InvalidObjectException("Function class name cannot be null");
 }
}

代码示例来源:origin: com.facebook.presto.hive/hive-apache

private void validateFunctionInfo(Function func) throws InvalidObjectException, MetaException {
 if (!MetaStoreUtils.validateName(func.getFunctionName())) {
  throw new InvalidObjectException(func.getFunctionName() + " is not a valid object name");
 }
 String className = func.getClassName();
 if (className == null) {
  throw new InvalidObjectException("Function class name cannot be null");
 }
}

代码示例来源:origin: org.spark-project.hive/hive-metastore

private void validateFunctionInfo(Function func) throws InvalidObjectException, MetaException {
 if (!MetaStoreUtils.validateName(func.getFunctionName())) {
  throw new InvalidObjectException(func.getFunctionName() + " is not a valid object name");
 }
 String className = func.getClassName();
 if (className == null) {
  throw new InvalidObjectException("Function class name cannot be null");
 }
}

代码示例来源:origin: com.facebook.presto.hive/hive-apache

public static void reloadFunctions() throws HiveException {
 Hive db = Hive.get();
 for (String dbName : db.getAllDatabases()) {
  for (String functionName : db.getFunctions(dbName, "*")) {
   Function function = db.getFunction(dbName, functionName);
   try {
  FunctionRegistry.registerPermanentFunction(
    FunctionUtils.qualifyFunctionName(functionName, dbName), function.getClassName(),
    false, FunctionTask.toFunctionResource(function.getResourceUris()));
   } catch (Exception e) {
    LOG.warn("Failed to register persistent function " +
      functionName + ":" + function.getClassName() + ". Ignore and continue.");
   }
  }
 }
}

代码示例来源:origin: org.apache.hive/hive-llap-server

public void startLocalizeAllFunctions() throws HiveException {
 Hive hive = Hive.get(false);
 // Do not allow embedded metastore in LLAP unless we are in test.
 try {
  hive.getMSC(HiveConf.getBoolVar(conf, ConfVars.HIVE_IN_TEST), true);
 } catch (MetaException e) {
  throw new HiveException(e);
 }
 List<Function> fns = hive.getAllFunctions();
 for (Function fn : fns) {
  String fqfn = fn.getDbName() + "." + fn.getFunctionName();
  List<ResourceUri> resources = fn.getResourceUris();
  if (resources == null || resources.isEmpty()) continue; // Nothing to localize.
  FnResources result = new FnResources();
  resourcesByFn.put(fqfn, result);
  workQueue.add(new LocalizeFn(fqfn, resources, result, fn.getClassName(), false));
 }
 workQueue.add(new RefreshClassloader());
}

代码示例来源:origin: com.facebook.presto.hive/hive-apache

private MFunction convertToMFunction(Function func) throws InvalidObjectException {
 if (func == null) {
  return null;
 }
 MDatabase mdb = null;
 try {
  mdb = getMDatabase(func.getDbName());
 } catch (NoSuchObjectException e) {
  LOG.error(StringUtils.stringifyException(e));
  throw new InvalidObjectException("Database " + func.getDbName() + " doesn't exist.");
 }
 MFunction mfunc = new MFunction(func.getFunctionName(),
   mdb,
   func.getClassName(),
   func.getOwnerName(),
   func.getOwnerType().name(),
   func.getCreateTime(),
   func.getFunctionType().getValue(),
   convertToMResourceUriList(func.getResourceUris()));
 return mfunc;
}

相关文章