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

Fix a bug causing query response to create a new stream for each content call #901

Merged
merged 10 commits into from
Oct 22, 2019

Conversation

j82w
Copy link
Contributor

@j82w j82w commented Oct 11, 2019

Pull Request Template

Description

QueryResponse was creating a new stream for every Content call. This causes a big performance hit if Content is called multiple times for example if the user is checking for null. This caches the result and uses the same stream for every content call. It's a memory stream so it does not need to be disposed of.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

…y time content was called on query response.
@j82w j82w added the QUERY label Oct 11, 2019
@j82w j82w self-assigned this Oct 11, 2019
@@ -99,7 +99,7 @@ static class CosmosElementSerializer
/// <param name="resourceType">The resource type</param>
/// <param name="cosmosSerializationOptions">The custom serialization options. This allows custom serialization types like BSON, JSON, or other formats</param>
/// <returns>Returns a memory stream of cosmos elements. By default the memory stream will contain JSON.</returns>
internal static Stream ToStream(
internal static MemoryStream ToStream(
Copy link
Contributor

Choose a reason for hiding this comment

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

I see you have finally come to the dark side on Stream vs MemoryStream and their disposability :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I honestly would like to convert all streams to new Memory objects.

bchong95
bchong95 previously approved these changes Oct 12, 2019
Copy link
Contributor

@bchong95 bchong95 left a comment

Choose a reason for hiding this comment

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

Thanks for making this change :)

Copy link
Member

@kirankumarkolli kirankumarkolli left a comment

Choose a reason for hiding this comment

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

:shipit:

@j82w j82w dismissed stale reviews from kirankumarkolli and bchong95 via 2fab66b October 14, 2019 15:52
@j82w j82w merged commit 3909cd0 into master Oct 22, 2019
@j82w j82w deleted the users/jawilley/query/optimize_stream branch October 22, 2019 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants