2014-01-12 53 views
1

如何将参数传递给我定义的mapper函数中的mapreduce mapreduce_pipeline.MapreducePipeline将参数传递给流水线中的映射函数

我使用的是DatastoreInputReader作为输入源。通常情况下,我只需要一个简单的映射函数:

def mapper(model_entity_instance): 
    """ my mapper function """ 

但是这一次,我需要这样的:

def mapper(model_entity_instance, params_dict): 
    """ my mapper function """ 

如何通过标准mapreduce包实现这一目标?

回答

4

找到了一个方法:

from mapreduce import context 

def mapper(model_entity_instance, params_dict): 
    """ my mapper function """ 
    ctx=context.get() 
    mapper_params=ctx.mapreduce_spec.mapper.params