GAE Datastore 游标是否永久且持久?
Are GAE Datastore cursors permanent and durable?
说 com.google.appengine.api.datastore.Cursor
只是将索引位置存储到 GAE 数据存储索引中是否正确?
游标耐用吗?也就是说,我是否可以永久存储游标并一次又一次地重复使用它,并确定如果它指向索引中的第 5000 个位置,它将永远指向那里?
如果索引缩减到少于 5000 个条目怎么办?使用此游标会导致错误还是 return 什么都没有?
对于更大的索引(比如 100,000 个或更多条目),我可以先为每个 5000 的倍数位置(比如)获取游标,存储它们,然后使用这组游标在 Map/Reduce 方式?
我实际上是在使用 Objectify 而不是直接使用 DS,但是据我所知,这不会影响 Cursors 相对于 Indexes 的属性。
游标仅在进行的原始查询的上下文中才有意义。它们不完全是索引 positions/offsets。来自 Cursors and data updates:
The cursor's position is defined as the location in the result list
after the last result returned. A cursor is not a relative position in
the list (it's not an offset); it's a marker to which Cloud Datastore
can jump when starting an index scan for results. If the results for a
query change between uses of a cursor, the query notices only changes
that occur in results after the cursor. If a new result appears before
the cursor's position for the query, it will not be returned when the
results after the cursor are fetched. Similarly, if an entity is no
longer a result for a query but had appeared before the cursor, the
results that appear after the cursor do not change. If the last result
returned is removed from the result set, the cursor still knows how to
locate the next result.
Cursors are subject to the following limitations:
- A cursor can be used only by the same application that performed the original query, and only to continue the same query. To use the cursor
in a subsequent retrieval operation, you must reconstitute the
original query exactly, including the same entity kind, ancestor
filter, property filters, and sort orders. It is not possible to
retrieve results using a cursor without setting up the same query from
which it was originally generated.
- Because the NOT_EQUAL and IN operators are implemented with multiple queries, queries that use them do not support cursors, nor do
composite queries constructed with the CompositeFilterOperator.or
method.
- Cursors don't always work as expected with a query that uses an inequality filter or a sort order on a property with multiple values.
The de-duplication logic for such multiple-valued properties does not
persist between retrievals, possibly causing the same result to be
returned more than once.
- New App Engine releases might change internal implementation details, invalidating cursors that depend on them. If an application
attempts to use a cursor that is no longer valid, Cloud Datastore
raises an IllegalArgumentException (low-level API),
JDOFatalUserException (JDO), or PersistenceException (JPA).
如果您的数据没有改变,您可能可以 map/reduce 方式使用游标(通过恢复原始查询),包括 pre-acquiring 它们。
说 com.google.appengine.api.datastore.Cursor
只是将索引位置存储到 GAE 数据存储索引中是否正确?
游标耐用吗?也就是说,我是否可以永久存储游标并一次又一次地重复使用它,并确定如果它指向索引中的第 5000 个位置,它将永远指向那里?
如果索引缩减到少于 5000 个条目怎么办?使用此游标会导致错误还是 return 什么都没有?
对于更大的索引(比如 100,000 个或更多条目),我可以先为每个 5000 的倍数位置(比如)获取游标,存储它们,然后使用这组游标在 Map/Reduce 方式?
我实际上是在使用 Objectify 而不是直接使用 DS,但是据我所知,这不会影响 Cursors 相对于 Indexes 的属性。
游标仅在进行的原始查询的上下文中才有意义。它们不完全是索引 positions/offsets。来自 Cursors and data updates:
The cursor's position is defined as the location in the result list after the last result returned. A cursor is not a relative position in the list (it's not an offset); it's a marker to which Cloud Datastore can jump when starting an index scan for results. If the results for a query change between uses of a cursor, the query notices only changes that occur in results after the cursor. If a new result appears before the cursor's position for the query, it will not be returned when the results after the cursor are fetched. Similarly, if an entity is no longer a result for a query but had appeared before the cursor, the results that appear after the cursor do not change. If the last result returned is removed from the result set, the cursor still knows how to locate the next result.
Cursors are subject to the following limitations:
- A cursor can be used only by the same application that performed the original query, and only to continue the same query. To use the cursor in a subsequent retrieval operation, you must reconstitute the original query exactly, including the same entity kind, ancestor filter, property filters, and sort orders. It is not possible to retrieve results using a cursor without setting up the same query from which it was originally generated.
- Because the NOT_EQUAL and IN operators are implemented with multiple queries, queries that use them do not support cursors, nor do composite queries constructed with the CompositeFilterOperator.or method.
- Cursors don't always work as expected with a query that uses an inequality filter or a sort order on a property with multiple values. The de-duplication logic for such multiple-valued properties does not persist between retrievals, possibly causing the same result to be returned more than once.
- New App Engine releases might change internal implementation details, invalidating cursors that depend on them. If an application attempts to use a cursor that is no longer valid, Cloud Datastore raises an IllegalArgumentException (low-level API), JDOFatalUserException (JDO), or PersistenceException (JPA).
如果您的数据没有改变,您可能可以 map/reduce 方式使用游标(通过恢复原始查询),包括 pre-acquiring 它们。