-
Notifications
You must be signed in to change notification settings - Fork 494
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
Conversation
…y time content was called on query response.
@@ -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( |
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
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.
There was a problem hiding this 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 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
….com/Azure/azure-cosmos-dotnet-v3 into users/jawilley/query/optimize_stream
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.