2015-05-09 81 views
2

我正在編寫多步驟mrjob。第一步驟做一些預處理和用下面的減速結束:將mrjob步驟的結果作爲參數傳遞給下一步

def some_reducer(self, key, values): 
    values = (int (value) for value in values) 
    if key == 'iwantthiskey': 
     //I want to pass sum(values) as a parameter to the next step 

我試圖通過文檔去,並用添加直通選項或添加值以self.jobconf()試驗,但我不能」弄明白了。 任何幫助,將不勝感激。

回答

0

Sonic provided an excellent solution by making a global variable。基本上,一旦你得到想要的值,將它存儲在全局變量中供以後使用。

my_parameter = None 

def some_reducer(self, key, values): 
    global my_parameter 
    values = (int (value) for value in values) 
    if key == 'iwantthiskey': 
     my_parameter = sum(values) 

def next_funtion_or_job(self, input, parameter=my_parameter): 
    #Your method goes here. 

````

相關問題