ndb 事务中访问的最大实体组数的定义?

Definition for the max number of entity groups accessed in an ndb transaction?

来自 What can be done in a transaction(我的重点):

All Datastore operations in a transaction must operate on entities in the same entity group if the transaction is a single group transaction, or on entities in a maximum of twenty-five entity groups if the transaction is a cross-group (XG) transaction.

是否有与我可以在我的 python 应用程序代码中引用的 25 数字相对应的实际定义?或者 API 调用返回它?我宁愿使用一个,如果可用,而不是创建我自己的定义,以防万一 Google 决定在路上改变它...

更新:为了澄清,我说的是 _MAX_EG_PER_TXN 的等价物,我刚刚在 SDK 的 google/appengine/datastore/datastore_stub_util.py 文件的 LiveTxn._GetTracker() 中发现:

      if self._allow_multiple_eg:
        Check(len(self._entity_groups) < _MAX_EG_PER_TXN,
              'operating on too many entity groups in a single transaction.')

作为旁注,如果在引发此类异常时可以以某种方式访问​​来自 self._entity_groups 的跟踪组信息,那么对于调试来说会非常有用。

实体组是顶级实体(没有 parent/ancestor)。将它作为祖先引用的每个子实体都属于同一个实体组。

没有一种程序化的方法可以让 API 获得计数,但您应该能够通过显式设计在自己的代码中确定它:

  • 如果使用顶级实体,交易中的实体不超过 25 个
  • 如果使用子实体,则不超过 25 个不同的父实体

实体组的定义已嵌入到底层 Megastore 存储层中,因此除了我们增加限制或删除限制外,不太可能以任何方式更改。

编辑: FR 记录:https://github.com/GoogleCloudPlatform/google-cloud-datastore/issues/121