开发者

In AppEngine (JDO), what is the difference between equality (==) of an item with list and contains() function?

开发者 https://www.devze.com 2023-02-19 20:36 出处:网络
For example, if I have: List A; and a String B; What is the difference, in JDO (AppEngine), between the following two conditions in a query: B == A; and A.contains(B);?

For example, if I have: List A; and a String B;

What is the difference, in JDO (AppEngine), between the following two conditions in a query: B == A; and A.contains(B);?

Also, does the query in Slides 23-25 of http://dl.google.com/io/2009/pres/W_0415_Building_Scalable_Complex_App_Engines.pdf work efficiently in AppEngine (JDO) for more than 30 receivers? How so, especially since I read in AppEngine documentation that each contains() query can have a maximum of 30 items in th开发者_如何学Ce list. Do I not use a contains() query to imitate the above slides (written in Python)? If not, then how can I achieve the same results in JDO?

Any suggestions/comments are highly welcome. I'm trying to build a messaging system in AppEngine but having trouble trying to get used to the platform.

Thanks.


There's no difference - in App Engine, equality checks on lists are the same as checking for containment, due to the way things are indexed in the datastore.

By the query on slides 23-25, I presume you mean this one?

indexes = db.GqlQuery(
    "SELECT __key__ FROM MessageIndex "
    "WHERE receivers = :1", me)
keys = [k.parent() for k in indexes]
messages = db.get(keys)

This works just fine, as it's a list containment check as described above, and results in a single datastore query. The limitation you're thinking about is on the reverse: if you have a list, and you want to find a record that contains any item in that list, a subquery will be created for each element in the list.

0

精彩评论

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