English 中文(简体)
如何最佳地盘问谷歌应用引擎数据储存重叠的时间范围
原标题:How to do optimal query Google App Engine Data store about overlapping time ranges

我有点,开端和终点(删除提及资源的例子,以更明确地说明):

class Reservation(db.Model):
  fromHour = db.DateTimeProperty()
  toHour = db.DateTimeProperty()
  fromToRange = db.ComputedProperty(lambda x: [x.fromHour, x.toHour])

并且希望添加另一个保留,如果它没有overlaps 之前的核查——如何在谷歌应用引擎中表达这种质问。

<>1st 我用list property,但double inequalityfils/strong>不可行。 它应从1 <,到2,从1 >,到1 >,到2和1个结果,无论如果数据增加,费用如何。

fromHour = datetime.datetime(2012, 04, 18, 0, 0, 0)
toHour = datetime.datetime(2012, 04, 18, 2, 0, 0)

reservation = Reservation(fromHour = fromHour, toHour = toHour, colors = [ white ,  black ])
reservation.put()

self.response.out.write( <p>Both %s</p>  % fromHour)    
self.response.out.write( <ol> )    
for reservation in Reservation.all()
  .filter( fromToRange > , fromHour)
  .filter( fromToRange <= , fromHour):
  self.response.out.write( <li>%s</li>  % (reservation.fromToRange))
self.response.out.write( </ol> )

我发现another Solutions,我可以使用包含日数的附加财产(这将是每份保留范围天数清单),因为需要检查日数,以缩小数据扫描,检查每份记录,如果新保留不重叠的话。

请帮助并提供一些答案,说明如何进行最佳查询,以发现重叠的保留——可能的话,在谷歌应用发动机中,时间范围问题有快速的解决方案,或者没有得到支持。

问题回答

是的,多重不平等过滤了对询问的限制,使得某些事情很难做到/难以做到。 例如,地理搜索。

d 我接受你提议的解决办法:确定财产价值,在清单财产中保留所有固定价值,例如,节省所有时间,包括将财产列入清单。 模棱两可的部分是选择适当的固定等级:天数、小时等。

从个人角度来说,我开始采用普遍时间尺度:不一时(时代),然后四舍五入到二分之四,然后 de缩。 例如,从清单中删除3个零件(1,000个第二剂,横跨约16个min),并从一开始节省全部固定价值。

如果水泥厂的罚款过重,则使用大于1:1 000座。

然后,你可以简单地在名单上询问财产,并附上一份平等过滤器和另外的过滤结果,以说明确切的时间开始和结束。





相关问题
How to make logging.debug work on Appengine?

I m having a tough time getting the logging on Appengine working. the statement import logging is flagged as an unrecognized import in my PyDev Appengine project. I suspected that this was just an ...

gqlQuery returns object, want list of keys

Is there a way to convert the GqlQuery object to an array of keys, or is there a way to force the query to return an array of keys? For example: items = db.GqlQuery("SELECT __key__ FROM Items") ...

Integrating Google AppEngine with a Thick Client

I want to make a multi-user client-server solution with Java Swing thick client as a front-end and Google AppEngine (Java one) as a back-end. The problem is that GAE provides only web-based forms for ...

sorl.thumbnail : thumbnail is not a valid tag library?

I am trying to install sorl.thumbnail but am getting the following error message: thumbnail is not a valid tag library: Could not load template library from django.templatetags.thumbnail, No module ...