我正在使用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
答案 0 :(得分:5)
您可以通过MapreduceState
's counter_map
属性访问计数器。
from mapreduce import model
state = model.MapreduceState.get_by_job_id(your_job_id)
# counters live in state.counters_map
大约一个月前,邮件列表上有一个关于访问计数器的discussion。