CosmosDB中的NULL连续令牌 [英] NULL Continuation Token in CosmosDB
问题描述
我知道,如果延续令牌为null(整个令牌json为null),则这意味着下一个请求中将不再有数据.
I know that if the continuation token is null (the whole token json is null), that means there will be no more data in the next request.
就我而言,我检查了下一页中肯定没有更多数据,并且该令牌应该为空.但它会返回此半"空令牌...
In my case, I checked that there is definitely no more data in the next page, and the token is supposed to be null. But it returns this "half" null token...
令牌看起来像这样:
"{\"令牌\:空,\"范围\:{\"最小\:\" xxxxxxxxxx \,\"最大\:\" xxxxxxxxxx \}}""
"{\"token\":null,\"range\":{\"min\":\"xxxxxxxxxx\",\"max\":\"xxxxxxxxxx\"}}"
仅令牌为空,但min
和max
不为空,这表示什么?换句话说,我应该使用continuation == null
还是continuation.token == null
来查看下一页是否还有更多数据?
Only the token is null, but min
and max
are not null, what does it indicate? In another word, should I use continuation == null
or continuation.token == null
to see whether there is more data in the next page?
推荐答案
对于某些背景上下文:
- Cosmos DB是一个分布式数据库,其中的数据和请求在多个后端服务器之间进行分区(以将存储和吞吐量扩展到单个服务器之外).
- 之所以提出这一点,是因为您可能执行路由到单个分区的查询(通过在查询的WHERE/filter子句中包含分区键),以及执行跨多个分区散开的查询. li>
- 在每个分区的范围内-查询结果以分页方式返回.
- 要了解有关分区的更多信息-请参阅: https://docs.microsoft.com/en-us/azure/cosmos-db/partition-data
- Cosmos DB is a distributed database, in which data and requests are partitioned across multiple backend servers (to scale storage and throughput beyond a single server).
- I bring this up because you may perform queries that are routed to a single partition (by including the partition key in the WHERE / filter clause of your query) - as well as perform queries that fan out across multiple partitions.
- Within the scope of each partition - query results are returned in a paginated manner.
- To learn more about partitioning - see: https://docs.microsoft.com/en-us/azure/cosmos-db/partition-data
您看到的令牌是来自SDK的复合延续令牌,其中包含:
The token you are seeing is a composite continuation token from the SDK that incorporates:
- 来自Cosmos DB后端的信息,以恢复查询执行并检索特定分区上的下一页(令牌字段)
- 后端继续令牌来自哪个分区的信息(范围字段).
您看到的是,对于SDK所查询的特定范围,没有更多结果.
What you are seeing is that for the particular range the SDK is querying there were no more results.
关于SDK为什么不只为延续令牌提供json null值的原因: 该SDK已到达给定分区的末尾,但仍然需要访问其他分区以确保没有更多与您的过滤器匹配的文档/需要返回给客户端.
As for why the SDK does not just give a json null value for the continuation token: The SDK has reached the end for a given partition but mstill needs to visit other partitions to know for sure that there are no more documents that match your filter / need to be returned to the client.
SDK访问完所有分区后,将返回空连续性.
When the SDK is done visiting all partitions it will return a null continuation.
这篇关于CosmosDB中的NULL连续令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!