SelfReferenceProperty与ListProperty Google App Engine [英] SelfReferenceProperty vs. ListProperty Google App Engine

查看:101
本文介绍了SelfReferenceProperty与ListProperty Google App Engine的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Google App Engine并有疑问。为简单起见,假设我的应用程序正在为计算机网络(一个拥有10,000个节点的相当大的公司网络)建模。我试图模拟我的Node类如下:

  class Node(db.Model):
name = db .StringProperty()
neighbors = db.SelfReferenceProperty()

让我们假设一分钟,我不能使用ListProperty()。根据我迄今为止的实验,我只能将一个实体分配给邻居 - 我不能使用虚拟集合(node_set)来访问节点邻居列表。



所以......我的问题是:


  1. SelfReferenceProperty会限制您一个可以引用的单个实体?

  2. 如果我使用ListProperty,我相信我只能使用5,000个密钥, li>

更新



就像我一样,我忘记了* ReferenceReleationship是向后 - 事物的列表指向关系的一方。 SelfReferenceProperty按我的想法工作。我的错。我仍然需要处理关系中大量的很多方面 - 而且我不认为ListProperty可以做到这一点,但我会发布我找到的。



感谢,
John

解决方案

询问):对于模型中的每个属性,模型的每个实例(AKA实体)具有该属性的一个值。所以例如对于给定的实体, IntegerProperty 具有一个整数值, SelfReferenceProperty 具有给定实体的一个值(内部是键字符串)等等。当然,这个模块的所有实例都不是一个 single 值,但我不相信这就是你的意思。



Re 2, 5000的限制(哇,这对于一个节点图只有10000个节点的邻居是一个很多)我相信你指的是在 indices 上一个实体 - 这篇文章更好地解释了这个限制。



一个可能的解决方法是根本没有 neighbors 属性在节点上,而是一个单独的连接模型来表示从一个节点到另一个节点的连接(使用 ReferenceProperty 属性,在连接中,每个引用一个节点)。您需要在Connection中额外添加一些内容(例如,受影响节点的传入和传出连接的累进计数),以便能够获取数千个数据,当然(在多个查询中,给定每次1000个限制)。

I am experimenting with the Google App Engine and have a question.

For the sake of simplicity, let's say my app is modeling a computer network (a fairly large corporate network with 10,000 nodes). I am trying to model my Node class as follows:

class Node(db.Model):
    name = db.StringProperty()
    neighbors = db.SelfReferenceProperty()  

Let's suppose, for a minute, that I cannot use a ListProperty(). Based on my experiments to date, I can assign only a single entity to 'neighbors' - and I cannot use the "virtual" collection (node_set) to access the list of Node neighbors.

So... my questions are:

  1. Does SelfReferenceProperty limit you to a single entity that you can reference?
  2. If I instead use a ListProperty, I believe I am limited to 5,000 keys, which I need to exceed.

Update

All wrapped up in my shorts as I was, I forgot the *ReferenceReleationship is "backwards" --- the "list" of things points back to the one side of the relationship. The SelfReferenceProperty works as I thought it would. My bad. I'll still need to deal with the large "many" side of the relationship - and I don't think a ListProperty will do the trick, but I'll post what I find.

Thanks, John

解决方案

Re 1, yes (if I understand correctly what you're asking): for each property in a model, each instance of the model (AKA "entity") has one value for that property. So e.g. an IntegerProperty has one integer value for a given entity, a SelfReferenceProperty has one value (internally a key string) for a given entity, and so forth. Not a single value for all instances of the module, of course, but I don't believe that's what you mean.

Re 2, the 5000 limit (wow, that's a lot of neighbors for a single node graph that only has 10000 nodes in all!) I believe you're referring to is on indices for an entity -- this article explains the limitation better.

One possible workaround is to have no neighbors property at all on the nodes, but rather a separate Connection model to represent the connection from one node to another (with ReferenceProperty properties, in the Connection, that each refer to a Node). You'll need something extra in the Connection (e.g., progressive counts of incoming and outgoing connections for the affected nodes) to be able to fetch many thousands of them, of course (in multiple queries, given the 1000-at-a-time limitation).

这篇关于SelfReferenceProperty与ListProperty Google App Engine的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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