返回Windows Azure表查询的1000多个实体 [英] Return more than 1000 entities of a Windows Azure Table query

查看:74
本文介绍了返回Windows Azure表查询的1000多个实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题正是这个.但是,Azure存储API发生了变化,我可以在这个问题上找到的所有答案都与旧版本有关.在当前的API版本中,如何处理返回1000多个项目的查询?获取少于1000个项目的查询如下所示:

My question is exactly this one. However, the Azure Storage API has changed and all answers I can find for this question deal with the old version. How do handle queries that return more than 1000 items in the current API version? The query fetching less than 1000 items looks like this:

var query = new TableQuery<TermScoreEntity>()
            .Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal,    Name));

var table = _tableClient.GetTableReference("scores");

foreach (var termScoreEntity in table.ExecuteQuery(query))            
    result.Add(termScoreEntity.RowKey, termScoreEntity.Score);

推荐答案

您是否尝试过使用上述代码检索1000多个实体?我认为使用简单的ExecuteQuery就足够了.

Have you tried to retrieve more than 1000 entities with your above code? I think use simple ExecuteQuery is enough.

文档仅表示其对纯REST请求的限制为 1,000 ExecuteQuery API在内部使用此rest api,但会自动剪切为多个请求,每个请求的限制为 1,000 .

The documentation only said it has 1,000 limitation for pure REST requests, the ExecuteQuery API internally use this rest api, but automatically cut to multiple requests, each of them has a limitation of 1,000.

因此,如果您使用.NET软件包,则无需担心此限制,该库已经为您处理了此限制.您可以参考此线程有关更多信息.

So if you use the .NET package, you don't need to worry about this limitation, the library already handle this for you. You can refer to this thread for more information.

以下是Azure SDK中ExecuteQuery的一些关键代码,如果您未指定take编号,您会发现实际上最大数量是9223372036854775807L:

Here is some key code for ExecuteQuery from Azure SDK, you would find actually the max number is 9223372036854775807L if you don't specify the take number:

internal IEnumerable<DynamicTableEntity> Execute(CloudTableClient client, CloudTable table, TableRequestOptions requestOptions, OperationContext operationContext)
{
  CommonUtility.AssertNotNullOrEmpty("tableName", table.Name);
  TableRequestOptions modifiedOptions = TableRequestOptions.ApplyDefaults(requestOptions, client);
  operationContext = operationContext ?? new OperationContext();
  return CommonUtility.LazyEnumerable<DynamicTableEntity>((Func<IContinuationToken, ResultSegment<DynamicTableEntity>>) (continuationToken =>
  {
    TableQuerySegment<DynamicTableEntity> local_0 = this.ExecuteQuerySegmented((TableContinuationToken) continuationToken, client, table, modifiedOptions, operationContext);
    return new ResultSegment<DynamicTableEntity>(local_0.Results)
    {
      ContinuationToken = (IContinuationToken) local_0.ContinuationToken
    };
  }), this.takeCount.HasValue ? (long) this.takeCount.Value : long.MaxValue);
}

这篇关于返回Windows Azure表查询的1000多个实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆