Google应用引擎实体组 [英] Google app engine entity groups

查看:79
本文介绍了Google应用引擎实体组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知,从应用程序引擎教程中,实体组仅存在于交易中:

仅当实体组需要交易时才使用实体组 (来自教程)

定义在同一个实体组中的定义是具有相同的根。在这种情况下,使用多于1层级?
也就是说,为什么我应该用A - > B - > C(A是根,B他的儿子,C他的孙子)
而不是A→B; A→C ? (A,B和C仍然在同一个实体组中,因为A是它们的根)。

如果实体组的唯一目的是在实体之间进行事务处理,为什么我应该使用超过1个层次结构级别(根据根 - >孙子关联获得什么)?

重新进行查询,您可以使用 ancestor()将查询限制为特定实体的子项 - 在您的示例中,您只能查找 B 的后代,如果它们都处于顶级。



Google App Engine编程

b

键和实体组也有说:


实体组关系指示App Engine将多个实体存储在分布式网络的同一部分中...组中的所有实体都存储在
相同的数据存储节点

编辑:同一文档还列出了一些不希望实体组变得太大的原因:


您的
应用程序拥有的实体组越多 - 也就是说,根
实体越多 - 有效的
数据存储可以
分布
数据存储节点上的实体组。更好的分配
提高了创建
和更新数据的性能。另外,多个
用户试图更新
中同一个实体组中的实体同时
将导致一些用户重试他们的
交易,可能会导致一些
未能提交更改。请勿将应用程序实体的所有
置于
一个根目录下。


组将导致任何其他写入同一个实体组失败。如果您的大型实体组有大量写入,这会导致很多争用,并且您的应用必须处理预期的写入失败。 避免数据存储争用更详细地介绍了可用于最大限度减少的策略争论。


As far as I understand from app engine tutorial, entity groups exist only for the purpose of transactions:

"Only use entity groups when they are needed for transactions" (from the tutorial)

The definition of being in the same entity group is to have the same root.. In that case, what is the use of having more than 1 hierarchy level? That is, why should I use "A -> B -> C" (A is the root, B his son, C his grandson) instead of "A -> B ; A -> C" ? (A, B and C are still in the same entity group since A is their root).

If the only purpose of entity groups in to make transaction possible between entities, why should I use more than 1 hierarchy level (what do I earn from Root -> Grandson linkage)?

解决方案

When you're doing queries, you can use ancestor() to restrict the query to children of a particular entity - in your example, you could look for only descendants of B, which you couldn't do if they were all at the top level.

There's more on Ancestor Queries in Programming Google App Engine

The Keys and Entity Groups doc also says that:

Entity group relationships tell App Engine to store several entities in the same part of the distributed network ... All entities in a group are stored in the same datastore node

edit: The same document also lists some of the reasons why you don't want your entity groups to grow too large:

The more entity groups your application has—that is, the more root entities there are—the more efficiently the datastore can distribute the entity groups across datastore nodes. Better distribution improves the performance of creating and updating data. Also, multiple users attempting to update entities in the same entity group at the same time will cause some users to retry their transactions, possibly causing some to fail to commit changes. Do not put all of the application's entities under one root.

Any transaction on an entity in a Group will cause any other writes to the same entity group to fail. If you have a large entity group with lots of writes, this causes lots of contention, and your app then has to handle the expected write failures. Avoiding datastore contention goes into more detail on the strategies you can use to minimse the contention.

这篇关于Google应用引擎实体组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆