Skip to content

Commit

Permalink
Restore binary compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
bartelink committed Sep 7, 2024
1 parent b467431 commit 6a4802d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/Equinox.CosmosStore/CosmosStoreSerialization.fs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,23 @@ module JsonElement =
if value.ValueKind = JsonValueKind.Null then value
else value |> toUtf8Bytes |> Deflate.compress |> JsonSerializer.SerializeToElement

[<System.Obsolete "Unused internal type; will be removed in V5">]
type CosmosJsonSerializer(options : JsonSerializerOptions) =
inherit Microsoft.Azure.Cosmos.CosmosSerializer()

override _.FromStream<'T>(stream) =
use _ = stream

if stream.Length = 0L then Unchecked.defaultof<'T>
elif typeof<Stream>.IsAssignableFrom(typeof<'T>) then box stream :?> 'T
else JsonSerializer.Deserialize<'T>(stream, options)

override _.ToStream<'T>(input : 'T) =
let memoryStream = new MemoryStream()
JsonSerializer.Serialize(memoryStream, input, input.GetType(), options)
memoryStream.Position <- 0L
memoryStream :> Stream

/// Manages inflating of the UTF-8 json bytes to make the index record minimal from the perspective of the writer stored proc
/// Only relevant for unfolds in the Tip
type JsonCompressedBase64Converter() =
Expand Down

0 comments on commit 6a4802d

Please sign in to comment.