Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReadMany: Adds ReadManyItems Api using Query under the covers #2352

Merged
merged 21 commits into from
Apr 16, 2021

Conversation

asketagarwal
Copy link
Contributor

@asketagarwal asketagarwal commented Mar 30, 2021

Sample

Stream:

  IReadOnlyList<(string, PartitionKey)> itemList = new List<(string, PartitionKey)>
  {
       ("Id1", new PartitionKey("pkValue1")),
       ("Id2", new PartitionKey("pkValue2")),
       ("Id3", new PartitionKey("pkValue3"))
  };
   
   using (ResponseMessage responseMessage = await this.Container.ReadManyItemsStreamAsync(itemList))
   {
       using (Stream stream = response.ReadBodyAsync())
       {
           //Read or do other operations with the stream
           using (StreamReader streamReader = new StreamReader(stream))
           {
               string content = streamReader.ReadToEndAsync();
           }
       }
   }

Typed:

   public class ToDoActivity{
       public string id {get; set;}
       public string status {get; set;}
   }
  
   IReadOnlyList<(string, PartitionKey)> itemList = new List<(string, PartitionKey)>
   {
       ("Id1", new PartitionKey("pkValue1")),
       ("Id2", new PartitionKey("pkValue2")),
       ("Id3", new PartitionKey("pkValue3"))
   };
  
  FeedResponse<ToDoActivity> feedResponse = this.Container.ReadManyItemsAsync<ToDoActivity>(itemList);

Closing issues

To automatically close an issue: closes #IssueNumber

@asketagarwal asketagarwal marked this pull request as ready for review April 5, 2021 10:38
@asketagarwal asketagarwal changed the title Draft ReadMany: Adds ReadMany Api ReadMany: Adds ReadManyItems Api using Query under the covers Apr 5, 2021

List<ResponseMessage> pages = new List<ResponseMessage>();
FeedIteratorInternal feedIterator = (FeedIteratorInternal)this.container.GetItemQueryStreamIterator(
new FeedRangeEpk(partitionKeyRange.ToRange()),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is crafty, good one

ealsur
ealsur previously approved these changes Apr 14, 2021
Copy link
Member

@ealsur ealsur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, the only points are around the semaphore wait that Kiran already pointed out

// Only allow 'maxConcurrency' number of queries at a time
await semaphore.WaitAsync();

ITrace childTrace = trace.StartChild("Execute query for a partitionkeyrange", TraceComponent.Query, TraceLevel.Info);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do PKRangeId show up in the trace-data?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, query adds the PKRangeIds

@j82w j82w merged commit 56aa533 into master Apr 16, 2021
@j82w j82w deleted the users/askagarw/readmany branch April 16, 2021 21:19
@j82w j82w mentioned this pull request May 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants