Skip to content

Commit

Permalink
Lots of work on the serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
halgari committed Jan 9, 2024
1 parent f40f1df commit 739b332
Show file tree
Hide file tree
Showing 29 changed files with 303 additions and 484 deletions.
14 changes: 0 additions & 14 deletions NexusMods.EventSourcing.sln
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "benchmarks", "benchmarks",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NexusMods.EventSourcing.Benchmarks", "benchmarks\NexusMods.EventSourcing.Benchmarks\NexusMods.EventSourcing.Benchmarks.csproj", "{96977D99-BF4B-4952-B594-6E44CCD826B9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NexusMods.EventSourcing.FasterKV", "src\NexusMods.EventSourcing.FasterKV\NexusMods.EventSourcing.FasterKV.csproj", "{AFB69777-0A6A-4C61-A621-32C894673002}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NexusMods.EventSourcing.RocksDB", "src\NexusMods.EventSourcing.RocksDB\NexusMods.EventSourcing.RocksDB.csproj", "{B8D0772A-FAD1-49AD-A85B-B2B6C5B14420}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NexusMods.EventSourcing.LMDB", "src\NexusMods.EventSourcing.LMDB\NexusMods.EventSourcing.LMDB.csproj", "{4D9C9933-B3F9-4713-B3C7-A7C5E3D47E14}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -53,9 +49,7 @@ Global
{6737673E-5898-42EC-B0B2-60DE2CFFF0AF} = {0377EBE6-F147-4233-86AD-32C821B9567E}
{66DCB10E-1D80-4A83-8380-B2E08BEEE7AE} = {6ED01F9D-5E12-4EB2-9601-64A2ADC719DE}
{96977D99-BF4B-4952-B594-6E44CCD826B9} = {72AFE85F-8C12-436A-894E-638ED2C92A76}
{AFB69777-0A6A-4C61-A621-32C894673002} = {0377EBE6-F147-4233-86AD-32C821B9567E}
{B8D0772A-FAD1-49AD-A85B-B2B6C5B14420} = {0377EBE6-F147-4233-86AD-32C821B9567E}
{4D9C9933-B3F9-4713-B3C7-A7C5E3D47E14} = {0377EBE6-F147-4233-86AD-32C821B9567E}
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A92DED3D-BC67-4E04-9A06-9A1B302B3070}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
Expand All @@ -78,17 +72,9 @@ Global
{96977D99-BF4B-4952-B594-6E44CCD826B9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{96977D99-BF4B-4952-B594-6E44CCD826B9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{96977D99-BF4B-4952-B594-6E44CCD826B9}.Release|Any CPU.Build.0 = Release|Any CPU
{AFB69777-0A6A-4C61-A621-32C894673002}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AFB69777-0A6A-4C61-A621-32C894673002}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AFB69777-0A6A-4C61-A621-32C894673002}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AFB69777-0A6A-4C61-A621-32C894673002}.Release|Any CPU.Build.0 = Release|Any CPU
{B8D0772A-FAD1-49AD-A85B-B2B6C5B14420}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B8D0772A-FAD1-49AD-A85B-B2B6C5B14420}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B8D0772A-FAD1-49AD-A85B-B2B6C5B14420}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B8D0772A-FAD1-49AD-A85B-B2B6C5B14420}.Release|Any CPU.Build.0 = Release|Any CPU
{4D9C9933-B3F9-4713-B3C7-A7C5E3D47E14}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4D9C9933-B3F9-4713-B3C7-A7C5E3D47E14}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4D9C9933-B3F9-4713-B3C7-A7C5E3D47E14}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4D9C9933-B3F9-4713-B3C7-A7C5E3D47E14}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
20 changes: 0 additions & 20 deletions benchmarks/NexusMods.EventSourcing.Benchmarks/ABenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using NexusMods.EventSourcing.Abstractions;
using NexusMods.EventSourcing.FasterKV;
using NexusMods.EventSourcing.RocksDB;
using NexusMods.EventSourcing.TestModel;
using NexusMods.Paths;
using Settings = NexusMods.EventSourcing.FasterKV.Settings;

namespace NexusMods.EventSourcing.Benchmarks;

Expand Down Expand Up @@ -37,22 +33,6 @@ public void MakeStore(Type type)
{
eventStore = new InMemoryEventStore<EventSerializer>(serializer);
}
else if (type == typeof(FasterKVEventStore<EventSerializer>))
{
eventStore = new FasterKVEventStore<EventSerializer>(serializer,
new Settings
{
StorageLocation = FileSystem.Shared.GetKnownPath(KnownPath.EntryDirectory).Combine("FasterKV.EventStore" + Guid.NewGuid())
});
}
else if (type == typeof(RocksDBEventStore<EventSerializer>))
{
eventStore = new RocksDBEventStore<EventSerializer>(serializer,
new RocksDB.Settings
{
StorageLocation = FileSystem.Shared.GetKnownPath(KnownPath.EntryDirectory).Combine("FasterKV.EventStore" + Guid.NewGuid())
});
}
else
{
throw new NotSupportedException($"EventStoreType '{type}' is not supported.");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
using System;
using BenchmarkDotNet.Attributes;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using NexusMods.EventSourcing.Abstractions;
using NexusMods.EventSourcing.FasterKV;
using NexusMods.EventSourcing.RocksDB;
using NexusMods.EventSourcing.TestModel;
using NexusMods.EventSourcing.TestModel.Events;
using NexusMods.EventSourcing.TestModel.Model;
using NexusMods.Paths;
using Settings = NexusMods.EventSourcing.FasterKV.Settings;

namespace NexusMods.EventSourcing.Benchmarks;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

<ItemGroup>
<ProjectReference Include="..\..\src\NexusMods.EventSourcing.Abstractions\NexusMods.EventSourcing.Abstractions.csproj" />
<ProjectReference Include="..\..\src\NexusMods.EventSourcing.FasterKV\NexusMods.EventSourcing.FasterKV.csproj" />
<ProjectReference Include="..\..\src\NexusMods.EventSourcing.RocksDB\NexusMods.EventSourcing.RocksDB.csproj" />
<ProjectReference Include="..\..\src\NexusMods.EventSourcing\NexusMods.EventSourcing.csproj" />
<ProjectReference Include="..\..\tests\NexusMods.EventSourcing.TestModel\NexusMods.EventSourcing.TestModel.csproj" />
Expand Down
2 changes: 0 additions & 2 deletions benchmarks/NexusMods.EventSourcing.Benchmarks/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

using System;
using BenchmarkDotNet.Running;
using NexusMods.EventSourcing;
using NexusMods.EventSourcing.Benchmarks;
using NexusMods.EventSourcing.FasterKV;
using NexusMods.EventSourcing.RocksDB;
using NexusMods.EventSourcing.TestModel;

Expand Down
4 changes: 4 additions & 0 deletions src/NexusMods.EventSourcing.Abstractions/IEventSerializer.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
using System;
using System.Buffers;

namespace NexusMods.EventSourcing.Abstractions;

/// <summary>
/// A serializer for events, is typed to a specific writer type to reduce virtual calls internally
/// </summary>
public interface IEventSerializer
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.IO;

namespace NexusMods.EventSourcing.Abstractions.Serialization;

public interface ISerializer
{
public bool CanSerialize(Type valueType);
public bool TryGetFixedSize(Type valueType, out int size);
}


public interface IFixedSizeSerializer<T> : ISerializer
{
public void Serialize(T value, Span<byte> output);
public T Deserialize(Span<byte> from);
}
119 changes: 0 additions & 119 deletions src/NexusMods.EventSourcing.FasterKV/FasterKVEventStore.cs

This file was deleted.

This file was deleted.

8 changes: 0 additions & 8 deletions src/NexusMods.EventSourcing.FasterKV/Settings.cs

This file was deleted.

Loading

0 comments on commit 739b332

Please sign in to comment.