开发者

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

开发者 https://www.devze.com 2023-01-11 10:15 出处:网络
How do I get the values from the counter after I processed all the records with Google AppEngine MapReduce?

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 h开发者_Python百科ttp://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>


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消