views:

71

answers:

1

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>
A: 

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.

Peter Recore
That interesting. Is the sum of a counter, the sum of the counters in all mappers? That would mean that the counters are reduced!?
Johan Carlsson