使用Google AppEngine MapReduce处理所有记录后,如何从计数器中获取值? [英] How do I get the values from the counter after I processed all the records with Google AppEngine MapReduce?

查看:52
本文介绍了使用Google AppEngine MapReduce处理所有记录后,如何从计数器中获取值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用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?

来自 http://code.google.com/p/appengine-mapreduce/wiki/UserGuidePython

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

完成映射归约操作后,如何获取计数器 counter1 的值?

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>

推荐答案

确定.由于您是从文档中发布代码,因此我假设您尚未尝试运行映射器.计数器的结果应显示在mapreduce会话的管理页面上.还必须有一种从映射器内部访问值的方法,但是我对API的Python版本还不十分了解,以告诉您如何使用.我知道这在Java方面是可行的.

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.

这篇关于使用Google AppEngine MapReduce处理所有记录后,如何从计数器中获取值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆