2011-11-22 66 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