简体   繁体   English

可以对数据存储区实体使用否定ID吗?

[英]Ok to use negative id's for datastore entities?

I would like to re-visit this old SO post , which says that the datastore can never have negative ID's, but is for the old M/S datastore and I believe no longer applies. 我想重新访问这个旧的SO帖子 ,该帖子说该数据存储区永远不会有负ID,但适用于旧的M / S数据存储区,我相信它不再适用。

(Note that this question is distinct from the common question about the auto-generate functionality, which still does not produce negative numbers.) (请注意,此问题与关于自动生成功能的常见问题不同,后者仍然不会产生负数。)

I find that the consensus of SO is that the datastore does not support negative id's, yet I've been using them for one of the Kind's in my app. 我发现SO的共识是数据存储区不支持否定ID,但我一直在我的应用程序中将它们用于同类之一。

I manually assign the negative numbers to the (Java) long id field of my entities' when I created them. 创建负数时,我将负数手动分配给实体的(Java)long id字段。 When I view the entities in the GAE console data viewer they appear correctly as negative numbers, eg "id=-8673495404141992816". 当我在GAE控制台数据查看器中查看实体时,它们正确显示为负数,例如“ id = -8673495404141992816”。

Perhaps the idea that the DS doesn't support negative ID's is just a relic of the M/S datastore, or perhaps I have unintentionally gone into unsupported and uncharted territory - in which case I should change my app! DS不支持负ID的想法可能只是M / S数据存储的遗物,或者我无意间进入了不受支持和未知的领域-在这种情况下,我应该更改我的应用程序!

Also, IMO, this is a fairly fundamental question in regard to the DS, so I want to be clear about the answer. 另外,IMO,对于DS来说,这是一个相当基本的问题,所以我想清楚答案。 After all, I'd like to have the option to generate ID's using a 64-bit hash function which could produce negative numbers. 毕竟,我想选择使用64位哈希函数生成ID的方法,该函数可能会产生负数。

IDs appear to be 64-bit values. ID似乎是64位值。 However, the default app id generator limits them to postive 53 bit values so that they will work with Javascript. 但是,默认的应用程序ID生成器将它们限制为正53位值,以便它们可以与Javascript一起使用。 You're probably floating around in uncharted territory. 您可能在未知的领域中徘徊。

Or at the very least, rarely used territory. 或至少是很少使用的领土。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM