Appengine 数据存储区中的设置操作

发布于 2024-10-18 13:26:17 字数 130 浏览 1 评论 0原文

我认为没有好的方法可以做到这一点,但如果必须这样做,您将如何在 Appengine 的数据存储上实现集合操作?

例如,给定两个整数集合,如何将它们存储在数据存储中以获得相交和除外(A 中不存在于 B 中的所有项目)操作的良好性能?

I assume there's no good way to do so, but if you had to, how would you implement set operations on Appengine's datastore?

For example given two collections of integers, how would you store them in the datastore to get a good performance for intersect and except (all those items in A that are not in B) operations?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

灯下孤影 2024-10-25 13:26:17

数据存储区 API 中没有任何内置设置操作。我看到您有两个选择:

  1. 对于较小的集合(数百个项目)您可能会对 A 组和 B 组进行仅键查询,并在应用程序中进行交集代码。 “小型”的精确定义取决于您的应用程序。

  2. 对于较大的集合(数百万个项目)如果您提前知道需要哪些交集,则可以在每次插入新记录时计算它们。例如,假设您有两个集合 A 和 B,并且您知道您最终会想要查询 (A 与 B 相交)。每当插入 A 时,请检查它是否已在 B 中。如果是,请在某处记录此事实(在单独的实体类型中,或作为 A 或 B 本身的布尔属性)。当然,您还需要为 B 执行此操作。

使用选项 1,您可以拥有许多不同的集合,但受到每个集合大小的限制。

使用选项 2,您可以拥有包含数百万个成员的集合,但如果您拥有多个集合,则尝试定义集合和运算符的所有可能排列将变得难以处理。

There aren't any built in set operations in the datastore API. I see you having two options:

  1. For smallish sets (hundreds of items) You might get away with doing keys-only queries for both set A and set B, and doing the intersection in your application code. The precise definition of "smallish" will depend on your application.

  2. For largish sets (millions of items) If you know ahead of time which intersections you'll want, you can calculate them each time you insert a new record. For example, assume you have two sets A and B, and you know that you'll eventually want to query on (A intersects B). whenever you insert an A, check to see if it is already in B. If it is, record this fact somewhere (either in a separate entity type, or as a boolean property on A or B itself). Of course, you'll need to do this for your B's also.

With option 1, you can have lots of different sets, but are limited by how big each set is.

With option 2, you can have sets with millions of members, but if you have more than a few sets, trying to define all the possible permutations of sets and operators will get unwieldy.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文