在 Elastic Map Reduce 上使用带有 Pig 的分布式缓存
我正在尝试在 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 作业时,我看到一个异常:
有异常 java.io.FileNotFoundException : ./myfile.txt (没有这样的文件或目录)
那么,我的问题是:在亚马逊的 EMR 上运行 Pig 脚本时如何使用分布式缓存文件?
编辑:我发现pig-0.6 与pig-0.9 不同,它没有一个名为getCacheFiles() 的函数。亚马逊不支持pig-0.6,所以我需要找到一种不同的方法来在0.6中获得分布式缓存工作
I am trying to run my Pig script (which uses UDFs) on Amazon's Elastic Map Reduce.
I need to use some static files from within my UDFs.
I do something like this in my 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;
}
}
I have stored the file in my s3 bucket /path/to/myfile.txt
However, on running my Pig job, I see an exception:
Got an exception java.io.FileNotFoundException: ./myfile.txt (No such file or directory)
So, my question is: how do I use distributed cache files when running pig script on amazon's EMR?
EDIT: I figured out that pig-0.6, unlike pig-0.9 does not have a function called getCacheFiles(). Amazon does not support pig-0.6 and so I need to figure out a different way to get distributed cache work in 0.6
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为将此额外参数添加到 Pig 命令行调用中应该可行(使用 s3 或 s3n,具体取决于文件的存储位置):
您应该能够在创建作业流程时将其添加到“额外参数”框中。
I think adding this extra arg to the Pig command line call should work (with s3 or s3n, depending on where your file is stored):
You should be able to add that in the "Extra Args" box when creating the Job flow.