2011-11-22 64 views
5

我想在亚马逊的Elastic Map Reduce上运行我的Pig脚本(它使用UDF)。 我需要在我的UDF中使用一些静态文件。在猪弹性地图上使用分布式缓存Reduce

我做这样的事情在我的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

但是,在运行我的猪的工作,我在Amazon EMR猪运行脚本时如何使用分布式缓存文件:看一个例外:

Got an exception java.io.FileNotFoundException: ./myfile.txt (No such file or directory)

所以,我的问题是什么吗?

编辑:我想出了猪-0.6,不像pig-0.9没有称为getCacheFiles()的函数。亚马逊不支持猪-0.6,所以我需要找出一种不同的方式来获得分布式缓存工作在0.6

+0

也许你已经知道了,但对于其他人,亚马逊现在支持Pig 0.6和0.9.1 http://aws.amazon.com/elasticmapreduce/faqs/#pig-7 –

回答

0

我认为将这个额外的参数添加到猪命令行调用应该工作(与s3或s3n,具体取决于您的文件存储在哪里):

–cacheFile s3n://bucket_name/file_name#cache_file_name 

创建作业流程时,您应该可以在“Extra Args”框中添加它。

+0

@ vivek-pandey我的回答是否解决了你的问题问题? – cabad