2015-05-09 84 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. 

````

相关问题