我正在尝试在 Amazon 的 Elastic Map Reduce 上运行我的 Pig 脚本(它使用 UDF)。我需要使用我的 UDF 中的一些静态文件。
我在我的 UDF 中做了这样的事情:
public class MyUDF extends EvalFunc<DataBag> {
public DataBag exec(Tuple input) {
...
FileReader fr = new FileReader("./myfile.txt");
...
}
public List<String> getCacheFiles() {
List<String> list = new ArrayList<String>(1);
list.add("s3://path/to/myfile.txt#myfile.txt");
return list;
}
}
我已将文件存储在我的 s3 存储桶 /path/to/myfile.txt
但是,在运行我的 Pig 作业时,我看到了一个异常:
Got an exception java.io.FileNotFoundException: ./myfile.txt (No such file or directory)
所以,我的问题是:在亚马逊的 EMR 上运行 pig 脚本时如何使用分布式缓存文件?
编辑:我发现 pig-0.6 与 pig-0.9 不同,它没有名为 getCacheFiles() 的函数。亚马逊不支持 pig-0.6,所以我需要找出一种不同的方法来在 0.6 中获得分布式缓存工作