了解Java API中AppEngine键名的最大长度 [英] Understanding maximum length of an AppEngine key-name in the Java API
问题描述
我试图找出AppEngine的最大长度 key name 位于Java API中。
这个问题在以下方面的要求要低得多:
并且收到了两个相互冲突的答案(对于我来说这个答案似乎不太可信)
@ryan能够在他的答案,我一直在试图找到类似的东西在Java API中。
但 Key.java ,也不是 KeyFactory.java , KeyTranslator.java 似乎对一个密钥的 name
属性实施任何限制。所以,如果有限制,它在其他地方实施。 KeyTranslator
调用 com.google.storage.onestore.v3.OnestoreEntity.Path.Element.setName()
,它可以成为实施限制的地方,但不幸的是,我无法在任何地方找到此类的源代码。
具体而言,我想知道: p>
- 500字符是否限制了后端某处键名所特有的硬限制,还是仅仅建议应该足以确保完整的键串永远不会超过 1500如果我理解正确,那么包含更多字节的长文本属性不能被编入索引。
-
如果它是一个硬限制:
- 它是500个字符还是500个字节(即一些编码后的长度)?
- 完整的500 b ytes /字符可用于密钥的名称或其他密钥组件(kind,parent,app-id,...)从这个数字中扣除?
-
如果是推荐:
- 所有情况下都足够吗?
- 如果所有键都位于我的应用程序的根目录下,并且种类只有一个字母,我可以使用的最大值是多少?换句话说:在给定其他关键组件的情况下,是否有一个公式可用于计算 real 限制?
最后,如果我试图通过存储长度不断增加的密钥来度量这个限制,直到我得到一些异常,我能否依赖于我发现的限制,如果我只创建具有相同祖先路径的密钥并在相同的应用程序中的相同长度的种类?或者是否有其他可变长度的组件可能会被添加并在某些情况下减少可用的键名称长度?开发和生产服务器应该是相同的吗? 数据存储在后端实现所有验证(因为它阻止了一个客户端中的成功操作在另一个客户端中失败)。数据存储键具有以下限制: - 一个键最多可以有100个路径元素(这些是kind,name / id对)
- 每种类型最多可以包含1500个字节。
- 每个名称最多可以包含1500个字节。
- Is the 500 character limit a hard limit specifically imposed for key names somewhere in the backend or is it simply a recommendation that should be sufficient to make sure the full key-string never exceeds the 1500-byte limit of a short text property (long text properties with more bytes cannot be indexed, if I understand correctly).
If it is a hard limit:
- Is it 500 characters or 500 bytes (i.e. the length after some encoding)?
- Are the full 500 bytes/characters available for the name of the key or do the other key-components (kind, parent, app-id, ...) deduct from this number?
If it is a recommendation:
- Is it sufficient in all cases?
- What is the maximum I can use if all keys are located in the root of my application and the kind is only one letter long? In other words: Is there a formula I can use to calculate the real limit given the other key components?
Lastly, if I simply try to measure this limit by attempting to store keys of increasing length until I get some exception, will I be able to rely on the limit that I find if I only create keys with identical ancestor paths and same-length kinds in the same application? Or are there other variable-length components to a key that might get added and reduce the available key-name-length in some cases? Should it be the same for the Development and the Production Servers?
- A key can have at most 100 path elements (these are kind, name/id pairs)
- Each kind can be at most 1500 bytes.
- Each name can be at most 1500 bytes.
500个字符限制已被转换为1500字节限制。因此,您之前看过500个字符的地方(例如@ ryan的链接问题答案)现在是1500字节。字符串使用UTF-8编码。
重要的是回答您的问题的一些细节:
是否有500个字节/字符可用于密钥名称或其他密钥组件(kind,parent,app-id,...)是否可以从这个数字中扣除?
否,1500字节限制为每个字段。
I am trying to figure out what the maximum length for an AppEngine key name is in the Java API.
This question has been asked in much less depth before:
and received two conflicting answers (with the one that seems less credible to me being the accepted one...)
@ryan was able to provide links to the relevant Python API source in his answer and I've been trying to find something similar in the Java API.
But neither Key.java, nor KeyFactory.java, nor KeyTranslator.java seem to enforce any limits on the name
property of a key. So, if there is a limit, it is implemented elsewhere. KeyTranslator
calls com.google.storage.onestore.v3.OnestoreEntity.Path.Element.setName()
, which could be the place where the limit is implemented, but unfortunately I can't find the source for this class anywhere...
Specifically, I would like to know:
The Datastore implements all of its validation in the backend (because it prevents successful operations in one client to fail in another). Datastore keys have the following restrictions:
The 500 character limit has been converted into a 1500 byte limit. So places you've seen a 500 character limit before (like @ryan's answer in the linked question) are now 1500 bytes. Strings are encoded using UTF-8.
Importantly to answer some specifics from your question:
Are the full 500 bytes/characters available for the name of the key or do the other key-components (kind, parent, app-id, ...) deduct from this number?
No, the 1500 byte limit is per field.
这篇关于了解Java API中AppEngine键名的最大长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!