How do I get the values from the counter after I processed all the records with Google AppEngine MapReduce?

杀马特。学长 韩版系。学妹 提交于 2019-12-10 17:08:32

问题


How do I get the values from the counter after I processed all the records with Google AppEngine MapReduce?

Or am I missing the use case for counters here?

Sample Code from http://code.google.com/p/appengine-mapreduce/wiki/UserGuidePython

How would I retrieve the value of counter counter1 when the mapreduce is done?

app.yaml

handlers:
- url: /mapreduce(/.*)?
  script: mapreduce/main.py
  login: admin

mapreduce/main.py

from mapreduce import operation as op
def process(entity):
    yield op.counters.Increment("counter1")

mapreduce.yaml

mapreduce:
- name: <Some descriptive name for UI>
  mapper:
    input_reader: mapreduce.input_readers.DatastoreInputReader
    handler: main.process
    params:
    - name: entity_kind
      default: <your entity name, e.g. main.MyEntity>

回答1:


OK. Since you're posting the code from the docs I'll assume you haven't tried to run a mapper yet. The results from the counter should show up on the admin page for the mapreduce session. There must be a way to access the values from within the mapper as well but I am not familiar enough with the Python version of the API to tell you how. I know it is doable in the Java side.



来源:https://stackoverflow.com/questions/3465669/how-do-i-get-the-values-from-the-counter-after-i-processed-all-the-records-with

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!