开发者

Using AppEngine-MapReduce on Google App Engine, what is the easiest way to analyze entities for a specific date range?

开发者 https://www.devze.com 2023-01-21 05:39 出处:网络
I am trying to use AppEngine-MapReduce. I understand ho开发者_运维知识库w to perform an operation over all entities of some entity_kind, but what is the easiest way to only operate on entities over a

I am trying to use AppEngine-MapReduce. I understand ho开发者_运维知识库w to perform an operation over all entities of some entity_kind, but what is the easiest way to only operate on entities over a data range when the entity has a date attribute? Is there a simple way to pass parameters to the mapper?

For example, what if I only wanted to delete entities where:

entity.created >= start and entity.created < stop

class Entity(db.Model):
  created = db.DateTimeProperty()

from mapreduce import operation as op
def process(entity):
  yield op.db.Delete(entity)


Currently there's no way to iterate over a query in a mapreduce - you have to iterate over every entity of the given kind. Instead, you should apply the filter in the map function, and only delete entities that match.


Since commit324 it is possible to use limited query filters as input.

If that will not let you do what you want there is an small extension you might want to try.

0

精彩评论

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