如何将参数传递给mapreduce mapper
中定义的mapreduce_pipeline.MapreducePipeline
函数?
我使用DatastoreInputReader
作为输入源。通常,我只需要一个简单的映射器函数:
def mapper(model_entity_instance):
""" my mapper function """
但这次我需要的东西是:
def mapper(model_entity_instance, params_dict):
""" my mapper function """
如何通过标准mapreduce
包实现此目的?
答案 0 :(得分: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