udaf中加载外部文件

来源:互联网 发布:行政审批窗口知乎 编辑:程序博客网 时间:2024/05/17 23:14
加载外部文件:

1.在shell中 要将文件加载进去 使用add file

例如:

hive -e "
add file ./pro_data/testfile.txt;
add jars $CLASSIFIER_JAR;
...

说明:文件位置在./pro_data目录下


2.java调用时, 文件路径需要改变

例如:

ToolsUtils.getDic("./testfile.dic");

因为文件已经加载到hdfs中了,相当在当前目录下


3.udaf读取的时候,必须在UDAFEvaluator的实现类的 init函数中初始化

例如:

private static Map<String, String> testmap = null;

public void init() {
    idAndDirectoryAndActorMap = ToolsUtils.getIdAndPersonList("./testfile.txt");
}

这样才能被加载到文件中



0 0
原创粉丝点击