在将hive client切换到beeline梳理hive上的udf的时候,发现工程中好多任务的代码都是直接注册方法,没有显示的add jar,后来在hive的conf目录下发现了.hiverc文件中有两行add jar的命令,瞬间好奇怎么加载的这个文件,一开始以为是在bin/hive脚本中加载的,后来发现不是,是在client启动的时候CliDriver中记载的,加载的代码如下:
public void processInitFiles(CliSessionState ss) throws IOException {
boolean saveSilent = ss.getIsSilent();
ss.setIsSilent(true);
for (String initFile : ss.initFiles) {
int rc = processFile(initFile);
if (rc != 0) {
System.exit(rc);
}
}
if (ss.initFiles.size() == 0) {
if (System.getenv("HIVE_HOME") != null) {
String hivercDefault = System.getenv("HIVE_HOME") + File.separator +
"bin" + File.separator + HIVERCFILE;
if (new File(hivercDefault).exists()) {
int rc = processFile(hivercDefault);
if (rc != 0) {
System.exit(rc);
}
console.printError("Putting the global hiverc in " +
"$HIVE_HOME/bin/.hiverc is deprecated. Please "+
"use $HIVE_CONF_DIR/.hiverc instead.");
}
}
if (System.getenv("HIVE_CONF_DIR") != null) {
String hivercDefault = System.getenv("HIVE_CONF_DIR") + File.separator
+ HIVERCFILE;
if (new File(hivercDefault).exists()) {
int rc = processFile(hivercDefault);
if (rc != 0) {
System.exit(rc);
}
}
}
if (System.getProperty("user.home") != null) {
String hivercUser = System.getProperty("user.home") + File.separator +
HIVERCFILE;
if (new File(hivercUser).exists()) {
int rc = processFile(hivercUser);
if (rc != 0) {
System.exit(rc);
}
}
}
}
ss.setIsSilent(saveSilent);
}
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。