mapreduceジョブが実行されるたびに(たとえば、ユーザーの要求に応じて)、パラメータをマップに渡す必要があるという意味で動的なmapreduceジョブを実行する必要があります。GAE mapreduceで関数をマップするためにパラメータを動的に渡す方法はありますか?
どうすればよいですか?ドキュメントのどこにでも、実行時に動的な処理をマップや縮小のために行う方法がわかりませんでした。
class MatchProcessing(webapp2.RequestHandler):
def get(self):
requestKeyID=int(self.request.get('riderbeeRequestID'))
userKey=self.request.get('userKey')
pipeline = MatchingPipeline(requestKeyID, userKey)
pipeline.start()
self.redirect(pipeline.base_path + "/status?root=" + pipeline.pipeline_id)
class MatchingPipeline(base_handler.PipelineBase):
def run(self, requestKeyID, userKey):
yield mapreduce_pipeline.MapreducePipeline(
"riderbee_matching",
"tasks.matchingMR.riderbee_map",
"tasks.matchingMR.riderbee_reduce",
"mapreduce.input_readers.DatastoreInputReader",
"mapreduce.output_writers.BlobstoreOutputWriter",
mapper_params={
"entity_kind": "models.rides.RiderbeeRequest",
"requestKeyID": requestKeyID,
"userKey": userKey,
},
reducer_params={
"mime_type": "text/plain",
},
shards=16)
def riderbee_map(riderbeeRequest):
# would like to access the requestKeyID and userKey parameters that were passed in mapper_params
# so that we can do some processing based on that
yield (riderbeeRequest.user.email, riderbeeRequest.key().id())
def riderbee_reduce(key, values):
# would like to access the requestKeyID and userKey parameters that were passed earlier, perhaps through reducer_params
# so that we can do some processing based on that
yield "%s: %s\n" % (key, len(values))
助けてください。
FYI ...ここにJavaでジョブにデータを送信する方法である - にhttp:// WWW。 thecloudavenue.com/2011/11/passing-parameters-to-mappers-and.html –
Hmmm。あなたが与えるリンクは、Hadoopのものを指しています。これはGAE MapReduceのためのものです... –