You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you have fields which large values, usually strings or binary data encoded as base64 strings, deserializing these fields might lead to large heap allocations due to reading the entire value into memory. ODataMessageWriter exposes a ReadAsStreamFunc property that the user can assign a delegate that returns true for any property that should be deserialized into a stream. This feature is not documented but is useful work performance-sensitive services working which large payloads.
Basically, there are two steps:
Register a ReadAsStreamFunc on the message writer settings which return true for the properties that you want to stream. ODL will call your function for each property and, if you return true, will enter a new reader state ODataReaderState.Stream.
Handle the ODataReaderState.Stream state by creating stream or text reader, depending on the type of the property, and read the stream.
When you have fields which large values, usually strings or binary data encoded as base64 strings, deserializing these fields might lead to large heap allocations due to reading the entire value into memory.
ODataMessageWriter
exposes aReadAsStreamFunc
property that the user can assign a delegate that returns true for any property that should be deserialized into a stream. This feature is not documented but is useful work performance-sensitive services working which large payloads.Basically, there are two steps:
ReadAsStreamFunc
on the message writer settings which return true for the properties that you want to stream. ODL will call your function for each property and, if you return true, will enter a new reader stateODataReaderState.Stream
.ODataReaderState.Stream
state by creating stream or text reader, depending on the type of the property, and read the stream.Here's a test that demonstrates the feature: https://github.com/OData/odata.net/blob/release-7.x/test/FunctionalTests/Microsoft.OData.Core.Tests/JsonLight/ODataJsonLightReaderTests.cs#L846
We should add a tutorial article this and/or mention it in the performance guidelines
The text was updated successfully, but these errors were encountered: