Skip to content

Commit

Permalink
add deserializer2 to have to do both
Browse files Browse the repository at this point in the history
  • Loading branch information
adamhathcock committed Sep 25, 2024
1 parent ad39879 commit cf6228e
Show file tree
Hide file tree
Showing 13 changed files with 477 additions and 86 deletions.
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<PackageVersion Include="Microsoft.CSharp" Version="4.7.0" />
<!-- Keep at 7 for side by side -->
<PackageVersion Include="Microsoft.Data.Sqlite" Version="7.0.7" />
<PackageVersion Include="Microsoft.Extensions.ObjectPool" Version="8.0.8" />
<PackageVersion Include="Microsoft.IO.RecyclableMemoryStream" Version="3.0.1" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="2.2.0" />
Expand All @@ -26,7 +27,6 @@
<PackageVersion Include="Speckle.DoubleNumerics" Version="4.0.1" />
<PackageVersion Include="SimpleExec" Version="12.0.0" />
<PackageVersion Include="Speckle.Objects" Version="3.1.0-dev.109" />
<PackageVersion Include="System.Threading.Tasks.Extensions" Version="4.5.4"/>
<GlobalPackageReference Include="PolySharp" Version="1.14.1" />
<GlobalPackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
<GlobalPackageReference Include="GitVersion.MsBuild" Version="5.12.0" />
Expand Down
43 changes: 24 additions & 19 deletions src/Speckle.Objects/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,14 @@
"System.Runtime": "4.3.0"
}
},
"System.Threading.Tasks.Extensions": {
"type": "Transitive",
"resolved": "4.5.4",
"contentHash": "zteT+G8xuGu6mS+mzDzYXbzS7rd3K6Fjb9RiZlYlJPam2/hU7JCBZBVEcywNuR+oZ1ncTvc/cq0faRr3P01OVg==",
"dependencies": {
"System.Runtime.CompilerServices.Unsafe": "4.5.3"
}
},
"speckle.sdk": {
"type": "Project",
"dependencies": {
Expand All @@ -230,13 +238,13 @@
"Microsoft.Data.Sqlite": "[7.0.7, )",
"Microsoft.Extensions.DependencyInjection.Abstractions": "[2.2.0, )",
"Microsoft.Extensions.Logging": "[2.2.0, )",
"Microsoft.Extensions.ObjectPool": "[8.0.8, )",
"Microsoft.IO.RecyclableMemoryStream": "[3.0.1, )",
"Polly": "[7.2.3, )",
"Polly.Contrib.WaitAndRetry": "[1.1.1, )",
"Polly.Extensions.Http": "[3.0.0, )",
"Speckle.DoubleNumerics": "[4.0.1, )",
"Speckle.Newtonsoft.Json": "[13.0.2, )",
"System.Threading.Tasks.Extensions": "[4.5.4, )"
"Speckle.Newtonsoft.Json": "[13.0.2, )"
}
},
"GraphQL.Client": {
Expand Down Expand Up @@ -284,6 +292,12 @@
"Microsoft.Extensions.Options": "2.2.0"
}
},
"Microsoft.Extensions.ObjectPool": {
"type": "CentralTransitive",
"requested": "[8.0.8, )",
"resolved": "8.0.8",
"contentHash": "wnjTFjEvvSbOs3iMfl6CeJcUgPHZMYUB9uAQbGQGxGwVRl4GydNpMSkVntTzoi7AqQeYumU9yDSNeVbpq+ebow=="
},
"Microsoft.IO.RecyclableMemoryStream": {
"type": "CentralTransitive",
"requested": "[3.0.1, )",
Expand Down Expand Up @@ -325,15 +339,6 @@
"requested": "[13.0.2, )",
"resolved": "13.0.2",
"contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA=="
},
"System.Threading.Tasks.Extensions": {
"type": "CentralTransitive",
"requested": "[4.5.4, )",
"resolved": "4.5.4",
"contentHash": "zteT+G8xuGu6mS+mzDzYXbzS7rd3K6Fjb9RiZlYlJPam2/hU7JCBZBVEcywNuR+oZ1ncTvc/cq0faRr3P01OVg==",
"dependencies": {
"System.Runtime.CompilerServices.Unsafe": "4.5.3"
}
}
},
"net8.0": {
Expand Down Expand Up @@ -510,13 +515,13 @@
"Microsoft.Data.Sqlite": "[7.0.7, )",
"Microsoft.Extensions.DependencyInjection.Abstractions": "[2.2.0, )",
"Microsoft.Extensions.Logging": "[2.2.0, )",
"Microsoft.Extensions.ObjectPool": "[8.0.8, )",
"Microsoft.IO.RecyclableMemoryStream": "[3.0.1, )",
"Polly": "[7.2.3, )",
"Polly.Contrib.WaitAndRetry": "[1.1.1, )",
"Polly.Extensions.Http": "[3.0.0, )",
"Speckle.DoubleNumerics": "[4.0.1, )",
"Speckle.Newtonsoft.Json": "[13.0.2, )",
"System.Threading.Tasks.Extensions": "[4.5.4, )"
"Speckle.Newtonsoft.Json": "[13.0.2, )"
}
},
"GraphQL.Client": {
Expand Down Expand Up @@ -564,6 +569,12 @@
"Microsoft.Extensions.Options": "2.2.0"
}
},
"Microsoft.Extensions.ObjectPool": {
"type": "CentralTransitive",
"requested": "[8.0.8, )",
"resolved": "8.0.8",
"contentHash": "wnjTFjEvvSbOs3iMfl6CeJcUgPHZMYUB9uAQbGQGxGwVRl4GydNpMSkVntTzoi7AqQeYumU9yDSNeVbpq+ebow=="
},
"Microsoft.IO.RecyclableMemoryStream": {
"type": "CentralTransitive",
"requested": "[3.0.1, )",
Expand Down Expand Up @@ -602,12 +613,6 @@
"requested": "[13.0.2, )",
"resolved": "13.0.2",
"contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA=="
},
"System.Threading.Tasks.Extensions": {
"type": "CentralTransitive",
"requested": "[4.5.4, )",
"resolved": "4.5.4",
"contentHash": "zteT+G8xuGu6mS+mzDzYXbzS7rd3K6Fjb9RiZlYlJPam2/hU7JCBZBVEcywNuR+oZ1ncTvc/cq0faRr3P01OVg=="
}
}
}
Expand Down
16 changes: 16 additions & 0 deletions src/Speckle.Sdk/Helpers/SpeckleObjectSerializer2Pool.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Buffers;
using Microsoft.Extensions.ObjectPool;
using Microsoft.IO;
using Speckle.Newtonsoft.Json;
using Speckle.Sdk.Common;
Expand Down Expand Up @@ -38,4 +39,19 @@ private class SerializerPool<T>(ArrayPool<T> pool) : IArrayPool<T>

public void Return(T[]? array) => pool.Return(array.NotNull());
}


public ObjectPool<Dictionary<string, object?>>
DictPool { get; }= new DefaultObjectPoolProvider().Create(new DictPoolPolicy());

private class DictPoolPolicy : PooledObjectPolicy<Dictionary<string, object?>>
{
public override Dictionary<string, object?> Create() => new Dictionary<string, object?>(StringComparer.OrdinalIgnoreCase);

public override bool Return(Dictionary<string, object?> obj)
{
obj.Clear();
return true;
}
}
}
Loading

0 comments on commit cf6228e

Please sign in to comment.