Chr*_*ris 5 google-app-engine mapreduce
我正在使用Google App Engine mapreduce来分析一些数据.我正在生成一些计数器,我想在我的done_callback中创建一个简单的Google图表.如何从回调中访问结果计数器?
#The map method
def count_created_since(entity):
now = datetime.datetime.now()
delta = now-entity.created
#analyze last 12 weeks
for x in range(12):
start = 7*x
stop = 7*(x+1)
if delta.days >= start and delta.days < stop:
#The counters
yield op.counters.Increment(str(x)+" weeks ago")
def my_callback(request):
# fetch counter results to create a simple Google chart url
Run Code Online (Sandbox Code Playgroud)
您可以通过访问计数器MapreduceState的 counter_map属性.
from mapreduce import model
state = model.MapreduceState.get_by_job_id(your_job_id)
# counters live in state.counters_map
Run Code Online (Sandbox Code Playgroud)
有一个讨论的邮件列表上大约每月访问计数器多前.
| 归档时间: |
|
| 查看次数: |
617 次 |
| 最近记录: |