gpt4 book ai didi

exception - 在本地运行 pig,UDF 程序无法写入文件/文件夹 : PriviledgedActionException

转载 作者:可可西里 更新时间:2023-11-01 16:17:31 26 4
gpt4 key购买 nike

Pig/hadoop 新手..

在本地跑 pig 。

java  -Xmx512m -Xmx1024m -cp $PIGDIR/pig.jar org.apache.pig.Main -Dpig.temp.dir=/tmp/$USER/$RANDOM -stop_on_failure -x  local script-buzz.pig

用我的 script.pig:

(...) 
buzz = FOREACH files GENERATE chiron.buzz.Honey(file, id) as buzz_file, id;

尝试用我的 UDF raise 写一个文件夹/文件:

[JobControl] ERROR org.apache.hadoop.security.UserGroupInformation - PriviledgedActionException as:felipehorta cause:org.apache.pig.backend.executionengine.ExecException: ERROR 2118: Input path does not exist: file:/Users/felipehorta/dev/ufrj/pig/pig-buzz/output

以下代码必须(!)写入在下一次加载时使用的文件。

jar 适用于:$ java -jar Pgm.jar *

(...)
public String exec(Tuple input) throws IOException {
try{
System.out.println(input.get(0).toString());
BumbleBee b = new BumbleBee(input.get(0).toString());
return b.writeRelation(input.get(1).toString());
} catch(Exception e){
System.err.println("Failed to process input; error - " + e.getMessage());
return null;
}
}

public String writeRelation(String folder) throws IOException {
try {
// writing file!
File output = new File("output/ERelation_" + folder + ".txt");
output.getParentFile().mkdirs();
FileWriter fw = new FileWriter(output);
String line = System.getProperty("line.separator");
fw.append("YEAR;WORD;COUNT" + line);
for (Integer year : buzzCandidates.keySet()) {
Map<String, Long> wordCounts = buzzCandidates.get(year);
for (String word : wordCounts.keySet()) {
long value = wordCounts.get(word);
if (value >= 3) {
fw.append(year + ";" + word.replace(" ", "_") + ";" + String.valueOf(value) + line);
}
}
}
fw.flush();
fw.close();
return output.getAbsolutePath();
} catch (Exception e) {
System.out.println(">>> ERROR!!\t" + e.getMessage());
return "ERROR";
}
}

我觉得是关于用UDF写文件的权限,但是我不知道在哪里设置权限。有帮助吗?

先谢谢大家了!

最佳答案

错误读取 输入路径不存在:文件:/Users/felipehorta/dev/ufrj/pig/pig-buzz/output 请检查 pig 脚本以了解如何使用负载。

relation = load '/Users/felipehorta/dev/ufrj/pig/pig-buzz/output' using ...

是正确的做法。

不确定这是否是确切原因。如果您可以发布脚本,那就太好了。

关于exception - 在本地运行 pig,UDF 程序无法写入文件/文件夹 : PriviledgedActionException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16889087/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com