diff --git a/NexusMods.EventSourcing.sln b/NexusMods.MneumonicDB.sln similarity index 77% rename from NexusMods.EventSourcing.sln rename to NexusMods.MneumonicDB.sln index 5f81e68c..defcaf00 100644 --- a/NexusMods.EventSourcing.sln +++ b/NexusMods.MneumonicDB.sln @@ -23,21 +23,21 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{6ED01F9D tests\SharedUsings.cs = tests\SharedUsings.cs EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NexusMods.EventSourcing", "src\NexusMods.EventSourcing\NexusMods.EventSourcing.csproj", "{A92DED3D-BC67-4E04-9A06-9A1B302B3070}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NexusMods.MneumonicDB", "src\NexusMods.MneumonicDB\NexusMods.MneumonicDB.csproj", "{A92DED3D-BC67-4E04-9A06-9A1B302B3070}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NexusMods.EventSourcing.Abstractions", "src\NexusMods.EventSourcing.Abstractions\NexusMods.EventSourcing.Abstractions.csproj", "{6737673E-5898-42EC-B0B2-60DE2CFFF0AF}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NexusMods.MneumonicDB.Abstractions", "src\NexusMods.MneumonicDB.Abstractions\NexusMods.MneumonicDB.Abstractions.csproj", "{6737673E-5898-42EC-B0B2-60DE2CFFF0AF}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "benchmarks", "benchmarks", "{72AFE85F-8C12-436A-894E-638ED2C92A76}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NexusMods.EventSourcing.TestModel", "tests\NexusMods.EventSourcing.TestModel\NexusMods.EventSourcing.TestModel.csproj", "{EC1570A4-18B9-4A76-84FF-275BAA76A357}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NexusMods.MneumonicDB.TestModel", "tests\NexusMods.MneumonicDB.TestModel\NexusMods.MneumonicDB.TestModel.csproj", "{EC1570A4-18B9-4A76-84FF-275BAA76A357}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NexusMods.EventSourcing.Tests", "tests\NexusMods.EventSourcing.Tests\NexusMods.EventSourcing.Tests.csproj", "{07E2C578-8644-474D-8F07-B25CFEB28408}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NexusMods.MneumonicDB.Tests", "tests\NexusMods.MneumonicDB.Tests\NexusMods.MneumonicDB.Tests.csproj", "{07E2C578-8644-474D-8F07-B25CFEB28408}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NexusMods.EventSourcing.Benchmarks", "benchmarks\NexusMods.EventSourcing.Benchmarks\NexusMods.EventSourcing.Benchmarks.csproj", "{930B3AB7-56EA-48D6-B603-24D79C7DD00A}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NexusMods.MneumonicDB.Benchmarks", "benchmarks\NexusMods.MneumonicDB.Benchmarks\NexusMods.MneumonicDB.Benchmarks.csproj", "{930B3AB7-56EA-48D6-B603-24D79C7DD00A}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NexusMods.EventSourcing.Storage", "src\NexusMods.EventSourcing.Storage\NexusMods.EventSourcing.Storage.csproj", "{73E074F9-250F-4D8A-8038-5B12DB761E98}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NexusMods.MneumonicDB.Storage", "src\NexusMods.MneumonicDB.Storage\NexusMods.MneumonicDB.Storage.csproj", "{73E074F9-250F-4D8A-8038-5B12DB761E98}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NexusMods.EventSourcing.Storage.Tests", "tests\NexusMods.EventSourcing.Storage.Tests\NexusMods.EventSourcing.Storage.Tests.csproj", "{33A3DA79-D3FD-46DC-8D14-82E23D5B608D}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NexusMods.MneumonicDB.Storage.Tests", "tests\NexusMods.MneumonicDB.Storage.Tests\NexusMods.MneumonicDB.Storage.Tests.csproj", "{33A3DA79-D3FD-46DC-8D14-82E23D5B608D}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OneBillionDatomsTest", "benchmarks\OneBillionDatomsTest\OneBillionDatomsTest.csproj", "{EA397BAE-9726-486F-BC9B-87BD86DF157F}" EndProject diff --git a/NexusMods.EventSourcing.sln.DotSettings b/NexusMods.MneumonicDB.sln.DotSettings similarity index 100% rename from NexusMods.EventSourcing.sln.DotSettings rename to NexusMods.MneumonicDB.sln.DotSettings diff --git a/README.md b/README.md index 01c7ee81..ece122b4 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,14 @@ -# NexusMods.EventSourcing +# NexusMods.MnemonicDB -EventSourcing and CQRS library for .NET. This library is designed for single process multi threaded applications, and -provides -extremely high performance event sourcing and CQRS capabilities. The current datastore is based on RocksDB, but the -interface is -designed to be easily swapped out for other storage systems. +This is a simple, fast, and type-safe in-process temporal database for .NET applications. It borrows heavily from +[Datomic](https://www.datomic.com/), [Datahike](https://github.com/replikativ/datahike) and heavily leverages +[RocksDB](https://rocksdb.org/) for storage. Performance wise, on modern desktop hardware it can write roughly +400K tuples per second sustained, and read roughly 1M tuples per second sustained, this includes the overhead +of maintaining the indexes. ## Documentation -The full docs can be found [here](https://nexus-mods.github.io/NexusMods.EventSourcing/) +The full docs can be found [here](https://nexus-mods.github.io/NexusMods.MnemonicDB/) ## License diff --git a/benchmarks/NexusMods.EventSourcing.Benchmarks/Benchmarks/ABenchmark.cs b/benchmarks/NexusMods.MneumonicDB.Benchmarks/Benchmarks/ABenchmark.cs similarity index 77% rename from benchmarks/NexusMods.EventSourcing.Benchmarks/Benchmarks/ABenchmark.cs rename to benchmarks/NexusMods.MneumonicDB.Benchmarks/Benchmarks/ABenchmark.cs index bda3b1f5..84075197 100644 --- a/benchmarks/NexusMods.EventSourcing.Benchmarks/Benchmarks/ABenchmark.cs +++ b/benchmarks/NexusMods.MneumonicDB.Benchmarks/Benchmarks/ABenchmark.cs @@ -2,13 +2,13 @@ using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; -using NexusMods.EventSourcing.Abstractions; -using NexusMods.EventSourcing.Storage; -using NexusMods.EventSourcing.TestModel; +using NexusMods.MneumonicDB.Abstractions; +using NexusMods.MneumonicDB.Storage; +using NexusMods.MneumonicDB.TestModel; using NexusMods.Paths; using Xunit; -namespace NexusMods.EventSourcing.Benchmarks.Benchmarks; +namespace NexusMods.MneumonicDB.Benchmarks.Benchmarks; public class ABenchmark : IAsyncLifetime { @@ -22,9 +22,9 @@ public async Task InitializeAsync() var builder = Host.CreateDefaultBuilder() .ConfigureServices(services => { - services.AddEventSourcingStorage() + services.AddMneumonicDBStorage() .AddRocksDbBackend() - .AddEventSourcing() + .AddMneumonicDB() .AddTestModel() .AddDatomStoreSettings(new DatomStoreSettings { @@ -33,7 +33,7 @@ public async Task InitializeAsync() }); _host = builder.Build(); - Connection = await EventSourcing.Connection.Start(Services); + Connection = await MneumonicDB.Connection.Start(Services); } public async Task DisposeAsync() diff --git a/benchmarks/NexusMods.EventSourcing.Benchmarks/Benchmarks/ReadTests.cs b/benchmarks/NexusMods.MneumonicDB.Benchmarks/Benchmarks/ReadTests.cs similarity index 64% rename from benchmarks/NexusMods.EventSourcing.Benchmarks/Benchmarks/ReadTests.cs rename to benchmarks/NexusMods.MneumonicDB.Benchmarks/Benchmarks/ReadTests.cs index 5c134666..2a5fb1e2 100644 --- a/benchmarks/NexusMods.EventSourcing.Benchmarks/Benchmarks/ReadTests.cs +++ b/benchmarks/NexusMods.MneumonicDB.Benchmarks/Benchmarks/ReadTests.cs @@ -1,13 +1,16 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using BenchmarkDotNet.Attributes; -using NexusMods.EventSourcing.Abstractions; -using NexusMods.EventSourcing.TestModel.Model; +using NexusMods.MneumonicDB.Abstractions; +using NexusMods.MneumonicDB.TestModel.ComplexModel.ReadModels; +using NexusMods.Hashing.xxHash64; +using NexusMods.Paths; // ReSharper disable MemberCanBePrivate.Global -namespace NexusMods.EventSourcing.Benchmarks.Benchmarks; +namespace NexusMods.MneumonicDB.Benchmarks.Benchmarks; [MemoryDiagnoser] public class ReadTests : ABenchmark @@ -25,13 +28,22 @@ public async Task Setup() await InitializeAsync(); var tx = Connection.BeginTransaction(); var entityIds = new List(); + + var modId = new Mod(tx) + { + Name = "TestMod", + Source = new Uri("https://www.nexusmods.com"), + LoadoutId = EntityId.From(1) + }; + for (var i = 0; i < Count; i++) { var file = new File(tx) { - Hash = (ulong)i, + Hash = Hash.From((ulong)i), Path = $"C:\\test_{i}.txt", - Index = (ulong)i + Size = Size.From((ulong)i), + ModId = modId.Id, }; entityIds.Add(file.Id); } @@ -49,7 +61,7 @@ public async Task Setup() public ulong ReadFiles() { ulong sum = 0; - sum += _db.Get(_readId).Index; + sum += _db.Get(_readId).Size.Value; return sum; } @@ -57,6 +69,6 @@ public ulong ReadFiles() public long ReadAll() { return _db.Get(_entityIds) - .Sum(e => (long)e.Index); + .Sum(e => (long)e.Size.Value); } } diff --git a/benchmarks/NexusMods.EventSourcing.Benchmarks/Benchmarks/WriteTests.cs b/benchmarks/NexusMods.MneumonicDB.Benchmarks/Benchmarks/WriteTests.cs similarity index 94% rename from benchmarks/NexusMods.EventSourcing.Benchmarks/Benchmarks/WriteTests.cs rename to benchmarks/NexusMods.MneumonicDB.Benchmarks/Benchmarks/WriteTests.cs index 956e5f22..3967e007 100644 --- a/benchmarks/NexusMods.EventSourcing.Benchmarks/Benchmarks/WriteTests.cs +++ b/benchmarks/NexusMods.MneumonicDB.Benchmarks/Benchmarks/WriteTests.cs @@ -1,4 +1,4 @@ -namespace NexusMods.EventSourcing.Benchmarks.Benchmarks; +namespace NexusMods.MneumonicDB.Benchmarks.Benchmarks; public class WriteTests { diff --git a/benchmarks/NexusMods.EventSourcing.Benchmarks/NexusMods.EventSourcing.Benchmarks.csproj b/benchmarks/NexusMods.MneumonicDB.Benchmarks/NexusMods.MneumonicDB.Benchmarks.csproj similarity index 61% rename from benchmarks/NexusMods.EventSourcing.Benchmarks/NexusMods.EventSourcing.Benchmarks.csproj rename to benchmarks/NexusMods.MneumonicDB.Benchmarks/NexusMods.MneumonicDB.Benchmarks.csproj index 9b9983aa..1b6044cd 100644 --- a/benchmarks/NexusMods.EventSourcing.Benchmarks/NexusMods.EventSourcing.Benchmarks.csproj +++ b/benchmarks/NexusMods.MneumonicDB.Benchmarks/NexusMods.MneumonicDB.Benchmarks.csproj @@ -14,9 +14,9 @@ - - - + + + diff --git a/benchmarks/NexusMods.EventSourcing.Benchmarks/Program.cs b/benchmarks/NexusMods.MneumonicDB.Benchmarks/Program.cs similarity index 89% rename from benchmarks/NexusMods.EventSourcing.Benchmarks/Program.cs rename to benchmarks/NexusMods.MneumonicDB.Benchmarks/Program.cs index 55802334..89cb6e07 100644 --- a/benchmarks/NexusMods.EventSourcing.Benchmarks/Program.cs +++ b/benchmarks/NexusMods.MneumonicDB.Benchmarks/Program.cs @@ -2,7 +2,7 @@ using System; using System.Diagnostics; -using NexusMods.EventSourcing.Benchmarks.Benchmarks; +using NexusMods.MneumonicDB.Benchmarks.Benchmarks; //#if DEBUG diff --git a/benchmarks/OneBillionDatomsTest/OneBillionDatomsTest.csproj b/benchmarks/OneBillionDatomsTest/OneBillionDatomsTest.csproj index 6c6f46d0..90f692b9 100644 --- a/benchmarks/OneBillionDatomsTest/OneBillionDatomsTest.csproj +++ b/benchmarks/OneBillionDatomsTest/OneBillionDatomsTest.csproj @@ -13,10 +13,10 @@ - - - - + + + + diff --git a/benchmarks/OneBillionDatomsTest/Program.cs b/benchmarks/OneBillionDatomsTest/Program.cs index 221c3b6e..a153457c 100644 --- a/benchmarks/OneBillionDatomsTest/Program.cs +++ b/benchmarks/OneBillionDatomsTest/Program.cs @@ -1,20 +1,26 @@ using System; +using System.Collections.Generic; using System.Diagnostics; +using System.Linq; +using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; -using NexusMods.EventSourcing; -using NexusMods.EventSourcing.Abstractions; -using NexusMods.EventSourcing.Storage; -using NexusMods.EventSourcing.TestModel; -using NexusMods.EventSourcing.TestModel.Model; +using NexusMods.MneumonicDB; +using NexusMods.MneumonicDB.Abstractions; +using NexusMods.MneumonicDB.Abstractions.DatomIterators; +using NexusMods.MneumonicDB.Storage; +using NexusMods.MneumonicDB.TestModel; +using NexusMods.MneumonicDB.TestModel.ComplexModel.Attributes; +using NexusMods.MneumonicDB.TestModel.ComplexModel.ReadModels; +using NexusMods.Hashing.xxHash64; using NexusMods.Paths; var host = Host.CreateDefaultBuilder() .ConfigureServices(s => { - s.AddEventSourcingStorage() - .AddEventSourcing() + s.AddMneumonicDBStorage() + .AddMneumonicDB() .AddRocksDbBackend() .AddTestModel() .AddSingleton(_ => new DatomStoreSettings @@ -48,6 +54,45 @@ var globalSw = Stopwatch.StartNew(); ulong fileNumber = 0; var lastPrint = DateTime.UtcNow; + +async Task<(TimeSpan Time, int loaded)> ReadCheckpoint(IDb db) +{ + var tasks = new List>(); + + + for (int i = 0; i < 4; i++) + { + var task = Task.Run(() => + { + var sw = Stopwatch.StartNew(); + using var iterator = db.Iterate(IndexType.TxLog); + + var count = 0; + var scanned = 0; + foreach (var itm in iterator.SeekLast().Reverse().Resolve()) + { + if (count == 1024 * 128) break; + if (itm is FileAttributes.Hash.ReadDatom hashDatom) + { + var file = db.Get(hashDatom.E); + count++; + } + + scanned++; + } + + return (sw.Elapsed, (count * 4) + scanned); + }); + tasks.Add(task); + } + + var results = await Task.WhenAll(tasks); + + return (results.Max(r => r.Time), results.Sum(r => r.loaded)); + +} + +var checkPointTask = ReadCheckpoint(connection.Db); for (ulong i = 0; i < batches; i++) { var tx = connection.BeginTransaction(); @@ -55,11 +100,12 @@ for (var j = 0; j < (int)batchSize; j++) { fileNumber += 1; - var file = new File(tx) + var _ = new File(tx) { Path = $"c:\\test_{i}_{j}.txt", - Hash = fileNumber, - Index = entityCount - fileNumber + Hash = Hash.From(fileNumber % 0xFFFF), + Size = Size.From(fileNumber), + ModId = EntityId.From(1) }; } @@ -69,10 +115,14 @@ if (DateTime.UtcNow - lastPrint > TimeSpan.FromSeconds(1)) { + var checkpointStatus = await checkPointTask; var estimatedRemaining = (batches - i) * (globalSw.Elapsed.TotalSeconds / i); Console.WriteLine( $"({i}/{batches}) Elapsed: {globalSw.Elapsed} - Datoms per second: {perSecond} - ETA: {TimeSpan.FromSeconds(estimatedRemaining)}"); + Console.WriteLine(" - Read Checkpoint: " + checkpointStatus.loaded + " datoms in " + checkpointStatus.Time.Milliseconds + "ms"); lastPrint = DateTime.UtcNow; + + checkPointTask = ReadCheckpoint(connection.Db); } } diff --git a/docs/IndexFormat.md b/docs/IndexFormat.md index d339247b..3caf314f 100644 --- a/docs/IndexFormat.md +++ b/docs/IndexFormat.md @@ -5,150 +5,80 @@ hide: ## Index Format -The index format of the framework will look familiar to those who have used Datomic in the past, although there's some very critical - -In general data flows through 4 core indexes: - -* TxIndex - A sorted list of all transactions, this isn't a index per-se, but it is the primary source of truth. It's key-value lookup where -the key is the transaction id and the value a block of all the tuples in that transaction. The storage system is expected to be able to -store new blocks, get a block by id, and to get the highest id in the store. Based on this the system can build the rest of indexes. -* InMemory - This is a single block of all the tuples that have been added to the TxLog but not yet been merged with the other indexes -* Historical index - This is a large index of every tuple that has ever been added to the system. Naturally this means that a search for a value -asof a given T value can be done by searching for a matching tuple with a tx value equal to or less than a given T. This means that -at times finding the recent value may be O(n) where n is the number of transactions for the given attribute. -* Current index - This index is a sorted list of all the current value of every attribute for every entity. There isn't historical data here, -but the Txvalue is recorded for each tuple so that queries can filter out values that are newer than the query time. This index is built -under the assumption that the vast number of queries will be on a relatively recent basis time. - -When we say the tuples are "sorted" the next question is "sorted by what?" The answer is that the InMemory and Historical and current -indexes are sorted in several ways, so that queries can efficently find the data they need. - -* EATV - This index is used to find all the tuples for a given entity. Most often used for questions of "what is the state of this entity?" -* AETV - This index is used to find all the tiples for a given attribute. Most often used for questions of "what entities have this attribute?" -* AVTE - This index is used to find all the entities for a given attribute and value. Most often used for questions of "what entities have this attribute with this value?", this index -can be expensive to maintain, so it is opt-in, but enabled by default for attributes where the type of the attribute is a reference to another entity. -* VATE - This index is used to find all the attributes or entities that have a given value. Most often used for backreference queries such as "what entities point to this entity?", to save space -this index is also opt-in, but enabled by default for attributes where the type of the attribute is a reference to another entity. - -## Data Structure - -The basic storage system of the the system is a "block" of data. This block is a sorted set -of tuples. Taking a page out of the book of DuckDB, the tuples themselves are stored as a set -of columns. This means that all the entity Ids are located in memory together, all the attribute -ids together, etc. Values are heterogenous, so take a special type of column, a "blob" column. This -column itself contains two 32bit integer columns (offset and size) and a chunk of memory for value storage. - -Taking another page from DuckDB's book, the rather large memory requirements of this storage format (32 bytes minimum -for a tuple), we can perform lightweight compression on this data. Chances are that a given block will only contain -a few attributes, or have data from a few Entity IDs, also that's likely that this data may be sorted by some of these -values, so many of the values may be repeated or close in value. Armed this we can "pack" these columns into -constants, dictionaries or min-max encoding. - -Data then exists in two states: appendable and packed. As one would expect, appendable data can be modified -while packed blocks have been compressed with lightweight compression and must be unpacked before they can be -modified. In practice these blocks can never be modified, and instead a new appendable block is created by ingesting -the data from a packed block, and from there the data is sorted, appended, and then repacked. - -As one would expect, this data exists in a linear format, and so is prone to many O(n) complexity issues as well -as requiring ever increasing amounts of memory. Thus at some point, blocks are split and formed into a tree. - - -## Index tree -When we say "index" what we often mean (in the case of the historical and current index) is that the data is broken -up into multiple blocks of a given size (often something like 8k tuples) and organized into a B+ tree. - -In this index format, the leaf nodes are all standard packed datablocks (linear arrays of tuples stored in columns). -Interestingly, the index branches are also packed data blocks but with a different meaning to the data stored them, -and with extra columns. These nodes are called "index nodes". - -The index nodes all contain the last tuple of each child node, and sort these tuples in the same format as the children. The -nodes then also contain 3 extra columns: - -* child count - a count of the total number of datoms in the child node -* child node count - a count of the number of child nodes in the child node -* storage reference id - a unique id for the child node. - -Since index nodes act like data nodes, many of the algorithms used for data nodes also apply to index nodes. For example, -a binary search of the contents of the index node will tell you what child node to look in for a specific tuple. - -Index nodes are also packed, and follow the same concept of needing to be "unpacked" before they can be modified. In practice -this isn't an issue as the nodes are only updated when the in-memory index reaches a certain size. Index nodes also split -after a certain branch size, often 8k tuples. Currently the deletion of data is not supported by this system, so the chances -of a node needing to be rebalanced is low. Instead nodes are expanded until they need to be split, then they the split nodes are -merged into the parent, and when the parent reaches a given size it is also split and merged into its parent. - -Since the overall branching factor is extremely high, a 8k branching factor means that 549 billion tuples -can exist in a single index before the depth increases above 3 nodes. This is extremely high and not supported, as the resulting -dataset would likely be over 18TB. - -These nodes are all immutable after being packed, so the common update format for the index is to perform a sorted merge of an -index and a new appendable node of data. This results in a new index root node, and future queries can point to this node. - -Note: since the current index is filtered by T, previous versions of indexes are never read again after the last query against -a given version of the index has finished. Thus old blocks are free to be GC'd by a background process has proven no reader -is reading from them. This garbage collection process can easily be made non-blocking and lazy and need not run often. - -## Vectorized Querying -A simplistic way to query this data is to leverage the fact that every column and every block supports a indexed value lookup. -Blocks report their total number of datoms, and getting the datom at a given index is O(log n) where n is so low that it approaches -the performance of O(1). This means that getting a datom at a given index is very fast, and due to that we can easily binary search -an index to get to a specific datom, from there we can increment and decrement the index to get datoms around the target datom. - -However, in practice this involves a lot of random access for data that we likely will want to bulk process. Thus we take yet another -page from DuckDB's book and support vectorized iterators. - -In this approach, data is iterated over in small compact chunks. Think of these chunks as subsections of the column's data stored -as columns themselves, but this time they are always unpacked. This is also useful for columns that may store data in a binary packed -or dictionary format, as it can allow us to bulk process column data and keep more state on the stack during the unpacking process. - -A nice side effect of using chunked iterators is that it allows us to leverage vector processing (and perhaps GPU processing) to -process these queries. For example, when looking for all datoms with a given entity ID, we can look at a single array of ulongs and -filter out the ones that do not match. In order to perform this filtering in a non-branching manner, we use another feature -from DuckDB and store a "mask" of live datoms as a small array of ulongs. If a given filter or processor of the chunk wants to mark -the datom as not matching, it simply sets the bit for that column to 0. Future processors can use this mask to either reduce work -performed, or to filter out results of processing. With all this in play a modern processor can easily process several datoms -at a time, without the need to perform conditional checks thanks to vectorized operations. - -The number of datoms in a chunk is a tradeoff between the amount of memory used and the amount of work that can be done in a single -step of the pipeline. DuckDB uses a chunk size of 2048, however it's likely that the data used in a desktop application like this will -likely be much smaller, so perhaps a chunk size of 64 (so that the flags all fit in a single ulong) or 128 is more appropriate as in that -case a single comparison of a 64 bit int can check all the null flags in a single step. This, naturally is a tradeoff between -the reduction in number of calls between the unpacking code and the amount of memory used. 4x ulongs (256 bits or AVX2 register size) -would result in a chunk size of 256 datoms, which may be a good tradeoff between the two. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +The index format of the framework will look familiar to those who have used similar databases like Datomic or Datahike. +Since MneumonicDB is based on RocksDB, most of the complexity of handling the index is abstracted away. Values are stored +in several "Column Families" which are RocksDB's way of storing data in separate files or partitions. The tuples are stored +exclusively in the key of the store, and the value is always empty. All the indexes store exactly the same format of key +layouts, and only the sorting logic of each index is different. + +### Key Format + +Keys are stored as a 16byte `KeyPrefix` followed by an arbitrarily sized value blob. Since RocksDB tracks the length of +the keys, there is no need to store the length of the value in the key. The `KeyPrefix` is a bitpacked value that contains +the following information: + +``` + [AttributeId: 2 bytes] + [TxId: 6 bytes] + [Entity Partition Id : 1 byte] + [EntityID : 6 bytes] + [IsRetract: 1byte] +``` + +The side effect of this bit packing is that the database can ever only have 64K attribute definitions, and roughly 180 +quintillion entities and transactions, these are considered to be reasonable limits for the database. + +### Indexes +There are 5 categories of indexes that are maintained in the database: + +* TxLog : this contains a sorted set of all data in the database sorted by transaction id. This allows for queries to +replay the database as of a specific transaction id, or to ask "what changed in this transaction". +* EAVT : this contains all datoms sorted primarily by Entity, then Attribute, then Value, then Transaction. This is most +commonly used for queries that ask "what is the value of this attribute for this entity", and is used to load an entity. +* AEVT : this contains all datoms sorted primarily by Attribute, then Entity, then Value, then Transaction. This is most +commonly used to look up all entities that have a specific attribute value. For example, querying for all the users in +the database. +* VAET : this contains datoms where the value is an EntityID also known as a reference. This index is used to look up +all the references to a specific entity. For example, querying for all the comments on a blog post. +* AVET : this contains datoms that have `isIndexed` set to true, and is the "reverse index". This is used to look up all +entities that have a specific attribute. For example, querying for all the users with a given email address. + +Since MnemonicDB is a temporal database, the last four indexes are maintained in a `current` index. When a value is +overwritten, it is evicted (deleted) from the `current` index and added to the historical index. This allows for fast +queries for the most recent data, and slower queries for historical data (as they must scan over all past values). + +When a transaction is committed, the system creates a snapshot of the underlying storage. This snapshot is then used to +keep the state of the database live as long as any part of the application has a reference to it. After the snapshot is +reclaimed, future queries for that specific TxId will need to use the historical indexes to find the data. While this sounds +like a serious tradeoff, chances are that an application will dereference the database, use a snapshot, then go back and +get an updated copy of the database, releasing the old snapshot. Going backwards in time is a rare operation, but supported. + +Attributes can be labeled as `noHistory`, in which case, when they are evicted from the `current` index, they are simply +discarded. This is useful for attributes that are not important to keep a history of, but have a high rate of change, such +as a "last seen" timestamp. + +### Why is history slower? + +The historical indexes are slower because they contain stale data. When queried, the historical indexes must scan over all +past values for a given entity or attribute pair, and select the maximum value. This then means that the complexity of these +operations are O(n) where n is the number of values for a given entity or attribute pair. The current indexes are O(1) as they +only need to look up the value in the index. In practice, loading datoms is extremely fast, and the overhead of scanning the +historical indexes is low, but it is a consideration when designing an application. + +### Making changes to the schema + +New attributes can be added to the database at any time, and the database will automatically start indexing them. In addition, +old attributes need not remain in the C# codebase, MneumonicDB will simply skip over them when loading values. So as much +as possible, try to make additive changes to the schema, and avoid changing attributes. Attributes are named after the classes +by convention, but this is not a requirement, and the database will work just fine if you change the class name of an attribute, +as long as the attribute's unique ID remains the same. Thus deprecated attributes can be moved to a `Deprecated` namespace, and +left to sit. + +### Migrations + +Migrations are not yet implemented, but the idea is fairly simple, a new database is created, and the TxLog of the source +is replayed into the target with some sort of transformation process happening on the way. This is a future feature, and +planned to be implemented soon. diff --git a/docs/index.md b/docs/index.md index 118a2c3f..a9211c8e 100644 --- a/docs/index.md +++ b/docs/index.md @@ -4,89 +4,162 @@ hide: ---
-

The Nexus Event Sourcing Framework

+

MneumonicDB a in-process temporal database for .NET



- Event Sourcing for single process desktop applications.
- GitHub Workflow Status + GitHub Workflow Status
## About -Event Sourcing, and more commonly CQRS, are patterns that are becoming more and more popular in the software industry especially -for large scale distributed systems. They are also patterns that fit well into a immutable state systems, or systems that wish -to track modifications to data and provide ways of auditing or undoing changes. - -The term "Event Sourcing" was coined by [Martin Fowler in 2005](https://martinfowler.com/eaaDev/EventSourcing.html), and is described as: - -!!! info "Event Sourcing ensures that all changes to application state are stored as a sequence of events. Not just can we -query these events, we can also use the event log to reconstruct past states, and as a foundation to automatically adjust the state to cope with retroactive changes." - -These features solve several problems we experience in the Nexus Mods App, namely: +Built for the NexusMods.App project, MneumonicDB is a tuple oriented, typesafe, in-process temporal database for .NET +applications. It supports a pluggable storage and value model leverages [RocksDB](https://rocksdb.org/) by default. +Many similarities can be seen in this project to [Datomic](https://www.datomic.com/), [Datahike](https://github.com/replikativ/datahike), +and [XTDB](https://xtdb.com/) + +by default, but has a pluggable storage layer. + +### Definitions +The above description is a bit of a mouthful, so let's break it down a bit. + +* **Tuple Oriented**: Data is stored in the database in the format of `[Entity, Attribute, Value, Transaction, Assert/Retract]` tuples. +thus it is not a traditional table based database like SQL, but more like a RDF or graph database. To create what is +traditionally thought of as a table, you would query for all tuples with the same entity. +* **Typesafe**: The database is designed to be used with C# and is strongly typed. As much as possible, allocations are +removed from the inner parts of the application, and the database is designed to be used with value types. These values +are processed and sorted via C# code, so the database supports arbitrary types, as long as they can be compared. +* **In-process**: The database is designed to be used in the same process as the application, and is not a separate service, +and does not support multiple processes accessing the same database at the same time. Multiple threads within the same +process can access the database concurrently without issue. +* **Temporal**: The database supports the concept of time, and can be queried as of a specific time, or for all values +for a given entity, or attribute over type. In many ways this provides an audit log of all changes to the database. In +spite of this feature, an index is maintained for the "Current" view of the database so that most queries are fast, and +yet the full history is available. +* **Pluggable Storage**: The database is designed to support multiple storage backends, and the default storage backend is +RocksDB. However, the storage layer is abstracted, and any system that supports a sorted set of keys, iteration (forward +and backward), and atomic updates across multiple keys can be used. Currently, the only other storage backend is a in-memory +backed based on Microsoft's `System.Collections.Immutable` library which contains the `ImmutableSortedSet` class. + +## Datamodel +At the core of the application is a set of attribute definitions. These are defined in C# as implementations of the `IAttribute` +class. Most often these are defined as classes inside a containing class to better group them by name. Here is an example +of a simple set of attributes: + +```csharp +public class FileAttributes +{ + /// + /// The path of the file + /// + public class Path() : ScalarAttribute(isIndexed: true); + + /// + /// The size of the file + /// + public class Size : ScalarAttribute; + + /// + /// The hashcode of the file + /// + public class Hash() : ScalarAttribute(isIndexed: true); + + /// + /// The mod this file belongs to + /// + public class ModId : ScalarAttribute; +} +``` -* A strongly typed data model that can be quickly loaded from disk -* A way to track changes to the data model -* A way to undo changes to the data model -* A way to adapt the data model to changes in the data model, if a property changes from a string to a number, how do - we adapt the data model to this change? +A few interesting features of the above code: -!!! tip "The concept of event sourcing is simple, given a set of events, the state of the system is then `aggregate({}, events) -> state`. All the state is the result of applying all the events in order" +* Each attribute is defined as a class, this is so the class can later be used in C# attributes such as `[From]` +for defining read models (more on this below). +* Attributes can be indexed, this is a hint to the database that this attribute will be queried on often, and it should +be included in the secondary or reverse index. In the above example all the entities where `Hash` is `X` can be found +very quickly, via a single lookup and scan of an index. +* Attributes define a value type. Also in the app, should be a `IValueSerializer` for each of these value types. But +this system is open-ended. The serializer is used to convert the value to and from a byte array for storage in the database, +and to perform comparisons on the values, so longs need not be stored in BigEndian order as they are not compared as byte +arrays, but as longs. In addition, arbitrary types can be stored in the database, so long as they can be compared in their +C# form. -What is interesting to note is that this pattern is very abstract, leaving a lot of room for optimization and customization. One such -customization is the idea of CQRS, or Command Query Responsibility Segregation. This is the idea that the system should be split into -two parts, the command side and the query side. The command side is responsible for handling commands, or actions that change the state -of the system. The query side is responsible for handling queries, or actions that read the state of the system. This pattern further -aligns with the idea of immutability, as the command side is the only side that can change the state of the system, and the query side -can be optimized for reading. -The overall architecture of a CQRS system is something like this: +Once the attributes are defined, they must be registered with the DI container. -```mermaid -flowchart TD - B(Event Log) --> C[Event Processor] - C --> D[Read Data Model] - D --> E[Application] - E --> | Command/Event |B +```csharp +services.AddAttributeCollection(); ``` -* Events are sent into the Event Log, this storage is considered the "source of truth" for the system -* An event processor takes these events and uses them to manipulate the read data model -* The application then reads from the read data model -* The application can also send commands to the event log to modify the model +While attributes can be registered individually, it is recommended to group them into classes as shown above, and register +them at once via the `AddAttributeCollection` method. + +## Read Models + +For ease of use, MnemonicDB supports the concept of read models. These are classes that define a set of attributes that +are commonly queried together. There is nothing that requires these attributes to always be grouped in the same way, and +users are encouraged to define read models that make sense for their application. + +```csharp +public class File(ITransaction? tx) : AReadModel(tx) +{ + [From] + public required RelativePath Name { get; set; } + + [From] + public required Size Size { get; set; } + + [From] + public required Hash Hash { get; set; } + + [From] + public required EntityId ModId { get; init; } + + public static File Create(ITransaction tx, string name, Mod mod, Size size, Hash hash) + { + return new File(tx) + { + Name = name, + Size = size, + Hash = hash, + ModId = mod.Id + }; + } +} +``` -!!! tip "The event log is the source of truth for the system, and the read data model is a projection of the event log. The read data model can be rebuilt at any time by replaying the events in the event log" +The above class defines a read model for a file. It is a simple class with properties that are decorated with the `[From]` +attribute. This attribute is used to tell the database that when this read model is queried, it should include the values +for the given DB attributes. The `ITransaction` parameter is used during writes to the database, and can be ignored for now. -## Nexus Event Sourcing Framework +Now that the read model is defined, it can be used to query the database. -A major issue in event sourcing systems is allowing for the system to adapt to changes in the model over time, while the concept of events mutating a state is simple, -the actual implementation can be quite complex. This framework reworks many aspects of the Event Sourcing model in order to present an interface that -is easier to maintain, adapt and extend in extension code. +```csharp + var file = db.Get(eId); -This framework takes heavy inspiration from [Datomic](https://docs.datomic.com/pro/index.html), an immutable, tuple oriented, single writer, parallel reader database system. Unfortunately, -Datomic is not open source, is written in Java, and not designed for a single process desktop application. However the information available about -the database is very insightful and we are leveraging many aspects of its design in our framework. + Console.WriteLine($"File: {file.Name} Size: {file.Size} Hash: {file.Hash}"); +``` -!!!info - While the Nexus Event Sourcing framework takes inspiration from Datomic, and although one of the authors (halgari) used to work for Cognitect (the company behind Datomic at the time), -this project is a 100% clean room implementation and does not contain any code from Datomic, nor have any of its authors ever seen the source code of Datomic. The main distinctions between -the two is that Datomic is primarilly focused on a distributed system, and the Nexus Event Sourcing framework is only designed for a single process application. +## Writing data +Datoms (tuples of data) are written to the database via transactions. Since MnemonicDB is a single-writer database, transactions +are not applied directly and do not lock the database. Instead, transactions are created, and then shipped off to the +writer task which serializes writes to the backing store. -### Data format -Data is stored as a series of tuples, in the format of `[entity, attribute, value, transaction, op]` where each of these has a specific meaning: +Read models can be used to create new entities in the database. Here is an example of creating a new file entity using +the above constructor method. -* `entity` - 64bit long - The entity id the tuple is associated with -* `attribute` - 64bit long - The attribute id the tuple is associated with -* `value` - The value of the tuple, a binary blob who's format is defined by the attribute's `NativeType` in the schema -* `transaction` - 64bit long - The transaction id the tuple is associated with -* `op` - 1bit flag - The operation that was performed on the tuple, either `Assert` or `Retract` +```csharp + var tx = db.BeginTransaction(); + var file = File.Create(tx, "file.txt", mod, 1024, hash); + var txResult = await tx.Commit(); +``` -It is interesting to note that the `transaction` id is a 64bit long, and is used to order the tuples in the event log, transactions are monotonic and always increasing. -This is a key feature of the system, as it allows us to order the events in the event log, and also allows us to replay the events in the event log in order to rebuild the read data model. +A key thing to note in this code is that each entity when it is created fresh, is given a temporary ID. These ids are +not unique, but are unique to the given transaction. Once `txResult` is returned, the tempId assigned to the entity +can be resolved to a real ID: -Attributes and transactions are also entities, and are put into a separate `partition` via a prefix on their ids. The top byte of an ID is the partition, the actual value of these partition -prefixes don't matter much, but it should be noted that the first partition is the partition for attributes, so at any time a quick check of the first byte in an entity id can tell us if it's an attribute id or not. +```csharp + file = db.Get(txResult[file.Id]); +``` -Data is stored in several indexes which can be queried to find a specific datom (or datom that is closest to a specific datom), from there the data is stored in a sorted -set so iterators can move forward and backwards through the data. By varying the order in which the parts of the datoms are sorted, we can efficently navigate through a model. diff --git a/src/NexusMods.EventSourcing.Abstractions/HelperExtensions.cs b/src/NexusMods.EventSourcing.Abstractions/HelperExtensions.cs deleted file mode 100644 index 0a7a15ae..00000000 --- a/src/NexusMods.EventSourcing.Abstractions/HelperExtensions.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.Buffers.Binary; - -namespace NexusMods.EventSourcing.Abstractions; - -/// -/// Helper extensions for the event sourcing library -/// -public static class HelperExtensions -{ - /// - /// Assumes the string is a valid GUID and converts it to a UInt128 - /// - /// - /// - /// - public static UInt128 ToUInt128Guid(this string guid) - { - Span bytes = stackalloc byte[16]; - if (!Guid.TryParse(guid, out var parsedGuid)) - throw new ArgumentException("Invalid GUID", nameof(guid)); - parsedGuid.TryWriteBytes(bytes); - return BinaryPrimitives.ReadUInt128LittleEndian(bytes); - } - - /// - /// Converts a GUID to a UInt128 - /// - public static UInt128 ToUInt128Guid(this Guid guid) - { - Span bytes = stackalloc byte[16]; - guid.TryWriteBytes(bytes); - return BinaryPrimitives.ReadUInt128LittleEndian(bytes); - } -} diff --git a/src/NexusMods.EventSourcing.Abstractions/ITransactionResult.cs b/src/NexusMods.EventSourcing.Abstractions/ITransactionResult.cs deleted file mode 100644 index 52e0be08..00000000 --- a/src/NexusMods.EventSourcing.Abstractions/ITransactionResult.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace NexusMods.EventSourcing.Abstractions; - -/// -/// The result of a transaction commit, contains metadata useful for looking up the results of the transaction -/// -public interface ITransactionResult -{ - /// - /// The new transaction id after the commit - /// - public TxId NewTx { get; } - - /// - /// The datoms that were added to the store as a result of the transaction - /// - public IReadOnlyCollection Added { get; } - - /// - /// The time it took to commit the transaction - /// - public TimeSpan Elapsed { get; } - - /// - /// Gets a fresh reference to the database after the transaction, this should be disposed when done. - /// - /// - public IDb NewDb(); -} diff --git a/src/NexusMods.EventSourcing.Abstractions/StackDatom.cs b/src/NexusMods.EventSourcing.Abstractions/StackDatom.cs deleted file mode 100644 index 617e7c24..00000000 --- a/src/NexusMods.EventSourcing.Abstractions/StackDatom.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; -using System.Diagnostics; -using Reloaded.Memory.Extensions; - -namespace NexusMods.EventSourcing.Abstractions; - -/// -/// A datom that can only exist on the stack. This is used to move data between the various indexes in the storage -/// layer -/// -public ref struct StackDatom -{ - /// - /// The entity id - /// - public ulong E; - - /// - /// The Attribute id - /// - public ushort A; - - /// - /// The Transaction id - /// - public ulong T; - - /// - /// The value span - /// - public ReadOnlySpan V; - - /// - /// The span for the value, prefixed with PaddingSize bytes of padding, these bytes can be used to store - /// extra data that needs to be written to the database, but is not part of the value itself. - /// - public Span PaddedSpan; - - /// - /// Returns the padded span, with all but the last padding bytes removed - /// - public Span Padded(int padding) - { - Debug.Assert(padding is >= 0 and <= PaddingSize); - return PaddedSpan.SliceFast(PaddingSize - padding); - } - - /// - /// The size of the padding in the V span - /// - public const int PaddingSize = sizeof(ulong) + sizeof(ushort) + sizeof(ulong); -} diff --git a/src/NexusMods.EventSourcing.Abstractions/StoreKey.cs b/src/NexusMods.EventSourcing.Abstractions/StoreKey.cs deleted file mode 100644 index d4070790..00000000 --- a/src/NexusMods.EventSourcing.Abstractions/StoreKey.cs +++ /dev/null @@ -1,17 +0,0 @@ -using TransparentValueObjects; - -namespace NexusMods.EventSourcing.Abstractions; - -/// -/// Represents a IKVStore key, which is a 64-bit unsigned integer, these make heavy -/// use of integer partitioning to ensure that keys are unique yet still sortable and -/// iterable. -/// -[ValueObject] -public readonly partial struct StoreKey -{ - /// - /// The root key, where the root of all the indexes are stored - /// - public static StoreKey RootKey => new(0); -} diff --git a/src/NexusMods.EventSourcing.Abstractions/StoreResult.cs b/src/NexusMods.EventSourcing.Abstractions/StoreResult.cs deleted file mode 100644 index 1a77323d..00000000 --- a/src/NexusMods.EventSourcing.Abstractions/StoreResult.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Collections.Generic; - -namespace NexusMods.EventSourcing.Abstractions; - -public class StoreResult -{ - public required TxId AssignedTxId { get; init; } - public required Dictionary Remaps { get; init; } - public required ISnapshot Snapshot { get; init; } - public required IReadOnlyCollection Datoms { get; init; } -} diff --git a/src/NexusMods.EventSourcing.Storage/Abstractions/IIndexStore.cs b/src/NexusMods.EventSourcing.Storage/Abstractions/IIndexStore.cs deleted file mode 100644 index 84f6e4ab..00000000 --- a/src/NexusMods.EventSourcing.Storage/Abstractions/IIndexStore.cs +++ /dev/null @@ -1,10 +0,0 @@ -using NexusMods.EventSourcing.Abstractions; -using NexusMods.EventSourcing.Abstractions.DatomIterators; - -namespace NexusMods.EventSourcing.Storage.Abstractions; - -public interface IIndexStore -{ - IndexType Type { get; } - IDatomSource GetIterator(); -} diff --git a/src/NexusMods.EventSourcing.Storage/Abstractions/KeyPrefix.cs b/src/NexusMods.EventSourcing.Storage/Abstractions/KeyPrefix.cs deleted file mode 100644 index ff36e742..00000000 --- a/src/NexusMods.EventSourcing.Storage/Abstractions/KeyPrefix.cs +++ /dev/null @@ -1 +0,0 @@ -namespace NexusMods.EventSourcing.Storage.Abstractions; diff --git a/src/NexusMods.EventSourcing.Storage/RocksDbBackend/IRocksDbIndex.cs b/src/NexusMods.EventSourcing.Storage/RocksDbBackend/IRocksDbIndex.cs deleted file mode 100644 index e06d1f79..00000000 --- a/src/NexusMods.EventSourcing.Storage/RocksDbBackend/IRocksDbIndex.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace NexusMods.EventSourcing.Storage.RocksDbBackend; - -public interface IRocksDbIndex { } diff --git a/src/NexusMods.EventSourcing.Storage/RocksDbBackend/Snapshot.cs b/src/NexusMods.EventSourcing.Storage/RocksDbBackend/Snapshot.cs deleted file mode 100644 index d19c15e7..00000000 --- a/src/NexusMods.EventSourcing.Storage/RocksDbBackend/Snapshot.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace NexusMods.EventSourcing.Storage.RocksDbBackend; - -public class Snapshot(Backend backend) { } diff --git a/src/NexusMods.EventSourcing/CommitResult.cs b/src/NexusMods.EventSourcing/CommitResult.cs deleted file mode 100644 index 39cccc6e..00000000 --- a/src/NexusMods.EventSourcing/CommitResult.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Collections.Generic; -using NexusMods.EventSourcing.Abstractions; - -namespace NexusMods.EventSourcing; - -/// -public class CommitResult(TxId newTxId, IDictionary remaps) : ICommitResult -{ - /// - public EntityId this[EntityId id] => - remaps.TryGetValue(id, out var found) ? found : id; - - /// - public TxId NewTx => newTxId; -} diff --git a/src/NexusMods.EventSourcing.Abstractions/AttributeId.cs b/src/NexusMods.MneumonicDB.Abstractions/AttributeId.cs similarity index 91% rename from src/NexusMods.EventSourcing.Abstractions/AttributeId.cs rename to src/NexusMods.MneumonicDB.Abstractions/AttributeId.cs index c8c0e34d..90c9964d 100644 --- a/src/NexusMods.EventSourcing.Abstractions/AttributeId.cs +++ b/src/NexusMods.MneumonicDB.Abstractions/AttributeId.cs @@ -1,6 +1,6 @@ using TransparentValueObjects; -namespace NexusMods.EventSourcing.Abstractions; +namespace NexusMods.MneumonicDB.Abstractions; /// /// A unique identifier for an attribute, also an EntityId. diff --git a/src/NexusMods.EventSourcing.Abstractions/DatomIterators/ExtensionMethods.cs b/src/NexusMods.MneumonicDB.Abstractions/DatomIterators/ExtensionMethods.cs similarity index 84% rename from src/NexusMods.EventSourcing.Abstractions/DatomIterators/ExtensionMethods.cs rename to src/NexusMods.MneumonicDB.Abstractions/DatomIterators/ExtensionMethods.cs index 42516e0b..c43242d1 100644 --- a/src/NexusMods.EventSourcing.Abstractions/DatomIterators/ExtensionMethods.cs +++ b/src/NexusMods.MneumonicDB.Abstractions/DatomIterators/ExtensionMethods.cs @@ -2,10 +2,10 @@ using System.Collections.Generic; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -using NexusMods.EventSourcing.Abstractions.Internals; +using NexusMods.MneumonicDB.Abstractions.Internals; using Reloaded.Memory.Extensions; -namespace NexusMods.EventSourcing.Abstractions.DatomIterators; +namespace NexusMods.MneumonicDB.Abstractions.DatomIterators; /// /// Extension methods for the IIterator interface @@ -30,7 +30,7 @@ public static IIterator SeekTo(this TParent parent, TxId txId) where TParent : ISeekableIterator { var key = new KeyPrefix(); - key.Set(EntityId.MinValue, AttributeId.Min, txId, false); + key.Set(EntityId.MinValueNoPartition, AttributeId.Min, txId, false); return parent.SeekTo(ref key); } @@ -41,7 +41,7 @@ public static IIterator SeekTo(this TParent parent, AttributeId aid) where TParent : ISeekableIterator { var key = new KeyPrefix(); - key.Set(EntityId.MinValue, aid, TxId.MinValue, false); + key.Set(EntityId.MinValueNoPartition, aid, TxId.MinValue, false); return parent.SeekTo(ref key); } @@ -64,6 +64,26 @@ public static IIterator SeekTo(this TParent parent, AttributeId a } } + /// + /// Seeks to the given attribute and value in the iterator, assumes that the other values are 0 + /// and that the value is unmanaged + /// + public static IIterator SeekTo(this TParent parent, TVal val) + where TParent : ISeekableIterator + where TAttribute : IAttribute + where TVal : unmanaged + { + unsafe + { + var aid = parent.Registry.GetAttributeId(typeof(TAttribute)); + Span span = stackalloc byte[sizeof(TVal) + sizeof(KeyPrefix)]; + var key = MemoryMarshal.Cast(span); + key[0].Set(EntityId.MinValue, aid, TxId.MinValue, false); + MemoryMarshal.Write(span.SliceFast(sizeof(KeyPrefix)), val); + return parent.Seek(span); + } + } + /// /// Seeks to the given key prefix in the iterator, the value is null; /// diff --git a/src/NexusMods.EventSourcing.Abstractions/DatomIterators/IDatomSource.cs b/src/NexusMods.MneumonicDB.Abstractions/DatomIterators/IDatomSource.cs similarity index 77% rename from src/NexusMods.EventSourcing.Abstractions/DatomIterators/IDatomSource.cs rename to src/NexusMods.MneumonicDB.Abstractions/DatomIterators/IDatomSource.cs index ad2415ec..536954d2 100644 --- a/src/NexusMods.EventSourcing.Abstractions/DatomIterators/IDatomSource.cs +++ b/src/NexusMods.MneumonicDB.Abstractions/DatomIterators/IDatomSource.cs @@ -1,6 +1,6 @@ using System; -namespace NexusMods.EventSourcing.Abstractions.DatomIterators; +namespace NexusMods.MneumonicDB.Abstractions.DatomIterators; /// /// The base interface for a datom iterator, also implements diff --git a/src/NexusMods.EventSourcing.Abstractions/DatomIterators/IIterator.cs b/src/NexusMods.MneumonicDB.Abstractions/DatomIterators/IIterator.cs similarity index 88% rename from src/NexusMods.EventSourcing.Abstractions/DatomIterators/IIterator.cs rename to src/NexusMods.MneumonicDB.Abstractions/DatomIterators/IIterator.cs index 0f373b92..325cb25c 100644 --- a/src/NexusMods.EventSourcing.Abstractions/DatomIterators/IIterator.cs +++ b/src/NexusMods.MneumonicDB.Abstractions/DatomIterators/IIterator.cs @@ -1,7 +1,7 @@ using System; -using NexusMods.EventSourcing.Abstractions.Internals; +using NexusMods.MneumonicDB.Abstractions.Internals; -namespace NexusMods.EventSourcing.Abstractions.DatomIterators; +namespace NexusMods.MneumonicDB.Abstractions.DatomIterators; /// /// Base interface for an iterator, that allows for moving forward and backwards diff --git a/src/NexusMods.EventSourcing.Abstractions/DatomIterators/ISeekableIterator.cs b/src/NexusMods.MneumonicDB.Abstractions/DatomIterators/ISeekableIterator.cs similarity index 72% rename from src/NexusMods.EventSourcing.Abstractions/DatomIterators/ISeekableIterator.cs rename to src/NexusMods.MneumonicDB.Abstractions/DatomIterators/ISeekableIterator.cs index 0d540d67..65935aa1 100644 --- a/src/NexusMods.EventSourcing.Abstractions/DatomIterators/ISeekableIterator.cs +++ b/src/NexusMods.MneumonicDB.Abstractions/DatomIterators/ISeekableIterator.cs @@ -1,6 +1,8 @@ using System; +using Microsoft.Win32; +using NexusMods.MneumonicDB.Abstractions.Internals; -namespace NexusMods.EventSourcing.Abstractions.DatomIterators; +namespace NexusMods.MneumonicDB.Abstractions.DatomIterators; /// /// An iterator that can seek to the end, start or beginning. @@ -24,4 +26,9 @@ public interface ISeekableIterator /// to an IIterator /// public IIterator SeekStart(); + + /// + /// The registry for the attributes. + /// + public IAttributeRegistry Registry { get; } } diff --git a/src/NexusMods.EventSourcing.Abstractions/DatomIterators/ReverseIterator.cs b/src/NexusMods.MneumonicDB.Abstractions/DatomIterators/ReverseIterator.cs similarity index 81% rename from src/NexusMods.EventSourcing.Abstractions/DatomIterators/ReverseIterator.cs rename to src/NexusMods.MneumonicDB.Abstractions/DatomIterators/ReverseIterator.cs index 031676b5..aaa13a67 100644 --- a/src/NexusMods.EventSourcing.Abstractions/DatomIterators/ReverseIterator.cs +++ b/src/NexusMods.MneumonicDB.Abstractions/DatomIterators/ReverseIterator.cs @@ -1,8 +1,8 @@ using System; -using NexusMods.EventSourcing.Abstractions.DatomIterators; -using NexusMods.EventSourcing.Abstractions.Internals; +using NexusMods.MneumonicDB.Abstractions.DatomIterators; +using NexusMods.MneumonicDB.Abstractions.Internals; -namespace NexusMods.EventSourcing.Abstractions; +namespace NexusMods.MneumonicDB.Abstractions; /// /// Reverses the order of the iterator so that a .Next will move backwards diff --git a/src/NexusMods.EventSourcing.Abstractions/DatomIterators/While.cs b/src/NexusMods.MneumonicDB.Abstractions/DatomIterators/While.cs similarity index 95% rename from src/NexusMods.EventSourcing.Abstractions/DatomIterators/While.cs rename to src/NexusMods.MneumonicDB.Abstractions/DatomIterators/While.cs index b6d81623..4973cb50 100644 --- a/src/NexusMods.EventSourcing.Abstractions/DatomIterators/While.cs +++ b/src/NexusMods.MneumonicDB.Abstractions/DatomIterators/While.cs @@ -1,7 +1,7 @@ using System; -using NexusMods.EventSourcing.Abstractions.Internals; +using NexusMods.MneumonicDB.Abstractions.Internals; -namespace NexusMods.EventSourcing.Abstractions.DatomIterators; +namespace NexusMods.MneumonicDB.Abstractions.DatomIterators; /// /// Iterates over the datoms while the attribute is equal to the given value diff --git a/src/NexusMods.EventSourcing.Abstractions/DatomStoreSettings.cs b/src/NexusMods.MneumonicDB.Abstractions/DatomStoreSettings.cs similarity index 78% rename from src/NexusMods.EventSourcing.Abstractions/DatomStoreSettings.cs rename to src/NexusMods.MneumonicDB.Abstractions/DatomStoreSettings.cs index b30b9a65..8530e208 100644 --- a/src/NexusMods.EventSourcing.Abstractions/DatomStoreSettings.cs +++ b/src/NexusMods.MneumonicDB.Abstractions/DatomStoreSettings.cs @@ -1,6 +1,6 @@ using NexusMods.Paths; -namespace NexusMods.EventSourcing.Abstractions; +namespace NexusMods.MneumonicDB.Abstractions; /// /// Settings for the datom store diff --git a/src/NexusMods.EventSourcing.Abstractions/DbAttribute.cs b/src/NexusMods.MneumonicDB.Abstractions/DbAttribute.cs similarity index 88% rename from src/NexusMods.EventSourcing.Abstractions/DbAttribute.cs rename to src/NexusMods.MneumonicDB.Abstractions/DbAttribute.cs index c985400a..4c7860df 100644 --- a/src/NexusMods.EventSourcing.Abstractions/DbAttribute.cs +++ b/src/NexusMods.MneumonicDB.Abstractions/DbAttribute.cs @@ -1,4 +1,4 @@ -namespace NexusMods.EventSourcing.Abstractions; +namespace NexusMods.MneumonicDB.Abstractions; /// /// A record of information that maps a in-code version of an attribute (the symbol name) to the diff --git a/src/NexusMods.EventSourcing.Abstractions/DependencyInjectionExtensions.cs b/src/NexusMods.MneumonicDB.Abstractions/DependencyInjectionExtensions.cs similarity index 97% rename from src/NexusMods.EventSourcing.Abstractions/DependencyInjectionExtensions.cs rename to src/NexusMods.MneumonicDB.Abstractions/DependencyInjectionExtensions.cs index ccf4cde6..87644ddd 100644 --- a/src/NexusMods.EventSourcing.Abstractions/DependencyInjectionExtensions.cs +++ b/src/NexusMods.MneumonicDB.Abstractions/DependencyInjectionExtensions.cs @@ -1,7 +1,7 @@ using System; using Microsoft.Extensions.DependencyInjection; -namespace NexusMods.EventSourcing.Abstractions; +namespace NexusMods.MneumonicDB.Abstractions; /// /// Extension methods for adding attributes and other types to the service collection. diff --git a/src/NexusMods.EventSourcing.Abstractions/EntityId.cs b/src/NexusMods.MneumonicDB.Abstractions/EntityId.cs similarity index 51% rename from src/NexusMods.EventSourcing.Abstractions/EntityId.cs rename to src/NexusMods.MneumonicDB.Abstractions/EntityId.cs index f8565549..e94f216c 100644 --- a/src/NexusMods.EventSourcing.Abstractions/EntityId.cs +++ b/src/NexusMods.MneumonicDB.Abstractions/EntityId.cs @@ -1,6 +1,6 @@ using TransparentValueObjects; -namespace NexusMods.EventSourcing.Abstractions; +namespace NexusMods.MneumonicDB.Abstractions; /// /// A unique identifier for an entity. @@ -11,5 +11,10 @@ public readonly partial struct EntityId /// /// The minimum possible value for an entity id in the entity partition. /// - public static EntityId MinValue => new(Ids.MakeId(Ids.Partition.Entity, 1)); + public static EntityId MinValue => From(Ids.MakeId(Ids.Partition.Entity, 1)); + + /// + /// Min value for an entity id with no partition + /// + public static EntityId MinValueNoPartition => From(0); } diff --git a/src/NexusMods.EventSourcing.Abstractions/IAttribute.cs b/src/NexusMods.MneumonicDB.Abstractions/IAttribute.cs similarity index 97% rename from src/NexusMods.EventSourcing.Abstractions/IAttribute.cs rename to src/NexusMods.MneumonicDB.Abstractions/IAttribute.cs index 4ef8c82d..fbace27e 100644 --- a/src/NexusMods.EventSourcing.Abstractions/IAttribute.cs +++ b/src/NexusMods.MneumonicDB.Abstractions/IAttribute.cs @@ -1,6 +1,6 @@ using System; -namespace NexusMods.EventSourcing.Abstractions; +namespace NexusMods.MneumonicDB.Abstractions; /// /// Interface for a specific attribute diff --git a/src/NexusMods.EventSourcing.Abstractions/ICommitResult.cs b/src/NexusMods.MneumonicDB.Abstractions/ICommitResult.cs similarity index 75% rename from src/NexusMods.EventSourcing.Abstractions/ICommitResult.cs rename to src/NexusMods.MneumonicDB.Abstractions/ICommitResult.cs index 72156307..050115e1 100644 --- a/src/NexusMods.EventSourcing.Abstractions/ICommitResult.cs +++ b/src/NexusMods.MneumonicDB.Abstractions/ICommitResult.cs @@ -1,7 +1,8 @@ using System; using System.Collections.Generic; +using NexusMods.MneumonicDB.Abstractions.Models; -namespace NexusMods.EventSourcing.Abstractions; +namespace NexusMods.MneumonicDB.Abstractions; /// /// The result of a transaction commit, contains metadata useful for looking up the results of the transaction @@ -14,6 +15,12 @@ public interface ICommitResult /// public EntityId this[EntityId id] { get; } + + /// + /// Remaps a ReadModel to a new instance with the new ids + /// + public T Remap(T model) where T : IReadModel; + /// /// Gets the new TxId after the commit /// diff --git a/src/NexusMods.EventSourcing.Abstractions/IConnection.cs b/src/NexusMods.MneumonicDB.Abstractions/IConnection.cs similarity index 92% rename from src/NexusMods.EventSourcing.Abstractions/IConnection.cs rename to src/NexusMods.MneumonicDB.Abstractions/IConnection.cs index a59e39de..125b48ef 100644 --- a/src/NexusMods.EventSourcing.Abstractions/IConnection.cs +++ b/src/NexusMods.MneumonicDB.Abstractions/IConnection.cs @@ -1,6 +1,6 @@ using System; -namespace NexusMods.EventSourcing.Abstractions; +namespace NexusMods.MneumonicDB.Abstractions; /// /// Represents a connection to a database. diff --git a/src/NexusMods.EventSourcing.Abstractions/IDatomStore.cs b/src/NexusMods.MneumonicDB.Abstractions/IDatomStore.cs similarity index 97% rename from src/NexusMods.EventSourcing.Abstractions/IDatomStore.cs rename to src/NexusMods.MneumonicDB.Abstractions/IDatomStore.cs index dd625878..f33e2daf 100644 --- a/src/NexusMods.EventSourcing.Abstractions/IDatomStore.cs +++ b/src/NexusMods.MneumonicDB.Abstractions/IDatomStore.cs @@ -1,9 +1,9 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; -using NexusMods.EventSourcing.Abstractions.Internals; +using NexusMods.MneumonicDB.Abstractions.Internals; -namespace NexusMods.EventSourcing.Abstractions; +namespace NexusMods.MneumonicDB.Abstractions; /// /// Represents the low-level storage for datoms. diff --git a/src/NexusMods.EventSourcing.Abstractions/IDb.cs b/src/NexusMods.MneumonicDB.Abstractions/IDb.cs similarity index 81% rename from src/NexusMods.EventSourcing.Abstractions/IDb.cs rename to src/NexusMods.MneumonicDB.Abstractions/IDb.cs index 6091721d..3c52899c 100644 --- a/src/NexusMods.EventSourcing.Abstractions/IDb.cs +++ b/src/NexusMods.MneumonicDB.Abstractions/IDb.cs @@ -1,8 +1,9 @@ using System; using System.Collections.Generic; -using NexusMods.EventSourcing.Abstractions.Models; +using NexusMods.MneumonicDB.Abstractions.DatomIterators; +using NexusMods.MneumonicDB.Abstractions.Models; -namespace NexusMods.EventSourcing.Abstractions; +namespace NexusMods.MneumonicDB.Abstractions; /// /// Represents an immutable database fixed to a specific TxId. @@ -50,6 +51,11 @@ public IEnumerable GetReverse(EntityId id) /// public IEnumerable Datoms(TxId txId); - public IEnumerable Datoms(IndexType type) + public IEnumerable Datoms() where TAttribute : IAttribute; + + /// + /// Create a new iterator for the given index type. + /// + IDatomSource Iterate(IndexType index); } diff --git a/src/NexusMods.EventSourcing.Abstractions/IReadDatom.cs b/src/NexusMods.MneumonicDB.Abstractions/IReadDatom.cs similarity index 87% rename from src/NexusMods.EventSourcing.Abstractions/IReadDatom.cs rename to src/NexusMods.MneumonicDB.Abstractions/IReadDatom.cs index d4c5695e..8f512173 100644 --- a/src/NexusMods.EventSourcing.Abstractions/IReadDatom.cs +++ b/src/NexusMods.MneumonicDB.Abstractions/IReadDatom.cs @@ -1,12 +1,15 @@ using System; -namespace NexusMods.EventSourcing.Abstractions; +namespace NexusMods.MneumonicDB.Abstractions; /// /// Marker interface for a read datom that will contain a TX value. /// public interface IReadDatom { + /// + /// Entity id of the datom. + /// public EntityId E { get; } /// diff --git a/src/NexusMods.EventSourcing.Abstractions/ISnapshot.cs b/src/NexusMods.MneumonicDB.Abstractions/ISnapshot.cs similarity index 76% rename from src/NexusMods.EventSourcing.Abstractions/ISnapshot.cs rename to src/NexusMods.MneumonicDB.Abstractions/ISnapshot.cs index 377eb986..74d5b8e9 100644 --- a/src/NexusMods.EventSourcing.Abstractions/ISnapshot.cs +++ b/src/NexusMods.MneumonicDB.Abstractions/ISnapshot.cs @@ -1,6 +1,6 @@ -using NexusMods.EventSourcing.Abstractions.DatomIterators; +using NexusMods.MneumonicDB.Abstractions.DatomIterators; -namespace NexusMods.EventSourcing.Abstractions; +namespace NexusMods.MneumonicDB.Abstractions; /// /// Represents a snapshot of the database at a specific point of time. Snapshots are immutable @@ -13,7 +13,5 @@ public interface ISnapshot /// /// Gets an iterator for the given index type. /// - /// - /// IDatomSource GetIterator(IndexType type); } diff --git a/src/NexusMods.EventSourcing.Abstractions/ITransaction.cs b/src/NexusMods.MneumonicDB.Abstractions/ITransaction.cs similarity index 92% rename from src/NexusMods.EventSourcing.Abstractions/ITransaction.cs rename to src/NexusMods.MneumonicDB.Abstractions/ITransaction.cs index 57455da9..0adf8fa6 100644 --- a/src/NexusMods.EventSourcing.Abstractions/ITransaction.cs +++ b/src/NexusMods.MneumonicDB.Abstractions/ITransaction.cs @@ -1,7 +1,7 @@ using System.Threading.Tasks; -using NexusMods.EventSourcing.Abstractions.Models; +using NexusMods.MneumonicDB.Abstractions.Models; -namespace NexusMods.EventSourcing.Abstractions; +namespace NexusMods.MneumonicDB.Abstractions; /// /// Represents a transaction, which is a set of proposed changes to the datom store diff --git a/src/NexusMods.EventSourcing.Abstractions/IValueSerializer.cs b/src/NexusMods.MneumonicDB.Abstractions/IValueSerializer.cs similarity index 97% rename from src/NexusMods.EventSourcing.Abstractions/IValueSerializer.cs rename to src/NexusMods.MneumonicDB.Abstractions/IValueSerializer.cs index b0889af1..ac8475f4 100644 --- a/src/NexusMods.EventSourcing.Abstractions/IValueSerializer.cs +++ b/src/NexusMods.MneumonicDB.Abstractions/IValueSerializer.cs @@ -1,7 +1,7 @@ using System; using System.Buffers; -namespace NexusMods.EventSourcing.Abstractions; +namespace NexusMods.MneumonicDB.Abstractions; /// /// A abstract interface for a value serializer. Serializers can either emit fixed diff --git a/src/NexusMods.EventSourcing.Abstractions/IWriteDatom.cs b/src/NexusMods.MneumonicDB.Abstractions/IWriteDatom.cs similarity index 90% rename from src/NexusMods.EventSourcing.Abstractions/IWriteDatom.cs rename to src/NexusMods.MneumonicDB.Abstractions/IWriteDatom.cs index fe94c1b2..58a6aa99 100644 --- a/src/NexusMods.EventSourcing.Abstractions/IWriteDatom.cs +++ b/src/NexusMods.MneumonicDB.Abstractions/IWriteDatom.cs @@ -1,8 +1,8 @@ using System; using System.Buffers; -using NexusMods.EventSourcing.Abstractions.Internals; +using NexusMods.MneumonicDB.Abstractions.Internals; -namespace NexusMods.EventSourcing.Abstractions; +namespace NexusMods.MneumonicDB.Abstractions; /// /// A typed datom for writing new datoms to the database. This is implemented by attributes diff --git a/src/NexusMods.EventSourcing.Abstractions/Ids.cs b/src/NexusMods.MneumonicDB.Abstractions/Ids.cs similarity index 98% rename from src/NexusMods.EventSourcing.Abstractions/Ids.cs rename to src/NexusMods.MneumonicDB.Abstractions/Ids.cs index 9815b502..73060dc7 100644 --- a/src/NexusMods.EventSourcing.Abstractions/Ids.cs +++ b/src/NexusMods.MneumonicDB.Abstractions/Ids.cs @@ -1,6 +1,6 @@ using System; -namespace NexusMods.EventSourcing.Abstractions; +namespace NexusMods.MneumonicDB.Abstractions; /// /// A lot of ids in this system are 64 bit unsigned integers. This class provides a way to partition those ids diff --git a/src/NexusMods.EventSourcing.Abstractions/IndexType.cs b/src/NexusMods.MneumonicDB.Abstractions/IndexType.cs similarity index 91% rename from src/NexusMods.EventSourcing.Abstractions/IndexType.cs rename to src/NexusMods.MneumonicDB.Abstractions/IndexType.cs index 1a2f8716..a79e2278 100644 --- a/src/NexusMods.EventSourcing.Abstractions/IndexType.cs +++ b/src/NexusMods.MneumonicDB.Abstractions/IndexType.cs @@ -1,4 +1,4 @@ -namespace NexusMods.EventSourcing.Abstractions; +namespace NexusMods.MneumonicDB.Abstractions; public enum IndexType { diff --git a/src/NexusMods.EventSourcing.Abstractions/Internals/IAttributeRegistry.cs b/src/NexusMods.MneumonicDB.Abstractions/Internals/IAttributeRegistry.cs similarity index 96% rename from src/NexusMods.EventSourcing.Abstractions/Internals/IAttributeRegistry.cs rename to src/NexusMods.MneumonicDB.Abstractions/Internals/IAttributeRegistry.cs index 7b67012f..5b01c770 100644 --- a/src/NexusMods.EventSourcing.Abstractions/Internals/IAttributeRegistry.cs +++ b/src/NexusMods.MneumonicDB.Abstractions/Internals/IAttributeRegistry.cs @@ -1,7 +1,7 @@ using System; using System.Buffers; -namespace NexusMods.EventSourcing.Abstractions.Internals; +namespace NexusMods.MneumonicDB.Abstractions.Internals; /// /// A registry of attributes and serializers that supports operations that requires converting diff --git a/src/NexusMods.EventSourcing.Abstractions/Internals/KeyPrefix.cs b/src/NexusMods.MneumonicDB.Abstractions/Internals/KeyPrefix.cs similarity index 95% rename from src/NexusMods.EventSourcing.Abstractions/Internals/KeyPrefix.cs rename to src/NexusMods.MneumonicDB.Abstractions/Internals/KeyPrefix.cs index 53ee94b2..0a74c83a 100644 --- a/src/NexusMods.EventSourcing.Abstractions/Internals/KeyPrefix.cs +++ b/src/NexusMods.MneumonicDB.Abstractions/Internals/KeyPrefix.cs @@ -2,7 +2,7 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -namespace NexusMods.EventSourcing.Abstractions.Internals; +namespace NexusMods.MneumonicDB.Abstractions.Internals; /// /// The system encodes keys as a 16 byte prefix followed by the actual key data, the format @@ -12,7 +12,7 @@ namespace NexusMods.EventSourcing.Abstractions.Internals; /// This KeyPrefix then contains the other parts of the Datom: EntityId, AttributeId, TxId, and Flags. /// Encodes and decodes the prefix of a key, the format is: /// [AttributeId: 2bytes] -/// [TxId: 8bytes - 1 bit for the assert/retract flag] +/// [TxId: 6bytes] /// [EntityID + PartitionID: 7bytes] /// [IsRetract: 1bit] /// The Entity Id is created by taking the last 6 bytes of the id and combining it with diff --git a/src/NexusMods.EventSourcing.Abstractions/Models/AReadModel.cs b/src/NexusMods.MneumonicDB.Abstractions/Models/AReadModel.cs similarity index 96% rename from src/NexusMods.EventSourcing.Abstractions/Models/AReadModel.cs rename to src/NexusMods.MneumonicDB.Abstractions/Models/AReadModel.cs index 3d7e2383..03409d3c 100644 --- a/src/NexusMods.EventSourcing.Abstractions/Models/AReadModel.cs +++ b/src/NexusMods.MneumonicDB.Abstractions/Models/AReadModel.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; -namespace NexusMods.EventSourcing.Abstractions.Models; +namespace NexusMods.MneumonicDB.Abstractions.Models; /// /// Base class for all read models. diff --git a/src/NexusMods.EventSourcing.Abstractions/Models/FromAttribute.cs b/src/NexusMods.MneumonicDB.Abstractions/Models/FromAttribute.cs similarity index 88% rename from src/NexusMods.EventSourcing.Abstractions/Models/FromAttribute.cs rename to src/NexusMods.MneumonicDB.Abstractions/Models/FromAttribute.cs index bd14ce83..575b273c 100644 --- a/src/NexusMods.EventSourcing.Abstractions/Models/FromAttribute.cs +++ b/src/NexusMods.MneumonicDB.Abstractions/Models/FromAttribute.cs @@ -1,6 +1,6 @@ using System; -namespace NexusMods.EventSourcing.Abstractions.Models; +namespace NexusMods.MneumonicDB.Abstractions.Models; /// /// Marks a property as being derived from an attribute. diff --git a/src/NexusMods.EventSourcing.Abstractions/Models/IFromAttribute.cs b/src/NexusMods.MneumonicDB.Abstractions/Models/IFromAttribute.cs similarity index 82% rename from src/NexusMods.EventSourcing.Abstractions/Models/IFromAttribute.cs rename to src/NexusMods.MneumonicDB.Abstractions/Models/IFromAttribute.cs index f9c1344d..d42fdc9f 100644 --- a/src/NexusMods.EventSourcing.Abstractions/Models/IFromAttribute.cs +++ b/src/NexusMods.MneumonicDB.Abstractions/Models/IFromAttribute.cs @@ -1,6 +1,6 @@ using System; -namespace NexusMods.EventSourcing.Abstractions.Models; +namespace NexusMods.MneumonicDB.Abstractions.Models; /// /// Base interface for all from attributes. diff --git a/src/NexusMods.EventSourcing.Abstractions/Models/IReadModel.cs b/src/NexusMods.MneumonicDB.Abstractions/Models/IReadModel.cs similarity index 90% rename from src/NexusMods.EventSourcing.Abstractions/Models/IReadModel.cs rename to src/NexusMods.MneumonicDB.Abstractions/Models/IReadModel.cs index 77fe414f..7da8e599 100644 --- a/src/NexusMods.EventSourcing.Abstractions/Models/IReadModel.cs +++ b/src/NexusMods.MneumonicDB.Abstractions/Models/IReadModel.cs @@ -1,4 +1,4 @@ -namespace NexusMods.EventSourcing.Abstractions.Models; +namespace NexusMods.MneumonicDB.Abstractions.Models; /// /// Base interface for all read models. The AReadModel class takes a generic parameter diff --git a/src/NexusMods.EventSourcing.Abstractions/NexusMods.EventSourcing.Abstractions.csproj b/src/NexusMods.MneumonicDB.Abstractions/NexusMods.MneumonicDB.Abstractions.csproj similarity index 91% rename from src/NexusMods.EventSourcing.Abstractions/NexusMods.EventSourcing.Abstractions.csproj rename to src/NexusMods.MneumonicDB.Abstractions/NexusMods.MneumonicDB.Abstractions.csproj index 4c27c9d9..41ca8e4f 100644 --- a/src/NexusMods.EventSourcing.Abstractions/NexusMods.EventSourcing.Abstractions.csproj +++ b/src/NexusMods.MneumonicDB.Abstractions/NexusMods.MneumonicDB.Abstractions.csproj @@ -1,6 +1,6 @@  - NexusMods.EventSourcing.Abstractions + NexusMods.MneumonicDB.Abstractions true diff --git a/src/NexusMods.EventSourcing.Abstractions/ScalarAttribute.cs b/src/NexusMods.MneumonicDB.Abstractions/ScalarAttribute.cs similarity index 98% rename from src/NexusMods.EventSourcing.Abstractions/ScalarAttribute.cs rename to src/NexusMods.MneumonicDB.Abstractions/ScalarAttribute.cs index edef629a..855aa35c 100644 --- a/src/NexusMods.EventSourcing.Abstractions/ScalarAttribute.cs +++ b/src/NexusMods.MneumonicDB.Abstractions/ScalarAttribute.cs @@ -1,8 +1,8 @@ using System; using System.Buffers; -using NexusMods.EventSourcing.Abstractions.Internals; +using NexusMods.MneumonicDB.Abstractions.Internals; -namespace NexusMods.EventSourcing.Abstractions; +namespace NexusMods.MneumonicDB.Abstractions; /// /// Interface for a specific attribute diff --git a/src/NexusMods.MneumonicDB.Abstractions/StoreResult.cs b/src/NexusMods.MneumonicDB.Abstractions/StoreResult.cs new file mode 100644 index 00000000..b68ec2fd --- /dev/null +++ b/src/NexusMods.MneumonicDB.Abstractions/StoreResult.cs @@ -0,0 +1,24 @@ +using System.Collections.Generic; + +namespace NexusMods.MneumonicDB.Abstractions; + +/// +/// The result of a transaction being commited to a store. +/// +public class StoreResult +{ + /// + /// The assigned transaction id. + /// + public required TxId AssignedTxId { get; init; } + + /// + /// The remaps that were created during the transaction. + /// + public required Dictionary Remaps { get; init; } + + /// + /// The snapshot of the store after the transaction. + /// + public required ISnapshot Snapshot { get; init; } +} diff --git a/src/NexusMods.EventSourcing.Abstractions/Symbol.cs b/src/NexusMods.MneumonicDB.Abstractions/Symbol.cs similarity index 98% rename from src/NexusMods.EventSourcing.Abstractions/Symbol.cs rename to src/NexusMods.MneumonicDB.Abstractions/Symbol.cs index c1a65418..2775073d 100644 --- a/src/NexusMods.EventSourcing.Abstractions/Symbol.cs +++ b/src/NexusMods.MneumonicDB.Abstractions/Symbol.cs @@ -1,6 +1,6 @@ using System.Collections.Concurrent; -namespace NexusMods.EventSourcing.Abstractions; +namespace NexusMods.MneumonicDB.Abstractions; /// /// A string that is interned behind a class so we can do reference equality diff --git a/src/NexusMods.EventSourcing.Abstractions/TxId.cs b/src/NexusMods.MneumonicDB.Abstractions/TxId.cs similarity index 95% rename from src/NexusMods.EventSourcing.Abstractions/TxId.cs rename to src/NexusMods.MneumonicDB.Abstractions/TxId.cs index a7353c9d..cc75ceb2 100644 --- a/src/NexusMods.EventSourcing.Abstractions/TxId.cs +++ b/src/NexusMods.MneumonicDB.Abstractions/TxId.cs @@ -1,6 +1,6 @@ using TransparentValueObjects; -namespace NexusMods.EventSourcing.Abstractions; +namespace NexusMods.MneumonicDB.Abstractions; /// /// A typed identifier for a transaction id, internally this is a ulong. diff --git a/src/NexusMods.EventSourcing.Storage/Abstractions/AIndex.cs b/src/NexusMods.MneumonicDB.Storage/Abstractions/AIndex.cs similarity index 90% rename from src/NexusMods.EventSourcing.Storage/Abstractions/AIndex.cs rename to src/NexusMods.MneumonicDB.Storage/Abstractions/AIndex.cs index ccbf084c..a42e6dcf 100644 --- a/src/NexusMods.EventSourcing.Storage/Abstractions/AIndex.cs +++ b/src/NexusMods.MneumonicDB.Storage/Abstractions/AIndex.cs @@ -1,7 +1,7 @@ using System; -using NexusMods.EventSourcing.Abstractions.DatomIterators; +using NexusMods.MneumonicDB.Abstractions.DatomIterators; -namespace NexusMods.EventSourcing.Storage.Abstractions; +namespace NexusMods.MneumonicDB.Storage.Abstractions; public abstract class AIndex(AttributeRegistry registry, TIndexStore store) : IIndex where TA : IElementComparer diff --git a/src/NexusMods.EventSourcing.Storage/Abstractions/ElementComparers/AComparer.cs b/src/NexusMods.MneumonicDB.Storage/Abstractions/ElementComparers/AComparer.cs similarity index 71% rename from src/NexusMods.EventSourcing.Storage/Abstractions/ElementComparers/AComparer.cs rename to src/NexusMods.MneumonicDB.Storage/Abstractions/ElementComparers/AComparer.cs index 4af5e353..5eb5afde 100644 --- a/src/NexusMods.EventSourcing.Storage/Abstractions/ElementComparers/AComparer.cs +++ b/src/NexusMods.MneumonicDB.Storage/Abstractions/ElementComparers/AComparer.cs @@ -1,8 +1,8 @@ using System; using System.Runtime.InteropServices; -using NexusMods.EventSourcing.Abstractions.Internals; +using NexusMods.MneumonicDB.Abstractions.Internals; -namespace NexusMods.EventSourcing.Storage.Abstractions.ElementComparers; +namespace NexusMods.MneumonicDB.Storage.Abstractions.ElementComparers; public class AComparer : IElementComparer { diff --git a/src/NexusMods.EventSourcing.Storage/Abstractions/ElementComparers/AssertComparer.cs b/src/NexusMods.MneumonicDB.Storage/Abstractions/ElementComparers/AssertComparer.cs similarity index 72% rename from src/NexusMods.EventSourcing.Storage/Abstractions/ElementComparers/AssertComparer.cs rename to src/NexusMods.MneumonicDB.Storage/Abstractions/ElementComparers/AssertComparer.cs index 20e46ced..14d6f1a0 100644 --- a/src/NexusMods.EventSourcing.Storage/Abstractions/ElementComparers/AssertComparer.cs +++ b/src/NexusMods.MneumonicDB.Storage/Abstractions/ElementComparers/AssertComparer.cs @@ -1,8 +1,8 @@ using System; using System.Runtime.InteropServices; -using NexusMods.EventSourcing.Abstractions.Internals; +using NexusMods.MneumonicDB.Abstractions.Internals; -namespace NexusMods.EventSourcing.Storage.Abstractions.ElementComparers; +namespace NexusMods.MneumonicDB.Storage.Abstractions.ElementComparers; public class AssertComparer : IElementComparer { diff --git a/src/NexusMods.EventSourcing.Storage/Abstractions/ElementComparers/EComparer.cs b/src/NexusMods.MneumonicDB.Storage/Abstractions/ElementComparers/EComparer.cs similarity index 71% rename from src/NexusMods.EventSourcing.Storage/Abstractions/ElementComparers/EComparer.cs rename to src/NexusMods.MneumonicDB.Storage/Abstractions/ElementComparers/EComparer.cs index 1741d7d8..55cb99f4 100644 --- a/src/NexusMods.EventSourcing.Storage/Abstractions/ElementComparers/EComparer.cs +++ b/src/NexusMods.MneumonicDB.Storage/Abstractions/ElementComparers/EComparer.cs @@ -1,8 +1,8 @@ using System; using System.Runtime.InteropServices; -using NexusMods.EventSourcing.Abstractions.Internals; +using NexusMods.MneumonicDB.Abstractions.Internals; -namespace NexusMods.EventSourcing.Storage.Abstractions.ElementComparers; +namespace NexusMods.MneumonicDB.Storage.Abstractions.ElementComparers; public class EComparer : IElementComparer { diff --git a/src/NexusMods.EventSourcing.Storage/Abstractions/ElementComparers/TxComparer.cs b/src/NexusMods.MneumonicDB.Storage/Abstractions/ElementComparers/TxComparer.cs similarity index 71% rename from src/NexusMods.EventSourcing.Storage/Abstractions/ElementComparers/TxComparer.cs rename to src/NexusMods.MneumonicDB.Storage/Abstractions/ElementComparers/TxComparer.cs index 6ff526a0..d97c4c07 100644 --- a/src/NexusMods.EventSourcing.Storage/Abstractions/ElementComparers/TxComparer.cs +++ b/src/NexusMods.MneumonicDB.Storage/Abstractions/ElementComparers/TxComparer.cs @@ -1,8 +1,8 @@ using System; using System.Runtime.InteropServices; -using NexusMods.EventSourcing.Abstractions.Internals; +using NexusMods.MneumonicDB.Abstractions.Internals; -namespace NexusMods.EventSourcing.Storage.Abstractions.ElementComparers; +namespace NexusMods.MneumonicDB.Storage.Abstractions.ElementComparers; public class TxComparer : IElementComparer { diff --git a/src/NexusMods.EventSourcing.Storage/Abstractions/ElementComparers/UnmanagedValueComparer.cs b/src/NexusMods.MneumonicDB.Storage/Abstractions/ElementComparers/UnmanagedValueComparer.cs similarity index 86% rename from src/NexusMods.EventSourcing.Storage/Abstractions/ElementComparers/UnmanagedValueComparer.cs rename to src/NexusMods.MneumonicDB.Storage/Abstractions/ElementComparers/UnmanagedValueComparer.cs index ff9b95c7..00255b2b 100644 --- a/src/NexusMods.EventSourcing.Storage/Abstractions/ElementComparers/UnmanagedValueComparer.cs +++ b/src/NexusMods.MneumonicDB.Storage/Abstractions/ElementComparers/UnmanagedValueComparer.cs @@ -1,9 +1,9 @@ using System; using System.Runtime.InteropServices; -using NexusMods.EventSourcing.Abstractions.Internals; +using NexusMods.MneumonicDB.Abstractions.Internals; using Reloaded.Memory.Extensions; -namespace NexusMods.EventSourcing.Storage.Abstractions.ElementComparers; +namespace NexusMods.MneumonicDB.Storage.Abstractions.ElementComparers; /// /// Unmanaged value comparer, assumes that the values will be of the same attribute and of type T. diff --git a/src/NexusMods.EventSourcing.Storage/Abstractions/ElementComparers/ValueComparer.cs b/src/NexusMods.MneumonicDB.Storage/Abstractions/ElementComparers/ValueComparer.cs similarity index 82% rename from src/NexusMods.EventSourcing.Storage/Abstractions/ElementComparers/ValueComparer.cs rename to src/NexusMods.MneumonicDB.Storage/Abstractions/ElementComparers/ValueComparer.cs index 00ac5dc0..414d4041 100644 --- a/src/NexusMods.EventSourcing.Storage/Abstractions/ElementComparers/ValueComparer.cs +++ b/src/NexusMods.MneumonicDB.Storage/Abstractions/ElementComparers/ValueComparer.cs @@ -1,9 +1,9 @@ using System; using System.Runtime.InteropServices; -using NexusMods.EventSourcing.Abstractions.Internals; +using NexusMods.MneumonicDB.Abstractions.Internals; using Reloaded.Memory.Extensions; -namespace NexusMods.EventSourcing.Storage.Abstractions.ElementComparers; +namespace NexusMods.MneumonicDB.Storage.Abstractions.ElementComparers; /// /// Compares values and assumes that some previous comparator will guarantee that the values are of the same attribute. diff --git a/src/NexusMods.EventSourcing.Storage/Abstractions/IElementComparer.cs b/src/NexusMods.MneumonicDB.Storage/Abstractions/IElementComparer.cs similarity index 75% rename from src/NexusMods.EventSourcing.Storage/Abstractions/IElementComparer.cs rename to src/NexusMods.MneumonicDB.Storage/Abstractions/IElementComparer.cs index e9b413fa..89e7aa89 100644 --- a/src/NexusMods.EventSourcing.Storage/Abstractions/IElementComparer.cs +++ b/src/NexusMods.MneumonicDB.Storage/Abstractions/IElementComparer.cs @@ -1,6 +1,6 @@ using System; -namespace NexusMods.EventSourcing.Storage.Abstractions; +namespace NexusMods.MneumonicDB.Storage.Abstractions; public interface IElementComparer { diff --git a/src/NexusMods.EventSourcing.Storage/Abstractions/IIndex.cs b/src/NexusMods.MneumonicDB.Storage/Abstractions/IIndex.cs similarity index 71% rename from src/NexusMods.EventSourcing.Storage/Abstractions/IIndex.cs rename to src/NexusMods.MneumonicDB.Storage/Abstractions/IIndex.cs index 305e8e26..59d9afc8 100644 --- a/src/NexusMods.EventSourcing.Storage/Abstractions/IIndex.cs +++ b/src/NexusMods.MneumonicDB.Storage/Abstractions/IIndex.cs @@ -1,7 +1,7 @@ using System; -using NexusMods.EventSourcing.Abstractions.DatomIterators; +using NexusMods.MneumonicDB.Abstractions.DatomIterators; -namespace NexusMods.EventSourcing.Storage.Abstractions; +namespace NexusMods.MneumonicDB.Storage.Abstractions; public interface IIndex { diff --git a/src/NexusMods.MneumonicDB.Storage/Abstractions/IIndexStore.cs b/src/NexusMods.MneumonicDB.Storage/Abstractions/IIndexStore.cs new file mode 100644 index 00000000..4f02399f --- /dev/null +++ b/src/NexusMods.MneumonicDB.Storage/Abstractions/IIndexStore.cs @@ -0,0 +1,10 @@ +using NexusMods.MneumonicDB.Abstractions; +using NexusMods.MneumonicDB.Abstractions.DatomIterators; + +namespace NexusMods.MneumonicDB.Storage.Abstractions; + +public interface IIndexStore +{ + IndexType Type { get; } + IDatomSource GetIterator(); +} diff --git a/src/NexusMods.EventSourcing.Storage/Abstractions/IStoreBackend.cs b/src/NexusMods.MneumonicDB.Storage/Abstractions/IStoreBackend.cs similarity index 91% rename from src/NexusMods.EventSourcing.Storage/Abstractions/IStoreBackend.cs rename to src/NexusMods.MneumonicDB.Storage/Abstractions/IStoreBackend.cs index 8885acce..57282920 100644 --- a/src/NexusMods.EventSourcing.Storage/Abstractions/IStoreBackend.cs +++ b/src/NexusMods.MneumonicDB.Storage/Abstractions/IStoreBackend.cs @@ -1,9 +1,9 @@ using System; -using NexusMods.EventSourcing.Abstractions; -using NexusMods.EventSourcing.Storage.Abstractions.ElementComparers; +using NexusMods.MneumonicDB.Abstractions; +using NexusMods.MneumonicDB.Storage.Abstractions.ElementComparers; using NexusMods.Paths; -namespace NexusMods.EventSourcing.Storage.Abstractions; +namespace NexusMods.MneumonicDB.Storage.Abstractions; public interface IStoreBackend : IDisposable { diff --git a/src/NexusMods.EventSourcing.Storage/Abstractions/IWriteBatch.cs b/src/NexusMods.MneumonicDB.Storage/Abstractions/IWriteBatch.cs similarity index 80% rename from src/NexusMods.EventSourcing.Storage/Abstractions/IWriteBatch.cs rename to src/NexusMods.MneumonicDB.Storage/Abstractions/IWriteBatch.cs index 32382237..fc14cb5f 100644 --- a/src/NexusMods.EventSourcing.Storage/Abstractions/IWriteBatch.cs +++ b/src/NexusMods.MneumonicDB.Storage/Abstractions/IWriteBatch.cs @@ -1,6 +1,6 @@ using System; -namespace NexusMods.EventSourcing.Storage.Abstractions; +namespace NexusMods.MneumonicDB.Storage.Abstractions; public interface IWriteBatch : IDisposable { diff --git a/src/NexusMods.MneumonicDB.Storage/Abstractions/KeyPrefix.cs b/src/NexusMods.MneumonicDB.Storage/Abstractions/KeyPrefix.cs new file mode 100644 index 00000000..fe3ee260 --- /dev/null +++ b/src/NexusMods.MneumonicDB.Storage/Abstractions/KeyPrefix.cs @@ -0,0 +1 @@ +namespace NexusMods.MneumonicDB.Storage.Abstractions; diff --git a/src/NexusMods.EventSourcing.Storage/AttributeRegistry.cs b/src/NexusMods.MneumonicDB.Storage/AttributeRegistry.cs similarity index 97% rename from src/NexusMods.EventSourcing.Storage/AttributeRegistry.cs rename to src/NexusMods.MneumonicDB.Storage/AttributeRegistry.cs index 68286258..f016441c 100644 --- a/src/NexusMods.EventSourcing.Storage/AttributeRegistry.cs +++ b/src/NexusMods.MneumonicDB.Storage/AttributeRegistry.cs @@ -4,11 +4,11 @@ using System.Linq; using System.Linq.Expressions; using System.Runtime.InteropServices; -using NexusMods.EventSourcing.Abstractions; -using NexusMods.EventSourcing.Abstractions.Internals; +using NexusMods.MneumonicDB.Abstractions; +using NexusMods.MneumonicDB.Abstractions.Internals; using Reloaded.Memory.Extensions; -namespace NexusMods.EventSourcing.Storage; +namespace NexusMods.MneumonicDB.Storage; /// /// Tracks all attributes and their respective serializers as well as the DB entity IDs for each diff --git a/src/NexusMods.EventSourcing.Storage/BuiltInAttributes.cs b/src/NexusMods.MneumonicDB.Storage/BuiltInAttributes.cs similarity index 84% rename from src/NexusMods.EventSourcing.Storage/BuiltInAttributes.cs rename to src/NexusMods.MneumonicDB.Storage/BuiltInAttributes.cs index 9cbf9e41..1551351e 100644 --- a/src/NexusMods.EventSourcing.Storage/BuiltInAttributes.cs +++ b/src/NexusMods.MneumonicDB.Storage/BuiltInAttributes.cs @@ -1,7 +1,7 @@ -using NexusMods.EventSourcing.Abstractions; -using NexusMods.EventSourcing.Storage.Serializers; +using NexusMods.MneumonicDB.Abstractions; +using NexusMods.MneumonicDB.Storage.Serializers; -namespace NexusMods.EventSourcing.Storage; +namespace NexusMods.MneumonicDB.Storage; public static class BuiltInAttributes { @@ -9,7 +9,7 @@ public static class BuiltInAttributes /// Static unique id of the UniqueId attribute /// private static readonly Symbol UniqueIdStaticId = - Symbol.InternPreSanitized("NexusMods.EventSourcing.DatomStore/UniqueId"); + Symbol.InternPreSanitized("NexusMods.MneumonicDB.DatomStore/UniqueId"); /// /// The database entity id of the UniqueId attribute @@ -20,7 +20,7 @@ public static class BuiltInAttributes /// Static unique id of the UniqueId attribute /// private static readonly Symbol ValueSerializerIdStaticId = - Symbol.InternPreSanitized("NexusMods.EventSourcing.DatomStore/ValueSerializerId"); + Symbol.InternPreSanitized("NexusMods.MneumonicDB.DatomStore/ValueSerializerId"); /// /// The database entity id of the UniqueId attribute @@ -55,5 +55,5 @@ public class UniqueId() : ScalarAttribute(UniqueIdStaticId); /// The unique id if the IValueSerializer used to serialize the value of the attribute. /// public class ValueSerializerId() - : ScalarAttribute("NexusMods.EventSourcing.DatomStore/ValueSerializerId"); + : ScalarAttribute("NexusMods.MneumonicDB.DatomStore/ValueSerializerId"); } diff --git a/src/NexusMods.EventSourcing.Storage/Configuration.cs b/src/NexusMods.MneumonicDB.Storage/Configuration.cs similarity index 74% rename from src/NexusMods.EventSourcing.Storage/Configuration.cs rename to src/NexusMods.MneumonicDB.Storage/Configuration.cs index 667bd6d3..c8425a88 100644 --- a/src/NexusMods.EventSourcing.Storage/Configuration.cs +++ b/src/NexusMods.MneumonicDB.Storage/Configuration.cs @@ -1,4 +1,4 @@ -namespace NexusMods.EventSourcing.Storage; +namespace NexusMods.MneumonicDB.Storage; public static class Configuration { diff --git a/src/NexusMods.EventSourcing.Storage/DatomStorageStructures/PendingTransaction.cs b/src/NexusMods.MneumonicDB.Storage/DatomStorageStructures/PendingTransaction.cs similarity index 84% rename from src/NexusMods.EventSourcing.Storage/DatomStorageStructures/PendingTransaction.cs rename to src/NexusMods.MneumonicDB.Storage/DatomStorageStructures/PendingTransaction.cs index 50f3e34c..bb6a8d62 100644 --- a/src/NexusMods.EventSourcing.Storage/DatomStorageStructures/PendingTransaction.cs +++ b/src/NexusMods.MneumonicDB.Storage/DatomStorageStructures/PendingTransaction.cs @@ -1,7 +1,7 @@ using System.Threading.Tasks; -using NexusMods.EventSourcing.Abstractions; +using NexusMods.MneumonicDB.Abstractions; -namespace NexusMods.EventSourcing.Storage.DatomStorageStructures; +namespace NexusMods.MneumonicDB.Storage.DatomStorageStructures; /// /// Information about a pending transaction, and a way to signal its completion. diff --git a/src/NexusMods.EventSourcing.Storage/DatomStore.cs b/src/NexusMods.MneumonicDB.Storage/DatomStore.cs similarity index 96% rename from src/NexusMods.EventSourcing.Storage/DatomStore.cs rename to src/NexusMods.MneumonicDB.Storage/DatomStore.cs index 67f69a93..aebd0522 100644 --- a/src/NexusMods.EventSourcing.Storage/DatomStore.cs +++ b/src/NexusMods.MneumonicDB.Storage/DatomStore.cs @@ -9,14 +9,14 @@ using System.Threading.Channels; using System.Threading.Tasks; using Microsoft.Extensions.Logging; -using NexusMods.EventSourcing.Abstractions; -using NexusMods.EventSourcing.Abstractions.DatomIterators; -using NexusMods.EventSourcing.Abstractions.Internals; -using NexusMods.EventSourcing.Storage.Abstractions; -using NexusMods.EventSourcing.Storage.DatomStorageStructures; +using NexusMods.MneumonicDB.Abstractions; +using NexusMods.MneumonicDB.Abstractions.DatomIterators; +using NexusMods.MneumonicDB.Abstractions.Internals; +using NexusMods.MneumonicDB.Storage.Abstractions; +using NexusMods.MneumonicDB.Storage.DatomStorageStructures; using Reloaded.Memory.Extensions; -namespace NexusMods.EventSourcing.Storage; +namespace NexusMods.MneumonicDB.Storage; public class DatomStore : IDatomStore { @@ -233,7 +233,6 @@ private async Task ConsumeTransactions() Remaps = new Dictionary(), AssignedTxId = _asOfTxId, Snapshot = _backend.GetSnapshot(), - Datoms = Array.Empty() }; pendingTransaction.CompletionSource.SetResult(storeResult); continue; @@ -329,8 +328,6 @@ private EntityId MaybeRemap(EntityId id, Dictionary remaps, private void Log(PendingTransaction pendingTransaction, out StoreResult result) { - var output = new List(); - var thisTx = TxId.From(_asOfTxId.Value + 1); @@ -410,7 +407,6 @@ private void Log(PendingTransaction pendingTransaction, out StoreResult result) { AssignedTxId = thisTx, Remaps = remaps, - Datoms = output, Snapshot = _backend.GetSnapshot() }; _asOfTxId = thisTx; diff --git a/src/NexusMods.EventSourcing.Storage/InMemoryBackend/Backend.cs b/src/NexusMods.MneumonicDB.Storage/InMemoryBackend/Backend.cs similarity index 85% rename from src/NexusMods.EventSourcing.Storage/InMemoryBackend/Backend.cs rename to src/NexusMods.MneumonicDB.Storage/InMemoryBackend/Backend.cs index 77c8a626..c0199e8d 100644 --- a/src/NexusMods.EventSourcing.Storage/InMemoryBackend/Backend.cs +++ b/src/NexusMods.MneumonicDB.Storage/InMemoryBackend/Backend.cs @@ -1,11 +1,11 @@ using System; using System.Linq; -using NexusMods.EventSourcing.Abstractions; -using NexusMods.EventSourcing.Storage.Abstractions; +using NexusMods.MneumonicDB.Abstractions; +using NexusMods.MneumonicDB.Storage.Abstractions; using NexusMods.Paths; -using IWriteBatch = NexusMods.EventSourcing.Storage.Abstractions.IWriteBatch; +using IWriteBatch = NexusMods.MneumonicDB.Storage.Abstractions.IWriteBatch; -namespace NexusMods.EventSourcing.Storage.InMemoryBackend; +namespace NexusMods.MneumonicDB.Storage.InMemoryBackend; public class Backend : IStoreBackend { diff --git a/src/NexusMods.EventSourcing.Storage/InMemoryBackend/Batch.cs b/src/NexusMods.MneumonicDB.Storage/InMemoryBackend/Batch.cs similarity index 85% rename from src/NexusMods.EventSourcing.Storage/InMemoryBackend/Batch.cs rename to src/NexusMods.MneumonicDB.Storage/InMemoryBackend/Batch.cs index a80cb6da..5db8cb44 100644 --- a/src/NexusMods.EventSourcing.Storage/InMemoryBackend/Batch.cs +++ b/src/NexusMods.MneumonicDB.Storage/InMemoryBackend/Batch.cs @@ -1,10 +1,10 @@ using System; using System.Collections.Generic; -using NexusMods.EventSourcing.Abstractions; -using NexusMods.EventSourcing.Storage.Abstractions; -using IWriteBatch = NexusMods.EventSourcing.Storage.Abstractions.IWriteBatch; +using NexusMods.MneumonicDB.Abstractions; +using NexusMods.MneumonicDB.Storage.Abstractions; +using IWriteBatch = NexusMods.MneumonicDB.Storage.Abstractions.IWriteBatch; -namespace NexusMods.EventSourcing.Storage.InMemoryBackend; +namespace NexusMods.MneumonicDB.Storage.InMemoryBackend; public class Batch(IndexStore[] stores) : IWriteBatch { diff --git a/src/NexusMods.EventSourcing.Storage/InMemoryBackend/IInMemoryIndex.cs b/src/NexusMods.MneumonicDB.Storage/InMemoryBackend/IInMemoryIndex.cs similarity index 68% rename from src/NexusMods.EventSourcing.Storage/InMemoryBackend/IInMemoryIndex.cs rename to src/NexusMods.MneumonicDB.Storage/InMemoryBackend/IInMemoryIndex.cs index 241686fc..ccf5d7dc 100644 --- a/src/NexusMods.EventSourcing.Storage/InMemoryBackend/IInMemoryIndex.cs +++ b/src/NexusMods.MneumonicDB.Storage/InMemoryBackend/IInMemoryIndex.cs @@ -1,6 +1,6 @@ using System.Collections.Immutable; -namespace NexusMods.EventSourcing.Storage.InMemoryBackend; +namespace NexusMods.MneumonicDB.Storage.InMemoryBackend; public interface IInMemoryIndex { diff --git a/src/NexusMods.EventSourcing.Storage/InMemoryBackend/Index.cs b/src/NexusMods.MneumonicDB.Storage/InMemoryBackend/Index.cs similarity index 84% rename from src/NexusMods.EventSourcing.Storage/InMemoryBackend/Index.cs rename to src/NexusMods.MneumonicDB.Storage/InMemoryBackend/Index.cs index 94c014d3..a25569e6 100644 --- a/src/NexusMods.EventSourcing.Storage/InMemoryBackend/Index.cs +++ b/src/NexusMods.MneumonicDB.Storage/InMemoryBackend/Index.cs @@ -1,9 +1,9 @@ using System; using System.Collections.Generic; using System.Collections.Immutable; -using NexusMods.EventSourcing.Storage.Abstractions; +using NexusMods.MneumonicDB.Storage.Abstractions; -namespace NexusMods.EventSourcing.Storage.InMemoryBackend; +namespace NexusMods.MneumonicDB.Storage.InMemoryBackend; public class Index(AttributeRegistry registry, IndexStore store) : AIndex(registry, store), IInMemoryIndex, IComparer diff --git a/src/NexusMods.EventSourcing.Storage/InMemoryBackend/IndexStore.cs b/src/NexusMods.MneumonicDB.Storage/InMemoryBackend/IndexStore.cs similarity index 82% rename from src/NexusMods.EventSourcing.Storage/InMemoryBackend/IndexStore.cs rename to src/NexusMods.MneumonicDB.Storage/InMemoryBackend/IndexStore.cs index e74cf0a9..d0fe3480 100644 --- a/src/NexusMods.EventSourcing.Storage/InMemoryBackend/IndexStore.cs +++ b/src/NexusMods.MneumonicDB.Storage/InMemoryBackend/IndexStore.cs @@ -1,10 +1,10 @@ using System.Collections.Generic; using System.Collections.Immutable; -using NexusMods.EventSourcing.Abstractions; -using NexusMods.EventSourcing.Abstractions.DatomIterators; -using NexusMods.EventSourcing.Storage.Abstractions; +using NexusMods.MneumonicDB.Abstractions; +using NexusMods.MneumonicDB.Abstractions.DatomIterators; +using NexusMods.MneumonicDB.Storage.Abstractions; -namespace NexusMods.EventSourcing.Storage.InMemoryBackend; +namespace NexusMods.MneumonicDB.Storage.InMemoryBackend; public class IndexStore : IIndexStore { diff --git a/src/NexusMods.EventSourcing.Storage/InMemoryBackend/Snapshot.cs b/src/NexusMods.MneumonicDB.Storage/InMemoryBackend/Snapshot.cs similarity index 75% rename from src/NexusMods.EventSourcing.Storage/InMemoryBackend/Snapshot.cs rename to src/NexusMods.MneumonicDB.Storage/InMemoryBackend/Snapshot.cs index 2295874e..48969614 100644 --- a/src/NexusMods.EventSourcing.Storage/InMemoryBackend/Snapshot.cs +++ b/src/NexusMods.MneumonicDB.Storage/InMemoryBackend/Snapshot.cs @@ -1,8 +1,8 @@ using System.Collections.Immutable; -using NexusMods.EventSourcing.Abstractions; -using NexusMods.EventSourcing.Abstractions.DatomIterators; +using NexusMods.MneumonicDB.Abstractions; +using NexusMods.MneumonicDB.Abstractions.DatomIterators; -namespace NexusMods.EventSourcing.Storage.InMemoryBackend; +namespace NexusMods.MneumonicDB.Storage.InMemoryBackend; public class Snapshot : ISnapshot { diff --git a/src/NexusMods.EventSourcing.Storage/InMemoryBackend/SortedSetIterator.cs b/src/NexusMods.MneumonicDB.Storage/InMemoryBackend/SortedSetIterator.cs similarity index 87% rename from src/NexusMods.EventSourcing.Storage/InMemoryBackend/SortedSetIterator.cs rename to src/NexusMods.MneumonicDB.Storage/InMemoryBackend/SortedSetIterator.cs index 1c0aaa46..465a9490 100644 --- a/src/NexusMods.EventSourcing.Storage/InMemoryBackend/SortedSetIterator.cs +++ b/src/NexusMods.MneumonicDB.Storage/InMemoryBackend/SortedSetIterator.cs @@ -1,9 +1,9 @@ using System; using System.Collections.Immutable; -using NexusMods.EventSourcing.Abstractions.DatomIterators; -using NexusMods.EventSourcing.Abstractions.Internals; +using NexusMods.MneumonicDB.Abstractions.DatomIterators; +using NexusMods.MneumonicDB.Abstractions.Internals; -namespace NexusMods.EventSourcing.Storage.InMemoryBackend; +namespace NexusMods.MneumonicDB.Storage.InMemoryBackend; public class SortedSetIterator : IDatomSource, IIterator { diff --git a/src/NexusMods.EventSourcing.Storage/NexusMods.EventSourcing.Storage.csproj b/src/NexusMods.MneumonicDB.Storage/NexusMods.MneumonicDB.Storage.csproj similarity index 90% rename from src/NexusMods.EventSourcing.Storage/NexusMods.EventSourcing.Storage.csproj rename to src/NexusMods.MneumonicDB.Storage/NexusMods.MneumonicDB.Storage.csproj index be595e7d..7b249128 100644 --- a/src/NexusMods.EventSourcing.Storage/NexusMods.EventSourcing.Storage.csproj +++ b/src/NexusMods.MneumonicDB.Storage/NexusMods.MneumonicDB.Storage.csproj @@ -20,7 +20,7 @@ - + diff --git a/src/NexusMods.EventSourcing.Storage/PooledMemoryBufferWriter.cs b/src/NexusMods.MneumonicDB.Storage/PooledMemoryBufferWriter.cs similarity index 98% rename from src/NexusMods.EventSourcing.Storage/PooledMemoryBufferWriter.cs rename to src/NexusMods.MneumonicDB.Storage/PooledMemoryBufferWriter.cs index 157f45fb..c40a7c61 100644 --- a/src/NexusMods.EventSourcing.Storage/PooledMemoryBufferWriter.cs +++ b/src/NexusMods.MneumonicDB.Storage/PooledMemoryBufferWriter.cs @@ -4,7 +4,7 @@ using System.Runtime.CompilerServices; using Reloaded.Memory.Extensions; -namespace NexusMods.EventSourcing.Storage; +namespace NexusMods.MneumonicDB.Storage; /// /// A IBufferWriter that uses pooled memory to reduce allocations. diff --git a/src/NexusMods.EventSourcing.Storage/RocksDbBackend/Backend.cs b/src/NexusMods.MneumonicDB.Storage/RocksDbBackend/Backend.cs similarity index 87% rename from src/NexusMods.EventSourcing.Storage/RocksDbBackend/Backend.cs rename to src/NexusMods.MneumonicDB.Storage/RocksDbBackend/Backend.cs index 9ea4dccd..3c6ec63e 100644 --- a/src/NexusMods.EventSourcing.Storage/RocksDbBackend/Backend.cs +++ b/src/NexusMods.MneumonicDB.Storage/RocksDbBackend/Backend.cs @@ -1,12 +1,12 @@ using System.Collections.Generic; -using NexusMods.EventSourcing.Abstractions; -using NexusMods.EventSourcing.Abstractions.DatomIterators; -using NexusMods.EventSourcing.Storage.Abstractions; +using NexusMods.MneumonicDB.Abstractions; +using NexusMods.MneumonicDB.Abstractions.DatomIterators; +using NexusMods.MneumonicDB.Storage.Abstractions; using NexusMods.Paths; using RocksDbSharp; -using IWriteBatch = NexusMods.EventSourcing.Storage.Abstractions.IWriteBatch; +using IWriteBatch = NexusMods.MneumonicDB.Storage.Abstractions.IWriteBatch; -namespace NexusMods.EventSourcing.Storage.RocksDbBackend; +namespace NexusMods.MneumonicDB.Storage.RocksDbBackend; public class Backend(AttributeRegistry registry) : IStoreBackend { @@ -50,7 +50,7 @@ public void Init(AbsolutePath location) var options = new DbOptions() .SetCreateIfMissing() .SetCreateMissingColumnFamilies() - .SetCompression(Compression.Zstd); + .SetCompression(Compression.Lz4); foreach (var (name, store) in _stores) { diff --git a/src/NexusMods.EventSourcing.Storage/RocksDbBackend/Batch.cs b/src/NexusMods.MneumonicDB.Storage/RocksDbBackend/Batch.cs similarity index 74% rename from src/NexusMods.EventSourcing.Storage/RocksDbBackend/Batch.cs rename to src/NexusMods.MneumonicDB.Storage/RocksDbBackend/Batch.cs index 5bb5b093..e3b78e59 100644 --- a/src/NexusMods.EventSourcing.Storage/RocksDbBackend/Batch.cs +++ b/src/NexusMods.MneumonicDB.Storage/RocksDbBackend/Batch.cs @@ -1,9 +1,9 @@ using System; -using NexusMods.EventSourcing.Storage.Abstractions; +using NexusMods.MneumonicDB.Storage.Abstractions; using RocksDbSharp; -using IWriteBatch = NexusMods.EventSourcing.Storage.Abstractions.IWriteBatch; +using IWriteBatch = NexusMods.MneumonicDB.Storage.Abstractions.IWriteBatch; -namespace NexusMods.EventSourcing.Storage.RocksDbBackend; +namespace NexusMods.MneumonicDB.Storage.RocksDbBackend; public class Batch(RocksDb db) : IWriteBatch { diff --git a/src/NexusMods.MneumonicDB.Storage/RocksDbBackend/IRocksDbIndex.cs b/src/NexusMods.MneumonicDB.Storage/RocksDbBackend/IRocksDbIndex.cs new file mode 100644 index 00000000..471a53e5 --- /dev/null +++ b/src/NexusMods.MneumonicDB.Storage/RocksDbBackend/IRocksDbIndex.cs @@ -0,0 +1,3 @@ +namespace NexusMods.MneumonicDB.Storage.RocksDbBackend; + +public interface IRocksDbIndex { } diff --git a/src/NexusMods.EventSourcing.Storage/RocksDbBackend/Index.cs b/src/NexusMods.MneumonicDB.Storage/RocksDbBackend/Index.cs similarity index 74% rename from src/NexusMods.EventSourcing.Storage/RocksDbBackend/Index.cs rename to src/NexusMods.MneumonicDB.Storage/RocksDbBackend/Index.cs index 4051cbb2..93ca09a9 100644 --- a/src/NexusMods.EventSourcing.Storage/RocksDbBackend/Index.cs +++ b/src/NexusMods.MneumonicDB.Storage/RocksDbBackend/Index.cs @@ -1,6 +1,6 @@ -using NexusMods.EventSourcing.Storage.Abstractions; +using NexusMods.MneumonicDB.Storage.Abstractions; -namespace NexusMods.EventSourcing.Storage.RocksDbBackend; +namespace NexusMods.MneumonicDB.Storage.RocksDbBackend; public class Index(AttributeRegistry registry, IndexStore store) : AIndex(registry, store), IRocksDbIndex diff --git a/src/NexusMods.EventSourcing.Storage/RocksDbBackend/IndexStore.cs b/src/NexusMods.MneumonicDB.Storage/RocksDbBackend/IndexStore.cs similarity index 89% rename from src/NexusMods.EventSourcing.Storage/RocksDbBackend/IndexStore.cs rename to src/NexusMods.MneumonicDB.Storage/RocksDbBackend/IndexStore.cs index 8c470930..091a791f 100644 --- a/src/NexusMods.EventSourcing.Storage/RocksDbBackend/IndexStore.cs +++ b/src/NexusMods.MneumonicDB.Storage/RocksDbBackend/IndexStore.cs @@ -1,11 +1,11 @@ using System; using System.Runtime.InteropServices; -using NexusMods.EventSourcing.Abstractions; -using NexusMods.EventSourcing.Abstractions.DatomIterators; -using NexusMods.EventSourcing.Storage.Abstractions; +using NexusMods.MneumonicDB.Abstractions; +using NexusMods.MneumonicDB.Abstractions.DatomIterators; +using NexusMods.MneumonicDB.Storage.Abstractions; using RocksDbSharp; -namespace NexusMods.EventSourcing.Storage.RocksDbBackend; +namespace NexusMods.MneumonicDB.Storage.RocksDbBackend; public class IndexStore : IIndexStore { diff --git a/src/NexusMods.EventSourcing.Storage/RocksDbBackend/IteratorWrapper.cs b/src/NexusMods.MneumonicDB.Storage/RocksDbBackend/IteratorWrapper.cs similarity index 85% rename from src/NexusMods.EventSourcing.Storage/RocksDbBackend/IteratorWrapper.cs rename to src/NexusMods.MneumonicDB.Storage/RocksDbBackend/IteratorWrapper.cs index 3d11c9ab..72da0cfb 100644 --- a/src/NexusMods.EventSourcing.Storage/RocksDbBackend/IteratorWrapper.cs +++ b/src/NexusMods.MneumonicDB.Storage/RocksDbBackend/IteratorWrapper.cs @@ -1,9 +1,9 @@ using System; -using NexusMods.EventSourcing.Abstractions.DatomIterators; -using NexusMods.EventSourcing.Abstractions.Internals; +using NexusMods.MneumonicDB.Abstractions.DatomIterators; +using NexusMods.MneumonicDB.Abstractions.Internals; using RocksDbSharp; -namespace NexusMods.EventSourcing.Storage.RocksDbBackend; +namespace NexusMods.MneumonicDB.Storage.RocksDbBackend; internal class IteratorWrapper : IDatomSource, IIterator { diff --git a/src/NexusMods.MneumonicDB.Storage/RocksDbBackend/Snapshot.cs b/src/NexusMods.MneumonicDB.Storage/RocksDbBackend/Snapshot.cs new file mode 100644 index 00000000..67cfa1e4 --- /dev/null +++ b/src/NexusMods.MneumonicDB.Storage/RocksDbBackend/Snapshot.cs @@ -0,0 +1,3 @@ +namespace NexusMods.MneumonicDB.Storage.RocksDbBackend; + +public class Snapshot(Backend backend) { } diff --git a/src/NexusMods.EventSourcing.Storage/Serializers/EntityIdSerializer.cs b/src/NexusMods.MneumonicDB.Storage/Serializers/EntityIdSerializer.cs similarity index 91% rename from src/NexusMods.EventSourcing.Storage/Serializers/EntityIdSerializer.cs rename to src/NexusMods.MneumonicDB.Storage/Serializers/EntityIdSerializer.cs index 500c8785..848bcf7e 100644 --- a/src/NexusMods.EventSourcing.Storage/Serializers/EntityIdSerializer.cs +++ b/src/NexusMods.MneumonicDB.Storage/Serializers/EntityIdSerializer.cs @@ -1,9 +1,9 @@ using System; using System.Buffers; using System.Runtime.InteropServices; -using NexusMods.EventSourcing.Abstractions; +using NexusMods.MneumonicDB.Abstractions; -namespace NexusMods.EventSourcing.Storage.Serializers; +namespace NexusMods.MneumonicDB.Storage.Serializers; public class EntityIdSerializer : IValueSerializer { diff --git a/src/NexusMods.EventSourcing.Storage/Serializers/StringSerializer.cs b/src/NexusMods.MneumonicDB.Storage/Serializers/StringSerializer.cs similarity index 91% rename from src/NexusMods.EventSourcing.Storage/Serializers/StringSerializer.cs rename to src/NexusMods.MneumonicDB.Storage/Serializers/StringSerializer.cs index 5c1c63cd..202f1bbc 100644 --- a/src/NexusMods.EventSourcing.Storage/Serializers/StringSerializer.cs +++ b/src/NexusMods.MneumonicDB.Storage/Serializers/StringSerializer.cs @@ -1,9 +1,9 @@ using System; using System.Buffers; using System.Text; -using NexusMods.EventSourcing.Abstractions; +using NexusMods.MneumonicDB.Abstractions; -namespace NexusMods.EventSourcing.Storage.Serializers; +namespace NexusMods.MneumonicDB.Storage.Serializers; public class StringSerializer : IValueSerializer { diff --git a/src/NexusMods.EventSourcing.Storage/Serializers/SymbolSerializer.cs b/src/NexusMods.MneumonicDB.Storage/Serializers/SymbolSerializer.cs similarity index 92% rename from src/NexusMods.EventSourcing.Storage/Serializers/SymbolSerializer.cs rename to src/NexusMods.MneumonicDB.Storage/Serializers/SymbolSerializer.cs index 27748e13..7104ac21 100644 --- a/src/NexusMods.EventSourcing.Storage/Serializers/SymbolSerializer.cs +++ b/src/NexusMods.MneumonicDB.Storage/Serializers/SymbolSerializer.cs @@ -1,9 +1,9 @@ using System; using System.Buffers; using System.Text; -using NexusMods.EventSourcing.Abstractions; +using NexusMods.MneumonicDB.Abstractions; -namespace NexusMods.EventSourcing.Storage.Serializers; +namespace NexusMods.MneumonicDB.Storage.Serializers; public class SymbolSerializer : IValueSerializer { diff --git a/src/NexusMods.EventSourcing.Storage/Serializers/TxIdSerializer.cs b/src/NexusMods.MneumonicDB.Storage/Serializers/TxIdSerializer.cs similarity index 90% rename from src/NexusMods.EventSourcing.Storage/Serializers/TxIdSerializer.cs rename to src/NexusMods.MneumonicDB.Storage/Serializers/TxIdSerializer.cs index 4f5a0a3f..7b9b2ccf 100644 --- a/src/NexusMods.EventSourcing.Storage/Serializers/TxIdSerializer.cs +++ b/src/NexusMods.MneumonicDB.Storage/Serializers/TxIdSerializer.cs @@ -1,9 +1,9 @@ using System; using System.Buffers; using System.Runtime.InteropServices; -using NexusMods.EventSourcing.Abstractions; +using NexusMods.MneumonicDB.Abstractions; -namespace NexusMods.EventSourcing.Storage.Serializers; +namespace NexusMods.MneumonicDB.Storage.Serializers; public class TxIdSerializer : IValueSerializer { diff --git a/src/NexusMods.EventSourcing.Storage/Serializers/UInt64Serializer.cs b/src/NexusMods.MneumonicDB.Storage/Serializers/UInt64Serializer.cs similarity index 92% rename from src/NexusMods.EventSourcing.Storage/Serializers/UInt64Serializer.cs rename to src/NexusMods.MneumonicDB.Storage/Serializers/UInt64Serializer.cs index c6e279aa..77275e63 100644 --- a/src/NexusMods.EventSourcing.Storage/Serializers/UInt64Serializer.cs +++ b/src/NexusMods.MneumonicDB.Storage/Serializers/UInt64Serializer.cs @@ -1,9 +1,9 @@ using System; using System.Buffers; using System.Runtime.InteropServices; -using NexusMods.EventSourcing.Abstractions; +using NexusMods.MneumonicDB.Abstractions; -namespace NexusMods.EventSourcing.Storage.Serializers; +namespace NexusMods.MneumonicDB.Storage.Serializers; public class UInt64Serializer : IValueSerializer { diff --git a/src/NexusMods.EventSourcing.Storage/Services.cs b/src/NexusMods.MneumonicDB.Storage/Services.cs similarity index 75% rename from src/NexusMods.EventSourcing.Storage/Services.cs rename to src/NexusMods.MneumonicDB.Storage/Services.cs index 58fdf812..4b319e7e 100644 --- a/src/NexusMods.EventSourcing.Storage/Services.cs +++ b/src/NexusMods.MneumonicDB.Storage/Services.cs @@ -1,14 +1,14 @@ using Microsoft.Extensions.DependencyInjection; -using NexusMods.EventSourcing.Abstractions; -using NexusMods.EventSourcing.Storage.Abstractions; -using NexusMods.EventSourcing.Storage.RocksDbBackend; -using NexusMods.EventSourcing.Storage.Serializers; +using NexusMods.MneumonicDB.Abstractions; +using NexusMods.MneumonicDB.Storage.Abstractions; +using NexusMods.MneumonicDB.Storage.RocksDbBackend; +using NexusMods.MneumonicDB.Storage.Serializers; -namespace NexusMods.EventSourcing.Storage; +namespace NexusMods.MneumonicDB.Storage; public static class Services { - public static IServiceCollection AddEventSourcingStorage(this IServiceCollection services) + public static IServiceCollection AddMneumonicDBStorage(this IServiceCollection services) { services.AddValueSerializer(); services.AddValueSerializer(); diff --git a/src/NexusMods.MneumonicDB/CommitResult.cs b/src/NexusMods.MneumonicDB/CommitResult.cs new file mode 100644 index 00000000..2dd03a79 --- /dev/null +++ b/src/NexusMods.MneumonicDB/CommitResult.cs @@ -0,0 +1,21 @@ +using System.Collections.Generic; +using NexusMods.MneumonicDB.Abstractions; +using NexusMods.MneumonicDB.Abstractions.Models; + +namespace NexusMods.MneumonicDB; + +/// +public class CommitResult(IDb db, IDictionary remaps) : ICommitResult +{ + /// + public EntityId this[EntityId id] => + remaps.TryGetValue(id, out var found) ? found : id; + + public T Remap(T model) where T : IReadModel + { + return db.Get(remaps[model.Id]); + } + + /// + public TxId NewTx => db.BasisTxId; +} diff --git a/src/NexusMods.EventSourcing/Connection.cs b/src/NexusMods.MneumonicDB/Connection.cs similarity index 92% rename from src/NexusMods.EventSourcing/Connection.cs rename to src/NexusMods.MneumonicDB/Connection.cs index 915f0955..1e849c90 100644 --- a/src/NexusMods.EventSourcing/Connection.cs +++ b/src/NexusMods.MneumonicDB/Connection.cs @@ -4,10 +4,10 @@ using System.Reactive.Linq; using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; -using NexusMods.EventSourcing.Abstractions; -using NexusMods.EventSourcing.Storage; +using NexusMods.MneumonicDB.Abstractions; +using NexusMods.MneumonicDB.Storage; -namespace NexusMods.EventSourcing; +namespace NexusMods.MneumonicDB; /// /// Main connection class, co-ordinates writes and immutable reads @@ -99,7 +99,7 @@ private async Task AddMissingAttributes(IEnumerable valueSeria private IEnumerable ExistingAttributes() { var db = Db; - var attrIds = db.Datoms(IndexType.AEVTCurrent) + var attrIds = db.Datoms() .Select(d => d.E); foreach (var attrId in attrIds) @@ -127,7 +127,8 @@ private IEnumerable ExistingAttributes() public async Task Transact(IEnumerable datoms) { var newTx = await _store.Transact(datoms); - var result = new CommitResult(newTx.AssignedTxId, newTx.Remaps); + var result = new CommitResult(new Db(newTx.Snapshot, this, newTx.AssignedTxId, (AttributeRegistry)_store.Registry) + , newTx.Remaps); return result; } } diff --git a/src/NexusMods.EventSourcing/Db.cs b/src/NexusMods.MneumonicDB/Db.cs similarity index 87% rename from src/NexusMods.EventSourcing/Db.cs rename to src/NexusMods.MneumonicDB/Db.cs index 9f12742d..35192d47 100644 --- a/src/NexusMods.EventSourcing/Db.cs +++ b/src/NexusMods.MneumonicDB/Db.cs @@ -1,10 +1,10 @@ using System.Collections.Generic; -using NexusMods.EventSourcing.Abstractions; -using NexusMods.EventSourcing.Abstractions.DatomIterators; -using NexusMods.EventSourcing.Abstractions.Models; -using NexusMods.EventSourcing.Storage; +using NexusMods.MneumonicDB.Abstractions; +using NexusMods.MneumonicDB.Abstractions.DatomIterators; +using NexusMods.MneumonicDB.Abstractions.Models; +using NexusMods.MneumonicDB.Storage; -namespace NexusMods.EventSourcing; +namespace NexusMods.MneumonicDB; internal class Db : IDb { @@ -101,17 +101,22 @@ public IEnumerable Datoms(TxId txId) yield return datom; } - public IEnumerable Datoms(IndexType type) + public IEnumerable Datoms() where TAttribute : IAttribute { var a = _registry.GetAttributeId(); - using var iterator = _snapshot.GetIterator(type); + using var iterator = _snapshot.GetIterator(IndexType.AEVTCurrent); foreach (var datom in iterator - .SeekStart() + .SeekTo(a) .While(a) .Resolve()) yield return datom; } + public IDatomSource Iterate(IndexType index) + { + return _snapshot.GetIterator(index); + } + public void Dispose() { } } diff --git a/src/NexusMods.EventSourcing/ModelReflector.cs b/src/NexusMods.MneumonicDB/ModelReflector.cs similarity index 86% rename from src/NexusMods.EventSourcing/ModelReflector.cs rename to src/NexusMods.MneumonicDB/ModelReflector.cs index a4d2c89d..43be3905 100644 --- a/src/NexusMods.EventSourcing/ModelReflector.cs +++ b/src/NexusMods.MneumonicDB/ModelReflector.cs @@ -5,10 +5,10 @@ using System.Linq; using System.Linq.Expressions; using System.Reflection; -using NexusMods.EventSourcing.Abstractions; -using NexusMods.EventSourcing.Abstractions.Models; +using NexusMods.MneumonicDB.Abstractions; +using NexusMods.MneumonicDB.Abstractions.Models; -namespace NexusMods.EventSourcing; +namespace NexusMods.MneumonicDB; /// /// Reflects over models and creates reader/writer functions for them. @@ -67,24 +67,6 @@ private EmitterFn CreateEmitter(Type readModel) return lambda.Compile(); } - private Func GetConstructor(Type readModel) - { - if (_constructors.TryGetValue(readModel, out var found)) - return (Func)found; - - var ctor = readModel.GetConstructor(new[] { typeof(IDb), typeof(EntityId) })!; - var dbParameter = Expression.Parameter(typeof(IDb), "db"); - var idParameter = Expression.Parameter(typeof(EntityId), "id"); - var model = Expression.New(ctor, dbParameter, idParameter); - var casted = Expression.Convert(model, typeof(object)); - - var lambda = Expression.Lambda>(casted, dbParameter, idParameter); - var compiled = lambda.Compile(); - - _constructors.TryAdd(readModel, compiled); - return compiled; - } - private static IEnumerable<(Type Attribute, PropertyInfo Property)> GetModelProperties(Type readModel) { var properties = readModel diff --git a/src/NexusMods.EventSourcing/NexusMods.EventSourcing.csproj b/src/NexusMods.MneumonicDB/NexusMods.MneumonicDB.csproj similarity index 77% rename from src/NexusMods.EventSourcing/NexusMods.EventSourcing.csproj rename to src/NexusMods.MneumonicDB/NexusMods.MneumonicDB.csproj index c1d5cdb0..f670dd66 100644 --- a/src/NexusMods.EventSourcing/NexusMods.EventSourcing.csproj +++ b/src/NexusMods.MneumonicDB/NexusMods.MneumonicDB.csproj @@ -1,6 +1,6 @@ - NexusMods.EventSourcing + NexusMods.MneumonicDB @@ -13,8 +13,8 @@ - - + + diff --git a/src/NexusMods.EventSourcing/Services.cs b/src/NexusMods.MneumonicDB/Services.cs similarity index 71% rename from src/NexusMods.EventSourcing/Services.cs rename to src/NexusMods.MneumonicDB/Services.cs index 54bb9d97..95d3b96f 100644 --- a/src/NexusMods.EventSourcing/Services.cs +++ b/src/NexusMods.MneumonicDB/Services.cs @@ -1,7 +1,7 @@ using Microsoft.Extensions.DependencyInjection; -using NexusMods.EventSourcing.Abstractions; +using NexusMods.MneumonicDB.Abstractions; -namespace NexusMods.EventSourcing; +namespace NexusMods.MneumonicDB; /// /// Extension methods for adding attributes and other types to the service collection. @@ -11,7 +11,7 @@ public static class Services /// /// Registers the event sourcing services with the service collection. /// - public static IServiceCollection AddEventSourcing(this IServiceCollection services) + public static IServiceCollection AddMneumonicDB(this IServiceCollection services) { services.AddSingleton(); return services; diff --git a/src/NexusMods.EventSourcing/Transaction.cs b/src/NexusMods.MneumonicDB/Transaction.cs similarity index 89% rename from src/NexusMods.EventSourcing/Transaction.cs rename to src/NexusMods.MneumonicDB/Transaction.cs index f97490f0..87dfde72 100644 --- a/src/NexusMods.EventSourcing/Transaction.cs +++ b/src/NexusMods.MneumonicDB/Transaction.cs @@ -1,10 +1,10 @@ using System.Collections.Concurrent; using System.Threading; using System.Threading.Tasks; -using NexusMods.EventSourcing.Abstractions; -using NexusMods.EventSourcing.Abstractions.Models; +using NexusMods.MneumonicDB.Abstractions; +using NexusMods.MneumonicDB.Abstractions.Models; -namespace NexusMods.EventSourcing; +namespace NexusMods.MneumonicDB; /// internal class Transaction(Connection connection) : ITransaction diff --git a/tests/NexusMods.EventSourcing.Storage.Tests/TestHelpers.cs b/tests/NexusMods.EventSourcing.Storage.Tests/TestHelpers.cs deleted file mode 100644 index d8016e8b..00000000 --- a/tests/NexusMods.EventSourcing.Storage.Tests/TestHelpers.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace NexusMods.EventSourcing.Storage.Tests; - -public class TestHelpers { } diff --git a/tests/NexusMods.EventSourcing.TestModel/ComplexModel/ReadModels/File.cs b/tests/NexusMods.EventSourcing.TestModel/ComplexModel/ReadModels/File.cs deleted file mode 100644 index 55d5b7cc..00000000 --- a/tests/NexusMods.EventSourcing.TestModel/ComplexModel/ReadModels/File.cs +++ /dev/null @@ -1,29 +0,0 @@ -using NexusMods.EventSourcing.Abstractions; -using NexusMods.EventSourcing.Abstractions.Models; -using NexusMods.Hashing.xxHash64; -using NexusMods.Paths; -using FileAttributes = NexusMods.EventSourcing.TestModel.ComplexModel.Attributes.FileAttributes; - -namespace NexusMods.EventSourcing.TestModel.ComplexModel.ReadModels; - -public class File(ITransaction? tx) : AReadModel(tx) -{ - [From] public required RelativePath Name { get; set; } - - [From] public required Size Size { get; set; } - - [From] public required Hash Hash { get; set; } - - [From] public required EntityId ModId { get; init; } - - public static File Create(ITransaction tx, string s, Mod mod, Size fromLong, Hash hash) - { - return new File(tx) - { - Name = s, - Size = fromLong, - Hash = hash, - ModId = mod.Id - }; - } -} diff --git a/tests/NexusMods.EventSourcing.TestModel/Model/ArchiveFile.cs b/tests/NexusMods.EventSourcing.TestModel/Model/ArchiveFile.cs deleted file mode 100644 index ba7bf25e..00000000 --- a/tests/NexusMods.EventSourcing.TestModel/Model/ArchiveFile.cs +++ /dev/null @@ -1,32 +0,0 @@ -using NexusMods.EventSourcing.Abstractions; -using NexusMods.EventSourcing.Abstractions.Models; -using NexusMods.EventSourcing.TestModel.Model.Attributes; - -namespace NexusMods.EventSourcing.TestModel.Model; - -public class ArchiveFile(ITransaction? tx) : AReadModel(tx) -{ - /// - /// Base attribute - /// - [From] - public required string ModPath { get; init; } - - /// - /// Base attribute - /// - [From] - public required string Path { get; init; } - - /// - /// Example of "inheritance" of attributes from other namespaces - /// - [From] - public required ulong Hash { get; init; } - - /// - /// The index of the file in the archive used for debugging purposes - /// - [From] - public required ulong Index { get; init; } -} diff --git a/tests/NexusMods.EventSourcing.TestModel/Model/Attributes/ArchiveFileAttributes.cs b/tests/NexusMods.EventSourcing.TestModel/Model/Attributes/ArchiveFileAttributes.cs deleted file mode 100644 index 1a258525..00000000 --- a/tests/NexusMods.EventSourcing.TestModel/Model/Attributes/ArchiveFileAttributes.cs +++ /dev/null @@ -1,16 +0,0 @@ -using NexusMods.EventSourcing.Abstractions; - -namespace NexusMods.EventSourcing.TestModel.Model.Attributes; - -public static class ArchiveFileAttributes -{ - /// - /// Extra attribute with a different name - /// - public class ArchiveHash : ScalarAttribute; - - /// - /// Overlapping name with ModFileAttributes.Path - /// - public class Path : ScalarAttribute; -} diff --git a/tests/NexusMods.EventSourcing.TestModel/Model/Attributes/LoadoutAttributes.cs b/tests/NexusMods.EventSourcing.TestModel/Model/Attributes/LoadoutAttributes.cs deleted file mode 100644 index bd6e840b..00000000 --- a/tests/NexusMods.EventSourcing.TestModel/Model/Attributes/LoadoutAttributes.cs +++ /dev/null @@ -1,16 +0,0 @@ -using NexusMods.EventSourcing.Abstractions; - -namespace NexusMods.EventSourcing.TestModel.Model.Attributes; - -public class LoadoutAttributes -{ - /// - /// Name of the loadout - /// - public class Name : ScalarAttribute; - - /// - /// The last transaction that updated the loadout - /// - public class UpdatedTx : ScalarAttribute; -} diff --git a/tests/NexusMods.EventSourcing.TestModel/Model/Attributes/ModAttributes.cs b/tests/NexusMods.EventSourcing.TestModel/Model/Attributes/ModAttributes.cs deleted file mode 100644 index 04a2502a..00000000 --- a/tests/NexusMods.EventSourcing.TestModel/Model/Attributes/ModAttributes.cs +++ /dev/null @@ -1,21 +0,0 @@ -using NexusMods.EventSourcing.Abstractions; - -namespace NexusMods.EventSourcing.TestModel.Model.Attributes; - -public class ModAttributes -{ - /// - /// Name of the loadout - /// - public class Name : ScalarAttribute; - - /// - /// The last transaction that updated the loadout - /// - public class UpdatedTx : ScalarAttribute; - - /// - /// The id of the loadout this mod belongs to - /// - public class LoadoutId : ScalarAttribute; -} diff --git a/tests/NexusMods.EventSourcing.TestModel/Model/Attributes/ModFileAttributes.cs b/tests/NexusMods.EventSourcing.TestModel/Model/Attributes/ModFileAttributes.cs deleted file mode 100644 index 00cf1e62..00000000 --- a/tests/NexusMods.EventSourcing.TestModel/Model/Attributes/ModFileAttributes.cs +++ /dev/null @@ -1,12 +0,0 @@ -using NexusMods.EventSourcing.Abstractions; - -namespace NexusMods.EventSourcing.TestModel.Model.Attributes; - -public static class ModFileAttributes -{ - public class Hash : ScalarAttribute; - - public class Path : ScalarAttribute; - - public class Index : ScalarAttribute; -} diff --git a/tests/NexusMods.EventSourcing.TestModel/Model/File.cs b/tests/NexusMods.EventSourcing.TestModel/Model/File.cs deleted file mode 100644 index b0169b14..00000000 --- a/tests/NexusMods.EventSourcing.TestModel/Model/File.cs +++ /dev/null @@ -1,26 +0,0 @@ -using NexusMods.EventSourcing.Abstractions; -using NexusMods.EventSourcing.Abstractions.Models; -using NexusMods.EventSourcing.TestModel.Model.Attributes; - -namespace NexusMods.EventSourcing.TestModel.Model; - -public class File(ITransaction? tx) : AReadModel(tx) -{ - /// - /// Base attribute - /// - [From] - public required string Path { get; init; } - - /// - /// Example of "inheritance" of attributes from other namespaces - /// - [From] - public required ulong Hash { get; init; } - - /// - /// The index of the file in the archive used for debugging purposes - /// - [From] - public required ulong Index { get; init; } -} diff --git a/tests/NexusMods.EventSourcing.TestModel/Model/Loadout.cs b/tests/NexusMods.EventSourcing.TestModel/Model/Loadout.cs deleted file mode 100644 index 4083ffff..00000000 --- a/tests/NexusMods.EventSourcing.TestModel/Model/Loadout.cs +++ /dev/null @@ -1,50 +0,0 @@ -using NexusMods.EventSourcing.Abstractions; -using NexusMods.EventSourcing.Abstractions.Models; -using NexusMods.EventSourcing.TestModel.Model.Attributes; - -namespace NexusMods.EventSourcing.TestModel.Model; - -public class Loadout(ITransaction? tx) : AReadModel(tx) -{ - /// - /// The name of the loadout. - /// - [From] - public required string Name { get; init; } - - /// - /// The last tx that updated the loadout. - /// - [From] - public required TxId Invalidator { get; init; } - - /// - /// The mods in the loadout. - /// - public IEnumerable Mods => GetReverse(); - - - /// - /// Create a new loadout with the given name. - /// - /// - /// - /// - public static Loadout Create(ITransaction tx, string name) - { - return new Loadout(tx) - { - Name = name, - Invalidator = tx.ThisTxId - }; - } - - /// - /// Updates this loadout marking it as touched by the given transaction. - /// - /// - public void Touch(ITransaction tx) - { - LoadoutAttributes.UpdatedTx.Add(tx, Id, tx.ThisTxId); - } -} diff --git a/tests/NexusMods.EventSourcing.TestModel/Model/Mod.cs b/tests/NexusMods.EventSourcing.TestModel/Model/Mod.cs deleted file mode 100644 index a26110f7..00000000 --- a/tests/NexusMods.EventSourcing.TestModel/Model/Mod.cs +++ /dev/null @@ -1,34 +0,0 @@ -using NexusMods.EventSourcing.Abstractions; -using NexusMods.EventSourcing.Abstractions.Models; -using NexusMods.EventSourcing.TestModel.Model.Attributes; - -namespace NexusMods.EventSourcing.TestModel.Model; - -public class Mod(ITransaction? tx) : AReadModel(tx) -{ - [From] public required string Name { get; init; } - - - [From] public required EntityId LoadoutId { get; init; } - - /// - /// The loadout for this mod. - /// - public Loadout Loadout => Get(LoadoutId); - - - public static Mod Create(ITransaction tx, string name, EntityId loadoutId) - { - var mod = new Mod(tx) - { - Name = name, - LoadoutId = loadoutId - }; - return mod; - } - - public void Touch(ITransaction tx) - { - Loadout.Touch(tx); - } -} diff --git a/tests/NexusMods.EventSourcing.TestModel/Services.cs b/tests/NexusMods.EventSourcing.TestModel/Services.cs deleted file mode 100644 index d2702610..00000000 --- a/tests/NexusMods.EventSourcing.TestModel/Services.cs +++ /dev/null @@ -1,35 +0,0 @@ -using Microsoft.Extensions.DependencyInjection; -using NexusMods.EventSourcing.Abstractions; -using NexusMods.EventSourcing.TestModel.Model.Attributes; -using NexusMods.EventSourcing.TestModel.ValueSerializers; -using FileAttributes = NexusMods.EventSourcing.TestModel.ComplexModel.Attributes.FileAttributes; - -namespace NexusMods.EventSourcing.TestModel; - -public static class Services -{ - public static IServiceCollection AddTestModel(this IServiceCollection services) - { - services.AddAttribute() - .AddAttribute() - .AddAttribute() - .AddAttribute() - .AddAttribute() - .AddAttribute() - .AddAttribute() - .AddAttribute() - .AddAttribute() - .AddAttribute(); - - services.AddAttributeCollection() - .AddAttributeCollection() - .AddAttributeCollection(); - - services.AddValueSerializer() - .AddValueSerializer() - .AddValueSerializer() - .AddValueSerializer(); - - return services; - } -} diff --git a/tests/NexusMods.EventSourcing.Tests/AEventSourcingTest.cs b/tests/NexusMods.EventSourcing.Tests/AEventSourcingTest.cs deleted file mode 100644 index c17f6521..00000000 --- a/tests/NexusMods.EventSourcing.Tests/AEventSourcingTest.cs +++ /dev/null @@ -1,71 +0,0 @@ -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; -using NexusMods.EventSourcing.Abstractions; -using NexusMods.EventSourcing.Storage; -using NexusMods.EventSourcing.Storage.RocksDbBackend; -using NexusMods.Paths; - -namespace NexusMods.EventSourcing.Tests; - -public class AEventSourcingTest : IAsyncLifetime -{ - private readonly IAttribute[] _attributes; - private readonly IServiceProvider _provider; - private readonly AttributeRegistry _registry; - private readonly IValueSerializer[] _valueSerializers; - private Backend _backend; - - private DatomStore _store; - protected Connection Connection = null!; - protected ILogger Logger; - - - protected AEventSourcingTest(IServiceProvider provider) - { - _provider = provider; - _valueSerializers = provider.GetRequiredService>().ToArray(); - _attributes = provider.GetRequiredService>().ToArray(); - - _registry = new AttributeRegistry(_valueSerializers, _attributes); - - Config = new DatomStoreSettings - { - Path = FileSystem.Shared.GetKnownPath(KnownPath.EntryDirectory) - .Combine("tests_eventsourcing" + Guid.NewGuid()) - }; - _backend = new Backend(_registry); - - _store = new DatomStore(provider.GetRequiredService>(), _registry, Config, _backend); - - Logger = provider.GetRequiredService>(); - } - - protected DatomStoreSettings Config { get; set; } - - public async Task InitializeAsync() - { - await _store.Sync(); - - Connection = await Connection.Start(_store, _valueSerializers, _attributes); - } - - public Task DisposeAsync() - { - _store.Dispose(); - return Task.CompletedTask; - } - - - protected async Task RestartDatomStore() - { - _store.Dispose(); - _backend.Dispose(); - - - _backend = new Backend(_registry); - _store = new DatomStore(_provider.GetRequiredService>(), _registry, Config, _backend); - await _store.Sync(); - - Connection = await Connection.Start(_store, _valueSerializers, _attributes); - } -} diff --git a/tests/NexusMods.EventSourcing.Storage.Tests/ABackendTest.cs b/tests/NexusMods.MneumonicDB.Storage.Tests/ABackendTest.cs similarity index 85% rename from tests/NexusMods.EventSourcing.Storage.Tests/ABackendTest.cs rename to tests/NexusMods.MneumonicDB.Storage.Tests/ABackendTest.cs index f5848561..1aff00b7 100644 --- a/tests/NexusMods.EventSourcing.Storage.Tests/ABackendTest.cs +++ b/tests/NexusMods.MneumonicDB.Storage.Tests/ABackendTest.cs @@ -1,13 +1,13 @@ -using NexusMods.EventSourcing.Abstractions; -using NexusMods.EventSourcing.Storage.Abstractions; -using NexusMods.EventSourcing.TestModel.ComplexModel.Attributes; -using NexusMods.EventSourcing.TestModel.Helpers; +using NexusMods.MneumonicDB.Abstractions; +using NexusMods.MneumonicDB.Storage.Abstractions; +using NexusMods.MneumonicDB.TestModel.ComplexModel.Attributes; +using NexusMods.MneumonicDB.TestModel.Helpers; using NexusMods.Hashing.xxHash64; using NexusMods.Paths; -using FileAttributes = NexusMods.EventSourcing.TestModel.ComplexModel.Attributes.FileAttributes; +using FileAttributes = NexusMods.MneumonicDB.TestModel.ComplexModel.Attributes.FileAttributes; -namespace NexusMods.EventSourcing.Storage.Tests; +namespace NexusMods.MneumonicDB.Storage.Tests; public abstract class ABackendTest( IServiceProvider provider, diff --git a/tests/NexusMods.EventSourcing.Storage.Tests/AStorageTest.cs b/tests/NexusMods.MneumonicDB.Storage.Tests/AStorageTest.cs similarity index 84% rename from tests/NexusMods.EventSourcing.Storage.Tests/AStorageTest.cs rename to tests/NexusMods.MneumonicDB.Storage.Tests/AStorageTest.cs index 5eaf8647..b90d8c0b 100644 --- a/tests/NexusMods.EventSourcing.Storage.Tests/AStorageTest.cs +++ b/tests/NexusMods.MneumonicDB.Storage.Tests/AStorageTest.cs @@ -1,15 +1,15 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -using NexusMods.EventSourcing.Abstractions; -using NexusMods.EventSourcing.Storage.Abstractions; -using NexusMods.EventSourcing.Storage.RocksDbBackend; -using NexusMods.EventSourcing.Storage.Serializers; -using NexusMods.EventSourcing.TestModel.ComplexModel.Attributes; -using NexusMods.EventSourcing.TestModel.ValueSerializers; +using NexusMods.MneumonicDB.Abstractions; +using NexusMods.MneumonicDB.Storage.Abstractions; +using NexusMods.MneumonicDB.Storage.RocksDbBackend; +using NexusMods.MneumonicDB.Storage.Serializers; +using NexusMods.MneumonicDB.TestModel.ComplexModel.Attributes; +using NexusMods.MneumonicDB.TestModel.ValueSerializers; using NexusMods.Paths; -using FileAttributes = NexusMods.EventSourcing.TestModel.ComplexModel.Attributes.FileAttributes; +using FileAttributes = NexusMods.MneumonicDB.TestModel.ComplexModel.Attributes.FileAttributes; -namespace NexusMods.EventSourcing.Storage.Tests; +namespace NexusMods.MneumonicDB.Storage.Tests; public abstract class AStorageTest : IAsyncLifetime { diff --git a/tests/NexusMods.EventSourcing.Storage.Tests/BackendTestVerifyData/InMemoryTests.InsertedDatomsShowUpInTheIndex_type=AEVTCurrent.verified.txt b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/InMemoryTests.InsertedDatomsShowUpInTheIndex_type=AEVTCurrent.verified.txt similarity index 85% rename from tests/NexusMods.EventSourcing.Storage.Tests/BackendTestVerifyData/InMemoryTests.InsertedDatomsShowUpInTheIndex_type=AEVTCurrent.verified.txt rename to tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/InMemoryTests.InsertedDatomsShowUpInTheIndex_type=AEVTCurrent.verified.txt index c7a07ac4..37dd02de 100644 --- a/tests/NexusMods.EventSourcing.Storage.Tests/BackendTestVerifyData/InMemoryTests.InsertedDatomsShowUpInTheIndex_type=AEVTCurrent.verified.txt +++ b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/InMemoryTests.InsertedDatomsShowUpInTheIndex_type=AEVTCurrent.verified.txt @@ -1,7 +1,7 @@ -+ | 0000000000000001 | (0001) UniqueId | NexusMods.EventSourcing.DatomStore/UniqueId | 0100000000000001 -+ | 0000000000000002 | (0001) UniqueId | NexusMods.EventSourcin...tore/ValueSerializerId | 0100000000000001 -+ | 0000000000000001 | (0002) ValueSerializerId | NexusMods.EventSourcin...izers/SymbolSerializer | 0100000000000001 -+ | 0000000000000002 | (0002) ValueSerializerId | NexusMods.EventSourcin...izers/SymbolSerializer | 0100000000000001 ++ | 0000000000000001 | (0001) UniqueId | NexusMods.MneumonicDB.DatomStore/UniqueId | 0100000000000001 ++ | 0000000000000002 | (0001) UniqueId | NexusMods.MneumonicDB....tore/ValueSerializerId | 0100000000000001 ++ | 0000000000000001 | (0002) ValueSerializerId | NexusMods.MneumonicDB....izers/SymbolSerializer | 0100000000000001 ++ | 0000000000000002 | (0002) ValueSerializerId | NexusMods.MneumonicDB....izers/SymbolSerializer | 0100000000000001 + | 0200000000000001 | (0014) Path | /foo/bar | 0100000000000002 + | 0200000000000002 | (0014) Path | /foo/qux | 0100000000000003 + | 0200000000000001 | (0015) Hash | 0x00000000DEADBEEF | 0100000000000002 diff --git a/tests/NexusMods.EventSourcing.Storage.Tests/BackendTestVerifyData/InMemoryTests.InsertedDatomsShowUpInTheIndex_type=AEVTHistory.verified.txt b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/InMemoryTests.InsertedDatomsShowUpInTheIndex_type=AEVTHistory.verified.txt similarity index 100% rename from tests/NexusMods.EventSourcing.Storage.Tests/BackendTestVerifyData/InMemoryTests.InsertedDatomsShowUpInTheIndex_type=AEVTHistory.verified.txt rename to tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/InMemoryTests.InsertedDatomsShowUpInTheIndex_type=AEVTHistory.verified.txt diff --git a/tests/NexusMods.EventSourcing.Storage.Tests/BackendTestVerifyData/InMemoryTests.InsertedDatomsShowUpInTheIndex_type=AVETCurrent.verified.txt b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/InMemoryTests.InsertedDatomsShowUpInTheIndex_type=AVETCurrent.verified.txt similarity index 100% rename from tests/NexusMods.EventSourcing.Storage.Tests/BackendTestVerifyData/InMemoryTests.InsertedDatomsShowUpInTheIndex_type=AVETCurrent.verified.txt rename to tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/InMemoryTests.InsertedDatomsShowUpInTheIndex_type=AVETCurrent.verified.txt diff --git a/tests/NexusMods.EventSourcing.Storage.Tests/BackendTestVerifyData/InMemoryTests.InsertedDatomsShowUpInTheIndex_type=AVETHistory.verified.txt b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/InMemoryTests.InsertedDatomsShowUpInTheIndex_type=AVETHistory.verified.txt similarity index 100% rename from tests/NexusMods.EventSourcing.Storage.Tests/BackendTestVerifyData/InMemoryTests.InsertedDatomsShowUpInTheIndex_type=AVETHistory.verified.txt rename to tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/InMemoryTests.InsertedDatomsShowUpInTheIndex_type=AVETHistory.verified.txt diff --git a/tests/NexusMods.EventSourcing.Storage.Tests/BackendTestVerifyData/InMemoryTests.InsertedDatomsShowUpInTheIndex_type=EAVTCurrent.verified.txt b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/InMemoryTests.InsertedDatomsShowUpInTheIndex_type=EAVTCurrent.verified.txt similarity index 85% rename from tests/NexusMods.EventSourcing.Storage.Tests/BackendTestVerifyData/InMemoryTests.InsertedDatomsShowUpInTheIndex_type=EAVTCurrent.verified.txt rename to tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/InMemoryTests.InsertedDatomsShowUpInTheIndex_type=EAVTCurrent.verified.txt index 7e6104f8..7697dd73 100644 --- a/tests/NexusMods.EventSourcing.Storage.Tests/BackendTestVerifyData/InMemoryTests.InsertedDatomsShowUpInTheIndex_type=EAVTCurrent.verified.txt +++ b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/InMemoryTests.InsertedDatomsShowUpInTheIndex_type=EAVTCurrent.verified.txt @@ -1,7 +1,7 @@ -+ | 0000000000000001 | (0001) UniqueId | NexusMods.EventSourcing.DatomStore/UniqueId | 0100000000000001 -+ | 0000000000000001 | (0002) ValueSerializerId | NexusMods.EventSourcin...izers/SymbolSerializer | 0100000000000001 -+ | 0000000000000002 | (0001) UniqueId | NexusMods.EventSourcin...tore/ValueSerializerId | 0100000000000001 -+ | 0000000000000002 | (0002) ValueSerializerId | NexusMods.EventSourcin...izers/SymbolSerializer | 0100000000000001 ++ | 0000000000000001 | (0001) UniqueId | NexusMods.MneumonicDB.DatomStore/UniqueId | 0100000000000001 ++ | 0000000000000001 | (0002) ValueSerializerId | NexusMods.MneumonicDB....izers/SymbolSerializer | 0100000000000001 ++ | 0000000000000002 | (0001) UniqueId | NexusMods.MneumonicDB....tore/ValueSerializerId | 0100000000000001 ++ | 0000000000000002 | (0002) ValueSerializerId | NexusMods.MneumonicDB....izers/SymbolSerializer | 0100000000000001 + | 0200000000000001 | (0014) Path | /foo/bar | 0100000000000002 + | 0200000000000001 | (0015) Hash | 0x00000000DEADBEEF | 0100000000000002 + | 0200000000000001 | (0016) Size | 42 B | 0100000000000002 diff --git a/tests/NexusMods.EventSourcing.Storage.Tests/BackendTestVerifyData/InMemoryTests.InsertedDatomsShowUpInTheIndex_type=EAVTHistory.verified.txt b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/InMemoryTests.InsertedDatomsShowUpInTheIndex_type=EAVTHistory.verified.txt similarity index 100% rename from tests/NexusMods.EventSourcing.Storage.Tests/BackendTestVerifyData/InMemoryTests.InsertedDatomsShowUpInTheIndex_type=EAVTHistory.verified.txt rename to tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/InMemoryTests.InsertedDatomsShowUpInTheIndex_type=EAVTHistory.verified.txt diff --git a/tests/NexusMods.EventSourcing.Storage.Tests/BackendTestVerifyData/InMemoryTests.InsertedDatomsShowUpInTheIndex_type=TxLog.verified.txt b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/InMemoryTests.InsertedDatomsShowUpInTheIndex_type=TxLog.verified.txt similarity index 87% rename from tests/NexusMods.EventSourcing.Storage.Tests/BackendTestVerifyData/InMemoryTests.InsertedDatomsShowUpInTheIndex_type=TxLog.verified.txt rename to tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/InMemoryTests.InsertedDatomsShowUpInTheIndex_type=TxLog.verified.txt index f698a279..cd4a6676 100644 --- a/tests/NexusMods.EventSourcing.Storage.Tests/BackendTestVerifyData/InMemoryTests.InsertedDatomsShowUpInTheIndex_type=TxLog.verified.txt +++ b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/InMemoryTests.InsertedDatomsShowUpInTheIndex_type=TxLog.verified.txt @@ -1,7 +1,7 @@ -+ | 0000000000000001 | (0001) UniqueId | NexusMods.EventSourcing.DatomStore/UniqueId | 0100000000000001 -+ | 0000000000000001 | (0002) ValueSerializerId | NexusMods.EventSourcin...izers/SymbolSerializer | 0100000000000001 -+ | 0000000000000002 | (0001) UniqueId | NexusMods.EventSourcin...tore/ValueSerializerId | 0100000000000001 -+ | 0000000000000002 | (0002) ValueSerializerId | NexusMods.EventSourcin...izers/SymbolSerializer | 0100000000000001 ++ | 0000000000000001 | (0001) UniqueId | NexusMods.MneumonicDB.DatomStore/UniqueId | 0100000000000001 ++ | 0000000000000001 | (0002) ValueSerializerId | NexusMods.MneumonicDB....izers/SymbolSerializer | 0100000000000001 ++ | 0000000000000002 | (0001) UniqueId | NexusMods.MneumonicDB....tore/ValueSerializerId | 0100000000000001 ++ | 0000000000000002 | (0002) ValueSerializerId | NexusMods.MneumonicDB....izers/SymbolSerializer | 0100000000000001 + | 0200000000000001 | (0014) Path | /foo/bar | 0100000000000002 + | 0200000000000001 | (0015) Hash | 0x00000000DEADBEEF | 0100000000000002 + | 0200000000000001 | (0016) Size | 42 B | 0100000000000002 diff --git a/tests/NexusMods.EventSourcing.Storage.Tests/BackendTestVerifyData/InMemoryTests.InsertedDatomsShowUpInTheIndex_type=VAETCurrent.verified.txt b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/InMemoryTests.InsertedDatomsShowUpInTheIndex_type=VAETCurrent.verified.txt similarity index 100% rename from tests/NexusMods.EventSourcing.Storage.Tests/BackendTestVerifyData/InMemoryTests.InsertedDatomsShowUpInTheIndex_type=VAETCurrent.verified.txt rename to tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/InMemoryTests.InsertedDatomsShowUpInTheIndex_type=VAETCurrent.verified.txt diff --git a/tests/NexusMods.EventSourcing.Storage.Tests/BackendTestVerifyData/InMemoryTests.InsertedDatomsShowUpInTheIndex_type=VAETHistory.verified.txt b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/InMemoryTests.InsertedDatomsShowUpInTheIndex_type=VAETHistory.verified.txt similarity index 100% rename from tests/NexusMods.EventSourcing.Storage.Tests/BackendTestVerifyData/InMemoryTests.InsertedDatomsShowUpInTheIndex_type=VAETHistory.verified.txt rename to tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/InMemoryTests.InsertedDatomsShowUpInTheIndex_type=VAETHistory.verified.txt diff --git a/tests/NexusMods.EventSourcing.Storage.Tests/BackendTestVerifyData/RocksDB.InsertedDatomsShowUpInTheIndex_type=AEVTCurrent.verified.txt b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/RocksDB.InsertedDatomsShowUpInTheIndex_type=AEVTCurrent.verified.txt similarity index 85% rename from tests/NexusMods.EventSourcing.Storage.Tests/BackendTestVerifyData/RocksDB.InsertedDatomsShowUpInTheIndex_type=AEVTCurrent.verified.txt rename to tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/RocksDB.InsertedDatomsShowUpInTheIndex_type=AEVTCurrent.verified.txt index c7a07ac4..37dd02de 100644 --- a/tests/NexusMods.EventSourcing.Storage.Tests/BackendTestVerifyData/RocksDB.InsertedDatomsShowUpInTheIndex_type=AEVTCurrent.verified.txt +++ b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/RocksDB.InsertedDatomsShowUpInTheIndex_type=AEVTCurrent.verified.txt @@ -1,7 +1,7 @@ -+ | 0000000000000001 | (0001) UniqueId | NexusMods.EventSourcing.DatomStore/UniqueId | 0100000000000001 -+ | 0000000000000002 | (0001) UniqueId | NexusMods.EventSourcin...tore/ValueSerializerId | 0100000000000001 -+ | 0000000000000001 | (0002) ValueSerializerId | NexusMods.EventSourcin...izers/SymbolSerializer | 0100000000000001 -+ | 0000000000000002 | (0002) ValueSerializerId | NexusMods.EventSourcin...izers/SymbolSerializer | 0100000000000001 ++ | 0000000000000001 | (0001) UniqueId | NexusMods.MneumonicDB.DatomStore/UniqueId | 0100000000000001 ++ | 0000000000000002 | (0001) UniqueId | NexusMods.MneumonicDB....tore/ValueSerializerId | 0100000000000001 ++ | 0000000000000001 | (0002) ValueSerializerId | NexusMods.MneumonicDB....izers/SymbolSerializer | 0100000000000001 ++ | 0000000000000002 | (0002) ValueSerializerId | NexusMods.MneumonicDB....izers/SymbolSerializer | 0100000000000001 + | 0200000000000001 | (0014) Path | /foo/bar | 0100000000000002 + | 0200000000000002 | (0014) Path | /foo/qux | 0100000000000003 + | 0200000000000001 | (0015) Hash | 0x00000000DEADBEEF | 0100000000000002 diff --git a/tests/NexusMods.EventSourcing.Storage.Tests/BackendTestVerifyData/RocksDB.InsertedDatomsShowUpInTheIndex_type=AEVTHistory.verified.txt b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/RocksDB.InsertedDatomsShowUpInTheIndex_type=AEVTHistory.verified.txt similarity index 100% rename from tests/NexusMods.EventSourcing.Storage.Tests/BackendTestVerifyData/RocksDB.InsertedDatomsShowUpInTheIndex_type=AEVTHistory.verified.txt rename to tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/RocksDB.InsertedDatomsShowUpInTheIndex_type=AEVTHistory.verified.txt diff --git a/tests/NexusMods.EventSourcing.Storage.Tests/BackendTestVerifyData/RocksDB.InsertedDatomsShowUpInTheIndex_type=AVETCurrent.verified.txt b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/RocksDB.InsertedDatomsShowUpInTheIndex_type=AVETCurrent.verified.txt similarity index 100% rename from tests/NexusMods.EventSourcing.Storage.Tests/BackendTestVerifyData/RocksDB.InsertedDatomsShowUpInTheIndex_type=AVETCurrent.verified.txt rename to tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/RocksDB.InsertedDatomsShowUpInTheIndex_type=AVETCurrent.verified.txt diff --git a/tests/NexusMods.EventSourcing.Storage.Tests/BackendTestVerifyData/RocksDB.InsertedDatomsShowUpInTheIndex_type=AVETHistory.verified.txt b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/RocksDB.InsertedDatomsShowUpInTheIndex_type=AVETHistory.verified.txt similarity index 100% rename from tests/NexusMods.EventSourcing.Storage.Tests/BackendTestVerifyData/RocksDB.InsertedDatomsShowUpInTheIndex_type=AVETHistory.verified.txt rename to tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/RocksDB.InsertedDatomsShowUpInTheIndex_type=AVETHistory.verified.txt diff --git a/tests/NexusMods.EventSourcing.Storage.Tests/BackendTestVerifyData/RocksDB.InsertedDatomsShowUpInTheIndex_type=EAVTCurrent.verified.txt b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/RocksDB.InsertedDatomsShowUpInTheIndex_type=EAVTCurrent.verified.txt similarity index 85% rename from tests/NexusMods.EventSourcing.Storage.Tests/BackendTestVerifyData/RocksDB.InsertedDatomsShowUpInTheIndex_type=EAVTCurrent.verified.txt rename to tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/RocksDB.InsertedDatomsShowUpInTheIndex_type=EAVTCurrent.verified.txt index 7e6104f8..7697dd73 100644 --- a/tests/NexusMods.EventSourcing.Storage.Tests/BackendTestVerifyData/RocksDB.InsertedDatomsShowUpInTheIndex_type=EAVTCurrent.verified.txt +++ b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/RocksDB.InsertedDatomsShowUpInTheIndex_type=EAVTCurrent.verified.txt @@ -1,7 +1,7 @@ -+ | 0000000000000001 | (0001) UniqueId | NexusMods.EventSourcing.DatomStore/UniqueId | 0100000000000001 -+ | 0000000000000001 | (0002) ValueSerializerId | NexusMods.EventSourcin...izers/SymbolSerializer | 0100000000000001 -+ | 0000000000000002 | (0001) UniqueId | NexusMods.EventSourcin...tore/ValueSerializerId | 0100000000000001 -+ | 0000000000000002 | (0002) ValueSerializerId | NexusMods.EventSourcin...izers/SymbolSerializer | 0100000000000001 ++ | 0000000000000001 | (0001) UniqueId | NexusMods.MneumonicDB.DatomStore/UniqueId | 0100000000000001 ++ | 0000000000000001 | (0002) ValueSerializerId | NexusMods.MneumonicDB....izers/SymbolSerializer | 0100000000000001 ++ | 0000000000000002 | (0001) UniqueId | NexusMods.MneumonicDB....tore/ValueSerializerId | 0100000000000001 ++ | 0000000000000002 | (0002) ValueSerializerId | NexusMods.MneumonicDB....izers/SymbolSerializer | 0100000000000001 + | 0200000000000001 | (0014) Path | /foo/bar | 0100000000000002 + | 0200000000000001 | (0015) Hash | 0x00000000DEADBEEF | 0100000000000002 + | 0200000000000001 | (0016) Size | 42 B | 0100000000000002 diff --git a/tests/NexusMods.EventSourcing.Storage.Tests/BackendTestVerifyData/RocksDB.InsertedDatomsShowUpInTheIndex_type=EAVTHistory.verified.txt b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/RocksDB.InsertedDatomsShowUpInTheIndex_type=EAVTHistory.verified.txt similarity index 100% rename from tests/NexusMods.EventSourcing.Storage.Tests/BackendTestVerifyData/RocksDB.InsertedDatomsShowUpInTheIndex_type=EAVTHistory.verified.txt rename to tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/RocksDB.InsertedDatomsShowUpInTheIndex_type=EAVTHistory.verified.txt diff --git a/tests/NexusMods.EventSourcing.Storage.Tests/BackendTestVerifyData/RocksDB.InsertedDatomsShowUpInTheIndex_type=TxLog.verified.txt b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/RocksDB.InsertedDatomsShowUpInTheIndex_type=TxLog.verified.txt similarity index 87% rename from tests/NexusMods.EventSourcing.Storage.Tests/BackendTestVerifyData/RocksDB.InsertedDatomsShowUpInTheIndex_type=TxLog.verified.txt rename to tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/RocksDB.InsertedDatomsShowUpInTheIndex_type=TxLog.verified.txt index f698a279..cd4a6676 100644 --- a/tests/NexusMods.EventSourcing.Storage.Tests/BackendTestVerifyData/RocksDB.InsertedDatomsShowUpInTheIndex_type=TxLog.verified.txt +++ b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/RocksDB.InsertedDatomsShowUpInTheIndex_type=TxLog.verified.txt @@ -1,7 +1,7 @@ -+ | 0000000000000001 | (0001) UniqueId | NexusMods.EventSourcing.DatomStore/UniqueId | 0100000000000001 -+ | 0000000000000001 | (0002) ValueSerializerId | NexusMods.EventSourcin...izers/SymbolSerializer | 0100000000000001 -+ | 0000000000000002 | (0001) UniqueId | NexusMods.EventSourcin...tore/ValueSerializerId | 0100000000000001 -+ | 0000000000000002 | (0002) ValueSerializerId | NexusMods.EventSourcin...izers/SymbolSerializer | 0100000000000001 ++ | 0000000000000001 | (0001) UniqueId | NexusMods.MneumonicDB.DatomStore/UniqueId | 0100000000000001 ++ | 0000000000000001 | (0002) ValueSerializerId | NexusMods.MneumonicDB....izers/SymbolSerializer | 0100000000000001 ++ | 0000000000000002 | (0001) UniqueId | NexusMods.MneumonicDB....tore/ValueSerializerId | 0100000000000001 ++ | 0000000000000002 | (0002) ValueSerializerId | NexusMods.MneumonicDB....izers/SymbolSerializer | 0100000000000001 + | 0200000000000001 | (0014) Path | /foo/bar | 0100000000000002 + | 0200000000000001 | (0015) Hash | 0x00000000DEADBEEF | 0100000000000002 + | 0200000000000001 | (0016) Size | 42 B | 0100000000000002 diff --git a/tests/NexusMods.EventSourcing.Storage.Tests/BackendTestVerifyData/RocksDB.InsertedDatomsShowUpInTheIndex_type=VAETCurrent.verified.txt b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/RocksDB.InsertedDatomsShowUpInTheIndex_type=VAETCurrent.verified.txt similarity index 100% rename from tests/NexusMods.EventSourcing.Storage.Tests/BackendTestVerifyData/RocksDB.InsertedDatomsShowUpInTheIndex_type=VAETCurrent.verified.txt rename to tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/RocksDB.InsertedDatomsShowUpInTheIndex_type=VAETCurrent.verified.txt diff --git a/tests/NexusMods.EventSourcing.Storage.Tests/BackendTestVerifyData/RocksDB.InsertedDatomsShowUpInTheIndex_type=VAETHistory.verified.txt b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/RocksDB.InsertedDatomsShowUpInTheIndex_type=VAETHistory.verified.txt similarity index 100% rename from tests/NexusMods.EventSourcing.Storage.Tests/BackendTestVerifyData/RocksDB.InsertedDatomsShowUpInTheIndex_type=VAETHistory.verified.txt rename to tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/RocksDB.InsertedDatomsShowUpInTheIndex_type=VAETHistory.verified.txt diff --git a/tests/NexusMods.EventSourcing.Storage.Tests/BackendTests/InMemoryTests.cs b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTests/InMemoryTests.cs similarity index 52% rename from tests/NexusMods.EventSourcing.Storage.Tests/BackendTests/InMemoryTests.cs rename to tests/NexusMods.MneumonicDB.Storage.Tests/BackendTests/InMemoryTests.cs index 6f89d76d..f82a7e91 100644 --- a/tests/NexusMods.EventSourcing.Storage.Tests/BackendTests/InMemoryTests.cs +++ b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTests/InMemoryTests.cs @@ -1,6 +1,6 @@ -using NexusMods.EventSourcing.Storage.InMemoryBackend; +using NexusMods.MneumonicDB.Storage.InMemoryBackend; -namespace NexusMods.EventSourcing.Storage.Tests.BackendTests; +namespace NexusMods.MneumonicDB.Storage.Tests.BackendTests; public class InMemoryTests(IServiceProvider provider) : ABackendTest(provider, registry => new Backend(registry)) { } diff --git a/tests/NexusMods.EventSourcing.Storage.Tests/BackendTests/RocksDB.cs b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTests/RocksDB.cs similarity index 50% rename from tests/NexusMods.EventSourcing.Storage.Tests/BackendTests/RocksDB.cs rename to tests/NexusMods.MneumonicDB.Storage.Tests/BackendTests/RocksDB.cs index 58b6035c..d017194b 100644 --- a/tests/NexusMods.EventSourcing.Storage.Tests/BackendTests/RocksDB.cs +++ b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTests/RocksDB.cs @@ -1,5 +1,5 @@ -using NexusMods.EventSourcing.Storage.RocksDbBackend; +using NexusMods.MneumonicDB.Storage.RocksDbBackend; -namespace NexusMods.EventSourcing.Storage.Tests.BackendTests; +namespace NexusMods.MneumonicDB.Storage.Tests.BackendTests; public class RocksDB(IServiceProvider provider) : ABackendTest(provider, registry => new Backend(registry)) { } diff --git a/tests/NexusMods.EventSourcing.Storage.Tests/GlobalUsings.cs b/tests/NexusMods.MneumonicDB.Storage.Tests/GlobalUsings.cs similarity index 100% rename from tests/NexusMods.EventSourcing.Storage.Tests/GlobalUsings.cs rename to tests/NexusMods.MneumonicDB.Storage.Tests/GlobalUsings.cs diff --git a/tests/NexusMods.EventSourcing.Storage.Tests/KVStoreType.cs b/tests/NexusMods.MneumonicDB.Storage.Tests/KVStoreType.cs similarity index 51% rename from tests/NexusMods.EventSourcing.Storage.Tests/KVStoreType.cs rename to tests/NexusMods.MneumonicDB.Storage.Tests/KVStoreType.cs index 148b583d..5e8e74ac 100644 --- a/tests/NexusMods.EventSourcing.Storage.Tests/KVStoreType.cs +++ b/tests/NexusMods.MneumonicDB.Storage.Tests/KVStoreType.cs @@ -1,4 +1,4 @@ -namespace NexusMods.EventSourcing.Storage.Tests; +namespace NexusMods.MneumonicDB.Storage.Tests; public enum KVStoreType { diff --git a/tests/NexusMods.EventSourcing.Storage.Tests/NexusMods.EventSourcing.Storage.Tests.csproj b/tests/NexusMods.MneumonicDB.Storage.Tests/NexusMods.MneumonicDB.Storage.Tests.csproj similarity index 91% rename from tests/NexusMods.EventSourcing.Storage.Tests/NexusMods.EventSourcing.Storage.Tests.csproj rename to tests/NexusMods.MneumonicDB.Storage.Tests/NexusMods.MneumonicDB.Storage.Tests.csproj index 4117c75e..4d0c61ee 100644 --- a/tests/NexusMods.EventSourcing.Storage.Tests/NexusMods.EventSourcing.Storage.Tests.csproj +++ b/tests/NexusMods.MneumonicDB.Storage.Tests/NexusMods.MneumonicDB.Storage.Tests.csproj @@ -3,7 +3,7 @@ true - NexusMods.EventSourcing.Storage.Tests + NexusMods.MneumonicDB.Storage.Tests @@ -58,8 +58,8 @@ - - + + diff --git a/tests/NexusMods.EventSourcing.Storage.Tests/Startup.cs b/tests/NexusMods.MneumonicDB.Storage.Tests/Startup.cs similarity index 62% rename from tests/NexusMods.EventSourcing.Storage.Tests/Startup.cs rename to tests/NexusMods.MneumonicDB.Storage.Tests/Startup.cs index 12b282d9..42a9b239 100644 --- a/tests/NexusMods.EventSourcing.Storage.Tests/Startup.cs +++ b/tests/NexusMods.MneumonicDB.Storage.Tests/Startup.cs @@ -1,19 +1,19 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -using NexusMods.EventSourcing.Abstractions; -using NexusMods.EventSourcing.Storage.RocksDbBackend; -using NexusMods.EventSourcing.TestModel.ComplexModel.Attributes; -using NexusMods.EventSourcing.TestModel.ValueSerializers; +using NexusMods.MneumonicDB.Abstractions; +using NexusMods.MneumonicDB.Storage.RocksDbBackend; +using NexusMods.MneumonicDB.TestModel.ComplexModel.Attributes; +using NexusMods.MneumonicDB.TestModel.ValueSerializers; using Xunit.DependencyInjection.Logging; -using FileAttributes = NexusMods.EventSourcing.TestModel.ComplexModel.Attributes.FileAttributes; +using FileAttributes = NexusMods.MneumonicDB.TestModel.ComplexModel.Attributes.FileAttributes; -namespace NexusMods.EventSourcing.Storage.Tests; +namespace NexusMods.MneumonicDB.Storage.Tests; public class Startup { public void ConfigureServices(IServiceCollection services) { - services.AddEventSourcingStorage() + services.AddMneumonicDBStorage() .AddSingleton() .AddLogging(builder => builder.AddXunitOutput().SetMinimumLevel(LogLevel.Debug)) .AddValueSerializer() diff --git a/tests/NexusMods.EventSourcing.Storage.Tests/TestAttributes.cs b/tests/NexusMods.MneumonicDB.Storage.Tests/TestAttributes.cs similarity index 81% rename from tests/NexusMods.EventSourcing.Storage.Tests/TestAttributes.cs rename to tests/NexusMods.MneumonicDB.Storage.Tests/TestAttributes.cs index 8ce5bca4..756103f5 100644 --- a/tests/NexusMods.EventSourcing.Storage.Tests/TestAttributes.cs +++ b/tests/NexusMods.MneumonicDB.Storage.Tests/TestAttributes.cs @@ -1,6 +1,6 @@ -using NexusMods.EventSourcing.Abstractions; +using NexusMods.MneumonicDB.Abstractions; -namespace NexusMods.EventSourcing.Storage.Tests; +namespace NexusMods.MneumonicDB.Storage.Tests; public class TestAttributes { diff --git a/tests/NexusMods.MneumonicDB.Storage.Tests/TestHelpers.cs b/tests/NexusMods.MneumonicDB.Storage.Tests/TestHelpers.cs new file mode 100644 index 00000000..39c78e4c --- /dev/null +++ b/tests/NexusMods.MneumonicDB.Storage.Tests/TestHelpers.cs @@ -0,0 +1,3 @@ +namespace NexusMods.MneumonicDB.Storage.Tests; + +public class TestHelpers { } diff --git a/tests/NexusMods.MneumonicDB.TestModel/ComplexModel/Attributes/ArchiveFileAttributes.cs b/tests/NexusMods.MneumonicDB.TestModel/ComplexModel/Attributes/ArchiveFileAttributes.cs new file mode 100644 index 00000000..8058245b --- /dev/null +++ b/tests/NexusMods.MneumonicDB.TestModel/ComplexModel/Attributes/ArchiveFileAttributes.cs @@ -0,0 +1,21 @@ +using NexusMods.MneumonicDB.Abstractions; +using NexusMods.Paths; + +namespace NexusMods.MneumonicDB.TestModel.ComplexModel.Attributes; + +/// +/// This class intentionally overlaps with the FileAttributes class in the tests, this is to test the attribute collection +/// is able to handle multiple attributes with the same short name (but unique full name). +/// +public class ArchiveFileAttributes +{ + /// + /// The path of the file in the archive + /// + public class Path() : ScalarAttribute(isIndexed: true); + + /// + /// The hashcode of the file + /// + public class Hash() : ScalarAttribute(isIndexed: true); +} diff --git a/tests/NexusMods.EventSourcing.TestModel/ComplexModel/Attributes/FileAttributes.cs b/tests/NexusMods.MneumonicDB.TestModel/ComplexModel/Attributes/FileAttributes.cs similarity index 84% rename from tests/NexusMods.EventSourcing.TestModel/ComplexModel/Attributes/FileAttributes.cs rename to tests/NexusMods.MneumonicDB.TestModel/ComplexModel/Attributes/FileAttributes.cs index edaadd72..712ca719 100644 --- a/tests/NexusMods.EventSourcing.TestModel/ComplexModel/Attributes/FileAttributes.cs +++ b/tests/NexusMods.MneumonicDB.TestModel/ComplexModel/Attributes/FileAttributes.cs @@ -1,7 +1,7 @@ -using NexusMods.EventSourcing.Abstractions; +using NexusMods.MneumonicDB.Abstractions; using NexusMods.Paths; -namespace NexusMods.EventSourcing.TestModel.ComplexModel.Attributes; +namespace NexusMods.MneumonicDB.TestModel.ComplexModel.Attributes; public class FileAttributes { diff --git a/tests/NexusMods.EventSourcing.TestModel/ComplexModel/Attributes/LoadoutAttributes.cs b/tests/NexusMods.MneumonicDB.TestModel/ComplexModel/Attributes/LoadoutAttributes.cs similarity index 74% rename from tests/NexusMods.EventSourcing.TestModel/ComplexModel/Attributes/LoadoutAttributes.cs rename to tests/NexusMods.MneumonicDB.TestModel/ComplexModel/Attributes/LoadoutAttributes.cs index ac7126c0..969b0606 100644 --- a/tests/NexusMods.EventSourcing.TestModel/ComplexModel/Attributes/LoadoutAttributes.cs +++ b/tests/NexusMods.MneumonicDB.TestModel/ComplexModel/Attributes/LoadoutAttributes.cs @@ -1,6 +1,6 @@ -using NexusMods.EventSourcing.Abstractions; +using NexusMods.MneumonicDB.Abstractions; -namespace NexusMods.EventSourcing.TestModel.ComplexModel.Attributes; +namespace NexusMods.MneumonicDB.TestModel.ComplexModel.Attributes; public class LoadoutAttributes { diff --git a/tests/NexusMods.EventSourcing.TestModel/ComplexModel/Attributes/ModAttributes.cs b/tests/NexusMods.MneumonicDB.TestModel/ComplexModel/Attributes/ModAttributes.cs similarity index 79% rename from tests/NexusMods.EventSourcing.TestModel/ComplexModel/Attributes/ModAttributes.cs rename to tests/NexusMods.MneumonicDB.TestModel/ComplexModel/Attributes/ModAttributes.cs index 83f6061a..b1337602 100644 --- a/tests/NexusMods.EventSourcing.TestModel/ComplexModel/Attributes/ModAttributes.cs +++ b/tests/NexusMods.MneumonicDB.TestModel/ComplexModel/Attributes/ModAttributes.cs @@ -1,6 +1,6 @@ -using NexusMods.EventSourcing.Abstractions; +using NexusMods.MneumonicDB.Abstractions; -namespace NexusMods.EventSourcing.TestModel.ComplexModel.Attributes; +namespace NexusMods.MneumonicDB.TestModel.ComplexModel.Attributes; public class ModAttributes { diff --git a/tests/NexusMods.MneumonicDB.TestModel/ComplexModel/ReadModels/ArchiveFile.cs b/tests/NexusMods.MneumonicDB.TestModel/ComplexModel/ReadModels/ArchiveFile.cs new file mode 100644 index 00000000..521912f5 --- /dev/null +++ b/tests/NexusMods.MneumonicDB.TestModel/ComplexModel/ReadModels/ArchiveFile.cs @@ -0,0 +1,27 @@ +using NexusMods.MneumonicDB.Abstractions; +using NexusMods.MneumonicDB.Abstractions.Models; +using NexusMods.MneumonicDB.TestModel.ComplexModel.Attributes; +using NexusMods.Hashing.xxHash64; +using NexusMods.Paths; +using FileAttributes = NexusMods.MneumonicDB.TestModel.ComplexModel.Attributes.FileAttributes; + +namespace NexusMods.MneumonicDB.TestModel.ComplexModel.ReadModels; + +/// +/// Read model the demonstrates the use of multiple attributes with the same short name (but unique full name). +/// Also demonstrates the use of a read model containing attributes from different attribute classes. +/// +public class ArchiveFile(ITransaction? tx) : AReadModel(tx) +{ + [From] + public required RelativePath Path { get; set; } + + [From] + public required Size Size { get; set; } + + [From] + public required RelativePath ArchivePath { get; set; } + + [From] + public required Hash Hash { get; set; } +} diff --git a/tests/NexusMods.MneumonicDB.TestModel/ComplexModel/ReadModels/File.cs b/tests/NexusMods.MneumonicDB.TestModel/ComplexModel/ReadModels/File.cs new file mode 100644 index 00000000..2e99a49b --- /dev/null +++ b/tests/NexusMods.MneumonicDB.TestModel/ComplexModel/ReadModels/File.cs @@ -0,0 +1,33 @@ +using NexusMods.MneumonicDB.Abstractions; +using NexusMods.MneumonicDB.Abstractions.Models; +using NexusMods.Hashing.xxHash64; +using NexusMods.Paths; +using FileAttributes = NexusMods.MneumonicDB.TestModel.ComplexModel.Attributes.FileAttributes; + +namespace NexusMods.MneumonicDB.TestModel.ComplexModel.ReadModels; + +public class File(ITransaction? tx) : AReadModel(tx) +{ + [From] + public required RelativePath Path { get; set; } + + [From] + public required Size Size { get; set; } + + [From] + public required Hash Hash { get; set; } + + [From] + public required EntityId ModId { get; init; } + + public static File Create(ITransaction tx, string s, Mod mod, Size fromLong, Hash hash) + { + return new File(tx) + { + Path = s, + Size = fromLong, + Hash = hash, + ModId = mod.Id + }; + } +} diff --git a/tests/NexusMods.EventSourcing.TestModel/ComplexModel/ReadModels/Loadout.cs b/tests/NexusMods.MneumonicDB.TestModel/ComplexModel/ReadModels/Loadout.cs similarity index 73% rename from tests/NexusMods.EventSourcing.TestModel/ComplexModel/ReadModels/Loadout.cs rename to tests/NexusMods.MneumonicDB.TestModel/ComplexModel/ReadModels/Loadout.cs index 111bfa9d..040d1f6f 100644 --- a/tests/NexusMods.EventSourcing.TestModel/ComplexModel/ReadModels/Loadout.cs +++ b/tests/NexusMods.MneumonicDB.TestModel/ComplexModel/ReadModels/Loadout.cs @@ -1,8 +1,8 @@ -using NexusMods.EventSourcing.Abstractions; -using NexusMods.EventSourcing.Abstractions.Models; -using NexusMods.EventSourcing.TestModel.ComplexModel.Attributes; +using NexusMods.MneumonicDB.Abstractions; +using NexusMods.MneumonicDB.Abstractions.Models; +using NexusMods.MneumonicDB.TestModel.ComplexModel.Attributes; -namespace NexusMods.EventSourcing.TestModel.ComplexModel.ReadModels; +namespace NexusMods.MneumonicDB.TestModel.ComplexModel.ReadModels; public class Loadout(ITransaction? tx) : AReadModel(tx) { diff --git a/tests/NexusMods.EventSourcing.TestModel/ComplexModel/ReadModels/Mod.cs b/tests/NexusMods.MneumonicDB.TestModel/ComplexModel/ReadModels/Mod.cs similarity index 57% rename from tests/NexusMods.EventSourcing.TestModel/ComplexModel/ReadModels/Mod.cs rename to tests/NexusMods.MneumonicDB.TestModel/ComplexModel/ReadModels/Mod.cs index 336eda91..fdca168c 100644 --- a/tests/NexusMods.EventSourcing.TestModel/ComplexModel/ReadModels/Mod.cs +++ b/tests/NexusMods.MneumonicDB.TestModel/ComplexModel/ReadModels/Mod.cs @@ -1,9 +1,10 @@ -using NexusMods.EventSourcing.Abstractions; -using NexusMods.EventSourcing.Abstractions.Models; -using NexusMods.EventSourcing.TestModel.ComplexModel.Attributes; -using FileAttributes = NexusMods.EventSourcing.TestModel.ComplexModel.Attributes.FileAttributes; +using System.Text.Json.Serialization; +using NexusMods.MneumonicDB.Abstractions; +using NexusMods.MneumonicDB.Abstractions.Models; +using NexusMods.MneumonicDB.TestModel.ComplexModel.Attributes; +using FileAttributes = NexusMods.MneumonicDB.TestModel.ComplexModel.Attributes.FileAttributes; -namespace NexusMods.EventSourcing.TestModel.ComplexModel.ReadModels; +namespace NexusMods.MneumonicDB.TestModel.ComplexModel.ReadModels; public class Mod(ITransaction? tx) : AReadModel(tx) { @@ -16,6 +17,16 @@ public class Mod(ITransaction? tx) : AReadModel(tx) public IEnumerable Files => GetReverse(); + + #region References + + public Loadout Loadout => Get(LoadoutId); + + public IEnumerable Mods => GetReverse(); + + + #endregion + /// /// Creates a new mod with the given name, source and loadout /// diff --git a/tests/NexusMods.EventSourcing.TestModel/Helpers/ExtensionMethods.cs b/tests/NexusMods.MneumonicDB.TestModel/Helpers/ExtensionMethods.cs similarity index 93% rename from tests/NexusMods.EventSourcing.TestModel/Helpers/ExtensionMethods.cs rename to tests/NexusMods.MneumonicDB.TestModel/Helpers/ExtensionMethods.cs index e03ac815..98189527 100644 --- a/tests/NexusMods.EventSourcing.TestModel/Helpers/ExtensionMethods.cs +++ b/tests/NexusMods.MneumonicDB.TestModel/Helpers/ExtensionMethods.cs @@ -1,8 +1,8 @@ using System.Text; -using NexusMods.EventSourcing.Abstractions; -using NexusMods.EventSourcing.Abstractions.Internals; +using NexusMods.MneumonicDB.Abstractions; +using NexusMods.MneumonicDB.Abstractions.Internals; -namespace NexusMods.EventSourcing.TestModel.Helpers; +namespace NexusMods.MneumonicDB.TestModel.Helpers; public static class ExtensionMethods { diff --git a/tests/NexusMods.EventSourcing.TestModel/Helpers/ObjectTuple.cs b/tests/NexusMods.MneumonicDB.TestModel/Helpers/ObjectTuple.cs similarity index 93% rename from tests/NexusMods.EventSourcing.TestModel/Helpers/ObjectTuple.cs rename to tests/NexusMods.MneumonicDB.TestModel/Helpers/ObjectTuple.cs index 4a8eb201..e1ac15bb 100644 --- a/tests/NexusMods.EventSourcing.TestModel/Helpers/ObjectTuple.cs +++ b/tests/NexusMods.MneumonicDB.TestModel/Helpers/ObjectTuple.cs @@ -1,7 +1,7 @@ using Argon; -using NexusMods.EventSourcing.Abstractions; +using NexusMods.MneumonicDB.Abstractions; -namespace NexusMods.EventSourcing.TestModel.Helpers; +namespace NexusMods.MneumonicDB.TestModel.Helpers; public class ObjectTuple { diff --git a/tests/NexusMods.EventSourcing.TestModel/NexusMods.EventSourcing.TestModel.csproj b/tests/NexusMods.MneumonicDB.TestModel/NexusMods.MneumonicDB.TestModel.csproj similarity index 94% rename from tests/NexusMods.EventSourcing.TestModel/NexusMods.EventSourcing.TestModel.csproj rename to tests/NexusMods.MneumonicDB.TestModel/NexusMods.MneumonicDB.TestModel.csproj index 17278762..e9888d3b 100644 --- a/tests/NexusMods.EventSourcing.TestModel/NexusMods.EventSourcing.TestModel.csproj +++ b/tests/NexusMods.MneumonicDB.TestModel/NexusMods.MneumonicDB.TestModel.csproj @@ -7,7 +7,7 @@ - + diff --git a/tests/NexusMods.MneumonicDB.TestModel/Services.cs b/tests/NexusMods.MneumonicDB.TestModel/Services.cs new file mode 100644 index 00000000..4de57446 --- /dev/null +++ b/tests/NexusMods.MneumonicDB.TestModel/Services.cs @@ -0,0 +1,25 @@ +using Microsoft.Extensions.DependencyInjection; +using NexusMods.MneumonicDB.Abstractions; +using NexusMods.MneumonicDB.TestModel.ComplexModel.Attributes; +using NexusMods.MneumonicDB.TestModel.ValueSerializers; +using FileAttributes = NexusMods.MneumonicDB.TestModel.ComplexModel.Attributes.FileAttributes; + +namespace NexusMods.MneumonicDB.TestModel; + +public static class Services +{ + public static IServiceCollection AddTestModel(this IServiceCollection services) + { + services.AddAttributeCollection() + .AddAttributeCollection() + .AddAttributeCollection() + .AddAttributeCollection(); + + services.AddValueSerializer() + .AddValueSerializer() + .AddValueSerializer() + .AddValueSerializer(); + + return services; + } +} diff --git a/tests/NexusMods.EventSourcing.TestModel/ValueSerializers/HashSerializer.cs b/tests/NexusMods.MneumonicDB.TestModel/ValueSerializers/HashSerializer.cs similarity index 90% rename from tests/NexusMods.EventSourcing.TestModel/ValueSerializers/HashSerializer.cs rename to tests/NexusMods.MneumonicDB.TestModel/ValueSerializers/HashSerializer.cs index bde71c2b..ddb4cf9f 100644 --- a/tests/NexusMods.EventSourcing.TestModel/ValueSerializers/HashSerializer.cs +++ b/tests/NexusMods.MneumonicDB.TestModel/ValueSerializers/HashSerializer.cs @@ -1,11 +1,11 @@ using System.Buffers; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -using NexusMods.EventSourcing.Abstractions; +using NexusMods.MneumonicDB.Abstractions; using NexusMods.Hashing.xxHash64; using NexusMods.Paths; -namespace NexusMods.EventSourcing.TestModel.ValueSerializers; +namespace NexusMods.MneumonicDB.TestModel.ValueSerializers; public class HashSerializer : IValueSerializer { diff --git a/tests/NexusMods.EventSourcing.TestModel/ValueSerializers/RelativePathSerializer.cs b/tests/NexusMods.MneumonicDB.TestModel/ValueSerializers/RelativePathSerializer.cs similarity index 91% rename from tests/NexusMods.EventSourcing.TestModel/ValueSerializers/RelativePathSerializer.cs rename to tests/NexusMods.MneumonicDB.TestModel/ValueSerializers/RelativePathSerializer.cs index 40fd5eb0..7ae57568 100644 --- a/tests/NexusMods.EventSourcing.TestModel/ValueSerializers/RelativePathSerializer.cs +++ b/tests/NexusMods.MneumonicDB.TestModel/ValueSerializers/RelativePathSerializer.cs @@ -1,9 +1,9 @@ using System.Buffers; using System.Text; -using NexusMods.EventSourcing.Abstractions; +using NexusMods.MneumonicDB.Abstractions; using NexusMods.Paths; -namespace NexusMods.EventSourcing.TestModel.ValueSerializers; +namespace NexusMods.MneumonicDB.TestModel.ValueSerializers; public class RelativePathSerializer : IValueSerializer { diff --git a/tests/NexusMods.EventSourcing.TestModel/ValueSerializers/SizeSerializer.cs b/tests/NexusMods.MneumonicDB.TestModel/ValueSerializers/SizeSerializer.cs similarity index 90% rename from tests/NexusMods.EventSourcing.TestModel/ValueSerializers/SizeSerializer.cs rename to tests/NexusMods.MneumonicDB.TestModel/ValueSerializers/SizeSerializer.cs index b25aae75..f714cde5 100644 --- a/tests/NexusMods.EventSourcing.TestModel/ValueSerializers/SizeSerializer.cs +++ b/tests/NexusMods.MneumonicDB.TestModel/ValueSerializers/SizeSerializer.cs @@ -1,10 +1,10 @@ using System.Buffers; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -using NexusMods.EventSourcing.Abstractions; +using NexusMods.MneumonicDB.Abstractions; using NexusMods.Paths; -namespace NexusMods.EventSourcing.TestModel.ValueSerializers; +namespace NexusMods.MneumonicDB.TestModel.ValueSerializers; public class SizeSerializer : IValueSerializer { diff --git a/tests/NexusMods.EventSourcing.TestModel/ValueSerializers/UriSerializer.cs b/tests/NexusMods.MneumonicDB.TestModel/ValueSerializers/UriSerializer.cs similarity index 91% rename from tests/NexusMods.EventSourcing.TestModel/ValueSerializers/UriSerializer.cs rename to tests/NexusMods.MneumonicDB.TestModel/ValueSerializers/UriSerializer.cs index d2a10c76..dfcafdc2 100644 --- a/tests/NexusMods.EventSourcing.TestModel/ValueSerializers/UriSerializer.cs +++ b/tests/NexusMods.MneumonicDB.TestModel/ValueSerializers/UriSerializer.cs @@ -1,8 +1,8 @@ using System.Buffers; using System.Text; -using NexusMods.EventSourcing.Abstractions; +using NexusMods.MneumonicDB.Abstractions; -namespace NexusMods.EventSourcing.TestModel.ValueSerializers; +namespace NexusMods.MneumonicDB.TestModel.ValueSerializers; public class UriSerializer : IValueSerializer { diff --git a/tests/NexusMods.MneumonicDB.Tests/AEventSourcingTest.cs b/tests/NexusMods.MneumonicDB.Tests/AEventSourcingTest.cs new file mode 100644 index 00000000..5b59edc7 --- /dev/null +++ b/tests/NexusMods.MneumonicDB.Tests/AEventSourcingTest.cs @@ -0,0 +1,148 @@ +using System.Reflection; +using System.Text.Json; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using NexusMods.MneumonicDB.Abstractions; +using NexusMods.MneumonicDB.Abstractions.Models; +using NexusMods.MneumonicDB.Storage; +using NexusMods.MneumonicDB.Storage.RocksDbBackend; +using NexusMods.MneumonicDB.TestModel.ComplexModel.Attributes; +using NexusMods.MneumonicDB.TestModel.ComplexModel.ReadModels; +using NexusMods.MneumonicDB.TestModel.Helpers; +using NexusMods.Hashing.xxHash64; +using NexusMods.Paths; +using File = NexusMods.MneumonicDB.TestModel.ComplexModel.ReadModels.File; + +namespace NexusMods.MneumonicDB.Tests; + +public class AMneumonicDBTest : IAsyncLifetime +{ + private readonly IAttribute[] _attributes; + private readonly IServiceProvider _provider; + private readonly AttributeRegistry _registry; + private readonly IValueSerializer[] _valueSerializers; + private Backend _backend; + + private DatomStore _store; + protected Connection Connection = null!; + protected ILogger Logger; + + + protected AMneumonicDBTest(IServiceProvider provider) + { + _provider = provider; + _valueSerializers = provider.GetRequiredService>().ToArray(); + _attributes = provider.GetRequiredService>().ToArray(); + + _registry = new AttributeRegistry(_valueSerializers, _attributes); + + Config = new DatomStoreSettings + { + Path = FileSystem.Shared.GetKnownPath(KnownPath.EntryDirectory) + .Combine("tests_MneumonicDB" + Guid.NewGuid()) + }; + _backend = new Backend(_registry); + + _store = new DatomStore(provider.GetRequiredService>(), _registry, Config, _backend); + + Logger = provider.GetRequiredService>(); + } + + protected DatomStoreSettings Config { get; set; } + + protected SettingsTask VerifyModel(TReadModel model) + where TReadModel : IReadModel + { + var datoms = DatomsFor(model).ToTable(_registry); + return Verify(datoms); + } + + protected SettingsTask VerifyModel(IEnumerable model) + { + var datoms = model.SelectMany(DatomsFor) + .ToTable(_registry); + return Verify(datoms); + } + + public async Task InitializeAsync() + { + await _store.Sync(); + + Connection = await Connection.Start(_store, _valueSerializers, _attributes); + } + + protected IReadDatom[] DatomsFor(IReadModel model) + { + var fromAttributes = model.GetType() + .GetProperties() + .SelectMany(p => p.CustomAttributes) + .Select(p => p.AttributeType) + .Where(a => a.IsAssignableTo(typeof(IFromAttribute))) + .Select(f => f.GenericTypeArguments.First()) + .ToArray(); + + var datoms = model.Db.Datoms(model.Id) + .Where(d => fromAttributes.Contains(d.AttributeType)) + .ToArray(); + return datoms; + } + + protected SettingsTask VerifyTable(IEnumerable datoms) + { + return Verify(datoms.ToTable(_registry)); + } + + protected async Task InsertExampleData() + { + var tx = Connection.BeginTransaction(); + var loadout = Loadout.Create(tx, "Test Loadout"); + List mods = new(); + + foreach (var modName in new[] { "Mod1", "Mod2", "Mod3" }) + { + var mod = Mod.Create(tx, modName, new Uri("http://somesite.com/" + modName), loadout); + var idx = 0; + foreach (var file in new[] { "File1", "File2", "File3" }) + { + File.Create(tx, file, mod, Size.From((ulong)idx), Hash.From((ulong)(0xDEADBEEF + idx))); + idx += 1; + } + mods.Add(mod); + } + + var txResult = await tx.Commit(); + + loadout = txResult.Remap(loadout); + + var tx2 = Connection.BeginTransaction(); + foreach (var mod in loadout.Mods) + { + ModAttributes.Name.Add(tx2, mod.Id, mod.Name + " - Updated"); + } + await tx2.Commit(); + + return Connection.Db.Get(loadout.Id); + + + } + + public Task DisposeAsync() + { + _store.Dispose(); + return Task.CompletedTask; + } + + + protected async Task RestartDatomStore() + { + _store.Dispose(); + _backend.Dispose(); + + + _backend = new Backend(_registry); + _store = new DatomStore(_provider.GetRequiredService>(), _registry, Config, _backend); + await _store.Sync(); + + Connection = await Connection.Start(_store, _valueSerializers, _attributes); + } +} diff --git a/tests/NexusMods.EventSourcing.Tests/ComplexModelTests.cs b/tests/NexusMods.MneumonicDB.Tests/ComplexModelTests.cs similarity index 94% rename from tests/NexusMods.EventSourcing.Tests/ComplexModelTests.cs rename to tests/NexusMods.MneumonicDB.Tests/ComplexModelTests.cs index 70de5a8b..216d3ba4 100644 --- a/tests/NexusMods.EventSourcing.Tests/ComplexModelTests.cs +++ b/tests/NexusMods.MneumonicDB.Tests/ComplexModelTests.cs @@ -1,13 +1,13 @@ using System.Diagnostics; using Microsoft.Extensions.Logging; -using NexusMods.EventSourcing.TestModel.ComplexModel.ReadModels; +using NexusMods.MneumonicDB.TestModel.ComplexModel.ReadModels; using NexusMods.Hashing.xxHash64; using NexusMods.Paths; -using File = NexusMods.EventSourcing.TestModel.ComplexModel.ReadModels.File; +using File = NexusMods.MneumonicDB.TestModel.ComplexModel.ReadModels.File; -namespace NexusMods.EventSourcing.Tests; +namespace NexusMods.MneumonicDB.Tests; -public class ComplexModelTests(IServiceProvider provider) : AEventSourcingTest(provider) +public class ComplexModelTests(IServiceProvider provider) : AMneumonicDBTest(provider) { [Theory] [InlineData(1, 1)] diff --git a/tests/NexusMods.MneumonicDB.Tests/DbTests.CanGetCommitUpdates.verified.txt b/tests/NexusMods.MneumonicDB.Tests/DbTests.CanGetCommitUpdates.verified.txt new file mode 100644 index 00000000..d249c241 --- /dev/null +++ b/tests/NexusMods.MneumonicDB.Tests/DbTests.CanGetCommitUpdates.verified.txt @@ -0,0 +1 @@ ++ | 0200000000000001 | (0005) Hash | 0x00000000DEADBEEF | 0100000000000004 diff --git a/tests/NexusMods.MneumonicDB.Tests/DbTests.CanGetCommitUpdates_update_datom_0.verified.txt b/tests/NexusMods.MneumonicDB.Tests/DbTests.CanGetCommitUpdates_update_datom_0.verified.txt new file mode 100644 index 00000000..d249c241 --- /dev/null +++ b/tests/NexusMods.MneumonicDB.Tests/DbTests.CanGetCommitUpdates_update_datom_0.verified.txt @@ -0,0 +1 @@ ++ | 0200000000000001 | (0005) Hash | 0x00000000DEADBEEF | 0100000000000004 diff --git a/tests/NexusMods.MneumonicDB.Tests/DbTests.CanGetCommitUpdates_update_datom_1.verified.txt b/tests/NexusMods.MneumonicDB.Tests/DbTests.CanGetCommitUpdates_update_datom_1.verified.txt new file mode 100644 index 00000000..deccac17 --- /dev/null +++ b/tests/NexusMods.MneumonicDB.Tests/DbTests.CanGetCommitUpdates_update_datom_1.verified.txt @@ -0,0 +1 @@ ++ | 0200000000000001 | (0005) Hash | 0x00000000DEADBEF0 | 0100000000000005 diff --git a/tests/NexusMods.MneumonicDB.Tests/DbTests.CanGetCommitUpdates_update_datom_2.verified.txt b/tests/NexusMods.MneumonicDB.Tests/DbTests.CanGetCommitUpdates_update_datom_2.verified.txt new file mode 100644 index 00000000..b17304f6 --- /dev/null +++ b/tests/NexusMods.MneumonicDB.Tests/DbTests.CanGetCommitUpdates_update_datom_2.verified.txt @@ -0,0 +1 @@ ++ | 0200000000000001 | (0005) Hash | 0x00000000DEADBEF1 | 0100000000000006 diff --git a/tests/NexusMods.MneumonicDB.Tests/DbTests.CanGetCommitUpdates_update_datom_3.verified.txt b/tests/NexusMods.MneumonicDB.Tests/DbTests.CanGetCommitUpdates_update_datom_3.verified.txt new file mode 100644 index 00000000..7355bb9b --- /dev/null +++ b/tests/NexusMods.MneumonicDB.Tests/DbTests.CanGetCommitUpdates_update_datom_3.verified.txt @@ -0,0 +1 @@ ++ | 0200000000000001 | (0005) Hash | 0x00000000DEADBEF2 | 0100000000000007 diff --git a/tests/NexusMods.MneumonicDB.Tests/DbTests.CanGetDatomIterator_AEVTCurrent_False.verified.txt b/tests/NexusMods.MneumonicDB.Tests/DbTests.CanGetDatomIterator_AEVTCurrent_False.verified.txt new file mode 100644 index 00000000..a5edc462 --- /dev/null +++ b/tests/NexusMods.MneumonicDB.Tests/DbTests.CanGetDatomIterator_AEVTCurrent_False.verified.txt @@ -0,0 +1,73 @@ ++ | 0000000000000001 | (0001) UniqueId | NexusMods.MneumonicDB.DatomStore/UniqueId | 0100000000000001 ++ | 0000000000000002 | (0001) UniqueId | NexusMods.MneumonicDB....tore/ValueSerializerId | 0100000000000001 ++ | 0000000000000003 | (0001) UniqueId | NexusMods.MneumonicDB....es.FileAttributes/Path | 0100000000000002 ++ | 0000000000000004 | (0001) UniqueId | NexusMods.MneumonicDB....es.FileAttributes/Size | 0100000000000002 ++ | 0000000000000005 | (0001) UniqueId | NexusMods.MneumonicDB....es.FileAttributes/Hash | 0100000000000002 ++ | 0000000000000006 | (0001) UniqueId | NexusMods.MneumonicDB....s.FileAttributes/ModId | 0100000000000002 ++ | 0000000000000007 | (0001) UniqueId | NexusMods.MneumonicDB....iveFileAttributes/Path | 0100000000000002 ++ | 0000000000000008 | (0001) UniqueId | NexusMods.MneumonicDB....iveFileAttributes/Hash | 0100000000000002 ++ | 0000000000000009 | (0001) UniqueId | NexusMods.MneumonicDB....LoadoutAttributes/Name | 0100000000000002 ++ | 000000000000000A | (0001) UniqueId | NexusMods.MneumonicDB....utAttributes/UpdatedAt | 0100000000000002 ++ | 000000000000000B | (0001) UniqueId | NexusMods.MneumonicDB....tes.ModAttributes/Name | 0100000000000002 ++ | 000000000000000C | (0001) UniqueId | NexusMods.MneumonicDB....s.ModAttributes/Source | 0100000000000002 ++ | 000000000000000D | (0001) UniqueId | NexusMods.MneumonicDB....odAttributes/LoadoutId | 0100000000000002 ++ | 0000000000000001 | (0002) ValueSerializerId | NexusMods.MneumonicDB....izers/SymbolSerializer | 0100000000000001 ++ | 0000000000000002 | (0002) ValueSerializerId | NexusMods.MneumonicDB....izers/SymbolSerializer | 0100000000000001 ++ | 0000000000000003 | (0002) ValueSerializerId | NexusMods.MneumonicDB....RelativePathSerializer | 0100000000000002 ++ | 0000000000000004 | (0002) ValueSerializerId | NexusMods.MneumonicDB....alizers/SizeSerializer | 0100000000000002 ++ | 0000000000000005 | (0002) ValueSerializerId | NexusMods.MneumonicDB....alizers/HashSerializer | 0100000000000002 ++ | 0000000000000006 | (0002) ValueSerializerId | NexusMods.MneumonicDB....ers/EntityIdSerializer | 0100000000000002 ++ | 0000000000000007 | (0002) ValueSerializerId | NexusMods.MneumonicDB....RelativePathSerializer | 0100000000000002 ++ | 0000000000000008 | (0002) ValueSerializerId | NexusMods.MneumonicDB....alizers/HashSerializer | 0100000000000002 ++ | 0000000000000009 | (0002) ValueSerializerId | NexusMods.MneumonicDB....izers/StringSerializer | 0100000000000002 ++ | 000000000000000A | (0002) ValueSerializerId | NexusMods.MneumonicDB....alizers/TxIdSerializer | 0100000000000002 ++ | 000000000000000B | (0002) ValueSerializerId | NexusMods.MneumonicDB....izers/StringSerializer | 0100000000000002 ++ | 000000000000000C | (0002) ValueSerializerId | NexusMods.MneumonicDB....ializers/UriSerializer | 0100000000000002 ++ | 000000000000000D | (0002) ValueSerializerId | NexusMods.MneumonicDB....ers/EntityIdSerializer | 0100000000000002 ++ | 0200000000000003 | (0003) Path | File1 | 0100000000000003 ++ | 0200000000000004 | (0003) Path | File2 | 0100000000000003 ++ | 0200000000000005 | (0003) Path | File3 | 0100000000000003 ++ | 0200000000000007 | (0003) Path | File1 | 0100000000000003 ++ | 0200000000000008 | (0003) Path | File2 | 0100000000000003 ++ | 0200000000000009 | (0003) Path | File3 | 0100000000000003 ++ | 020000000000000B | (0003) Path | File1 | 0100000000000003 ++ | 020000000000000C | (0003) Path | File2 | 0100000000000003 ++ | 020000000000000D | (0003) Path | File3 | 0100000000000003 ++ | 0200000000000003 | (0004) Size | 0 B | 0100000000000003 ++ | 0200000000000004 | (0004) Size | 1 B | 0100000000000003 ++ | 0200000000000005 | (0004) Size | 2 B | 0100000000000003 ++ | 0200000000000007 | (0004) Size | 0 B | 0100000000000003 ++ | 0200000000000008 | (0004) Size | 1 B | 0100000000000003 ++ | 0200000000000009 | (0004) Size | 2 B | 0100000000000003 ++ | 020000000000000B | (0004) Size | 0 B | 0100000000000003 ++ | 020000000000000C | (0004) Size | 1 B | 0100000000000003 ++ | 020000000000000D | (0004) Size | 2 B | 0100000000000003 ++ | 0200000000000003 | (0005) Hash | 0x00000000DEADBEEF | 0100000000000003 ++ | 0200000000000004 | (0005) Hash | 0x00000000DEADBEF0 | 0100000000000003 ++ | 0200000000000005 | (0005) Hash | 0x00000000DEADBEF1 | 0100000000000003 ++ | 0200000000000007 | (0005) Hash | 0x00000000DEADBEEF | 0100000000000003 ++ | 0200000000000008 | (0005) Hash | 0x00000000DEADBEF0 | 0100000000000003 ++ | 0200000000000009 | (0005) Hash | 0x00000000DEADBEF1 | 0100000000000003 ++ | 020000000000000B | (0005) Hash | 0x00000000DEADBEEF | 0100000000000003 ++ | 020000000000000C | (0005) Hash | 0x00000000DEADBEF0 | 0100000000000003 ++ | 020000000000000D | (0005) Hash | 0x00000000DEADBEF1 | 0100000000000003 ++ | 0200000000000003 | (0006) ModId | 0200000000000002 | 0100000000000003 ++ | 0200000000000004 | (0006) ModId | 0200000000000002 | 0100000000000003 ++ | 0200000000000005 | (0006) ModId | 0200000000000002 | 0100000000000003 ++ | 0200000000000007 | (0006) ModId | 0200000000000006 | 0100000000000003 ++ | 0200000000000008 | (0006) ModId | 0200000000000006 | 0100000000000003 ++ | 0200000000000009 | (0006) ModId | 0200000000000006 | 0100000000000003 ++ | 020000000000000B | (0006) ModId | 020000000000000A | 0100000000000003 ++ | 020000000000000C | (0006) ModId | 020000000000000A | 0100000000000003 ++ | 020000000000000D | (0006) ModId | 020000000000000A | 0100000000000003 ++ | 0200000000000001 | (0009) Name | Test Loadout | 0100000000000003 ++ | 0200000000000001 | (000A) UpdatedAt | 216172782113783808 | 0100000000000003 ++ | 0200000000000002 | (000B) Name | Mod1 - Updated | 0100000000000004 ++ | 0200000000000006 | (000B) Name | Mod2 - Updated | 0100000000000004 ++ | 020000000000000A | (000B) Name | Mod3 - Updated | 0100000000000004 ++ | 0200000000000002 | (000C) Source | http://somesite.com/Mod1 | 0100000000000003 ++ | 0200000000000006 | (000C) Source | http://somesite.com/Mod2 | 0100000000000003 ++ | 020000000000000A | (000C) Source | http://somesite.com/Mod3 | 0100000000000003 ++ | 0200000000000002 | (000D) LoadoutId | 0200000000000001 | 0100000000000003 ++ | 0200000000000006 | (000D) LoadoutId | 0200000000000001 | 0100000000000003 ++ | 020000000000000A | (000D) LoadoutId | 0200000000000001 | 0100000000000003 diff --git a/tests/NexusMods.MneumonicDB.Tests/DbTests.CanGetDatomIterator_AEVTCurrent_True.verified.txt b/tests/NexusMods.MneumonicDB.Tests/DbTests.CanGetDatomIterator_AEVTCurrent_True.verified.txt new file mode 100644 index 00000000..f7421561 --- /dev/null +++ b/tests/NexusMods.MneumonicDB.Tests/DbTests.CanGetDatomIterator_AEVTCurrent_True.verified.txt @@ -0,0 +1,73 @@ ++ | 020000000000000A | (000D) LoadoutId | 0200000000000001 | 0100000000000003 ++ | 0200000000000006 | (000D) LoadoutId | 0200000000000001 | 0100000000000003 ++ | 0200000000000002 | (000D) LoadoutId | 0200000000000001 | 0100000000000003 ++ | 020000000000000A | (000C) Source | http://somesite.com/Mod3 | 0100000000000003 ++ | 0200000000000006 | (000C) Source | http://somesite.com/Mod2 | 0100000000000003 ++ | 0200000000000002 | (000C) Source | http://somesite.com/Mod1 | 0100000000000003 ++ | 020000000000000A | (000B) Name | Mod3 - Updated | 0100000000000004 ++ | 0200000000000006 | (000B) Name | Mod2 - Updated | 0100000000000004 ++ | 0200000000000002 | (000B) Name | Mod1 - Updated | 0100000000000004 ++ | 0200000000000001 | (000A) UpdatedAt | 216172782113783808 | 0100000000000003 ++ | 0200000000000001 | (0009) Name | Test Loadout | 0100000000000003 ++ | 020000000000000D | (0006) ModId | 020000000000000A | 0100000000000003 ++ | 020000000000000C | (0006) ModId | 020000000000000A | 0100000000000003 ++ | 020000000000000B | (0006) ModId | 020000000000000A | 0100000000000003 ++ | 0200000000000009 | (0006) ModId | 0200000000000006 | 0100000000000003 ++ | 0200000000000008 | (0006) ModId | 0200000000000006 | 0100000000000003 ++ | 0200000000000007 | (0006) ModId | 0200000000000006 | 0100000000000003 ++ | 0200000000000005 | (0006) ModId | 0200000000000002 | 0100000000000003 ++ | 0200000000000004 | (0006) ModId | 0200000000000002 | 0100000000000003 ++ | 0200000000000003 | (0006) ModId | 0200000000000002 | 0100000000000003 ++ | 020000000000000D | (0005) Hash | 0x00000000DEADBEF1 | 0100000000000003 ++ | 020000000000000C | (0005) Hash | 0x00000000DEADBEF0 | 0100000000000003 ++ | 020000000000000B | (0005) Hash | 0x00000000DEADBEEF | 0100000000000003 ++ | 0200000000000009 | (0005) Hash | 0x00000000DEADBEF1 | 0100000000000003 ++ | 0200000000000008 | (0005) Hash | 0x00000000DEADBEF0 | 0100000000000003 ++ | 0200000000000007 | (0005) Hash | 0x00000000DEADBEEF | 0100000000000003 ++ | 0200000000000005 | (0005) Hash | 0x00000000DEADBEF1 | 0100000000000003 ++ | 0200000000000004 | (0005) Hash | 0x00000000DEADBEF0 | 0100000000000003 ++ | 0200000000000003 | (0005) Hash | 0x00000000DEADBEEF | 0100000000000003 ++ | 020000000000000D | (0004) Size | 2 B | 0100000000000003 ++ | 020000000000000C | (0004) Size | 1 B | 0100000000000003 ++ | 020000000000000B | (0004) Size | 0 B | 0100000000000003 ++ | 0200000000000009 | (0004) Size | 2 B | 0100000000000003 ++ | 0200000000000008 | (0004) Size | 1 B | 0100000000000003 ++ | 0200000000000007 | (0004) Size | 0 B | 0100000000000003 ++ | 0200000000000005 | (0004) Size | 2 B | 0100000000000003 ++ | 0200000000000004 | (0004) Size | 1 B | 0100000000000003 ++ | 0200000000000003 | (0004) Size | 0 B | 0100000000000003 ++ | 020000000000000D | (0003) Path | File3 | 0100000000000003 ++ | 020000000000000C | (0003) Path | File2 | 0100000000000003 ++ | 020000000000000B | (0003) Path | File1 | 0100000000000003 ++ | 0200000000000009 | (0003) Path | File3 | 0100000000000003 ++ | 0200000000000008 | (0003) Path | File2 | 0100000000000003 ++ | 0200000000000007 | (0003) Path | File1 | 0100000000000003 ++ | 0200000000000005 | (0003) Path | File3 | 0100000000000003 ++ | 0200000000000004 | (0003) Path | File2 | 0100000000000003 ++ | 0200000000000003 | (0003) Path | File1 | 0100000000000003 ++ | 000000000000000D | (0002) ValueSerializerId | NexusMods.MneumonicDB....ers/EntityIdSerializer | 0100000000000002 ++ | 000000000000000C | (0002) ValueSerializerId | NexusMods.MneumonicDB....ializers/UriSerializer | 0100000000000002 ++ | 000000000000000B | (0002) ValueSerializerId | NexusMods.MneumonicDB....izers/StringSerializer | 0100000000000002 ++ | 000000000000000A | (0002) ValueSerializerId | NexusMods.MneumonicDB....alizers/TxIdSerializer | 0100000000000002 ++ | 0000000000000009 | (0002) ValueSerializerId | NexusMods.MneumonicDB....izers/StringSerializer | 0100000000000002 ++ | 0000000000000008 | (0002) ValueSerializerId | NexusMods.MneumonicDB....alizers/HashSerializer | 0100000000000002 ++ | 0000000000000007 | (0002) ValueSerializerId | NexusMods.MneumonicDB....RelativePathSerializer | 0100000000000002 ++ | 0000000000000006 | (0002) ValueSerializerId | NexusMods.MneumonicDB....ers/EntityIdSerializer | 0100000000000002 ++ | 0000000000000005 | (0002) ValueSerializerId | NexusMods.MneumonicDB....alizers/HashSerializer | 0100000000000002 ++ | 0000000000000004 | (0002) ValueSerializerId | NexusMods.MneumonicDB....alizers/SizeSerializer | 0100000000000002 ++ | 0000000000000003 | (0002) ValueSerializerId | NexusMods.MneumonicDB....RelativePathSerializer | 0100000000000002 ++ | 0000000000000002 | (0002) ValueSerializerId | NexusMods.MneumonicDB....izers/SymbolSerializer | 0100000000000001 ++ | 0000000000000001 | (0002) ValueSerializerId | NexusMods.MneumonicDB....izers/SymbolSerializer | 0100000000000001 ++ | 000000000000000D | (0001) UniqueId | NexusMods.MneumonicDB....odAttributes/LoadoutId | 0100000000000002 ++ | 000000000000000C | (0001) UniqueId | NexusMods.MneumonicDB....s.ModAttributes/Source | 0100000000000002 ++ | 000000000000000B | (0001) UniqueId | NexusMods.MneumonicDB....tes.ModAttributes/Name | 0100000000000002 ++ | 000000000000000A | (0001) UniqueId | NexusMods.MneumonicDB....utAttributes/UpdatedAt | 0100000000000002 ++ | 0000000000000009 | (0001) UniqueId | NexusMods.MneumonicDB....LoadoutAttributes/Name | 0100000000000002 ++ | 0000000000000008 | (0001) UniqueId | NexusMods.MneumonicDB....iveFileAttributes/Hash | 0100000000000002 ++ | 0000000000000007 | (0001) UniqueId | NexusMods.MneumonicDB....iveFileAttributes/Path | 0100000000000002 ++ | 0000000000000006 | (0001) UniqueId | NexusMods.MneumonicDB....s.FileAttributes/ModId | 0100000000000002 ++ | 0000000000000005 | (0001) UniqueId | NexusMods.MneumonicDB....es.FileAttributes/Hash | 0100000000000002 ++ | 0000000000000004 | (0001) UniqueId | NexusMods.MneumonicDB....es.FileAttributes/Size | 0100000000000002 ++ | 0000000000000003 | (0001) UniqueId | NexusMods.MneumonicDB....es.FileAttributes/Path | 0100000000000002 ++ | 0000000000000002 | (0001) UniqueId | NexusMods.MneumonicDB....tore/ValueSerializerId | 0100000000000001 ++ | 0000000000000001 | (0001) UniqueId | NexusMods.MneumonicDB.DatomStore/UniqueId | 0100000000000001 diff --git a/tests/NexusMods.MneumonicDB.Tests/DbTests.CanGetDatomIterator_AVETCurrent_False.verified.txt b/tests/NexusMods.MneumonicDB.Tests/DbTests.CanGetDatomIterator_AVETCurrent_False.verified.txt new file mode 100644 index 00000000..b7c56790 --- /dev/null +++ b/tests/NexusMods.MneumonicDB.Tests/DbTests.CanGetDatomIterator_AVETCurrent_False.verified.txt @@ -0,0 +1,18 @@ ++ | 0200000000000003 | (0003) Path | File1 | 0100000000000003 ++ | 0200000000000007 | (0003) Path | File1 | 0100000000000003 ++ | 020000000000000B | (0003) Path | File1 | 0100000000000003 ++ | 0200000000000004 | (0003) Path | File2 | 0100000000000003 ++ | 0200000000000008 | (0003) Path | File2 | 0100000000000003 ++ | 020000000000000C | (0003) Path | File2 | 0100000000000003 ++ | 0200000000000005 | (0003) Path | File3 | 0100000000000003 ++ | 0200000000000009 | (0003) Path | File3 | 0100000000000003 ++ | 020000000000000D | (0003) Path | File3 | 0100000000000003 ++ | 0200000000000003 | (0005) Hash | 0x00000000DEADBEEF | 0100000000000003 ++ | 0200000000000007 | (0005) Hash | 0x00000000DEADBEEF | 0100000000000003 ++ | 020000000000000B | (0005) Hash | 0x00000000DEADBEEF | 0100000000000003 ++ | 0200000000000004 | (0005) Hash | 0x00000000DEADBEF0 | 0100000000000003 ++ | 0200000000000008 | (0005) Hash | 0x00000000DEADBEF0 | 0100000000000003 ++ | 020000000000000C | (0005) Hash | 0x00000000DEADBEF0 | 0100000000000003 ++ | 0200000000000005 | (0005) Hash | 0x00000000DEADBEF1 | 0100000000000003 ++ | 0200000000000009 | (0005) Hash | 0x00000000DEADBEF1 | 0100000000000003 ++ | 020000000000000D | (0005) Hash | 0x00000000DEADBEF1 | 0100000000000003 diff --git a/tests/NexusMods.MneumonicDB.Tests/DbTests.CanGetDatomIterator_AVETCurrent_True.verified.txt b/tests/NexusMods.MneumonicDB.Tests/DbTests.CanGetDatomIterator_AVETCurrent_True.verified.txt new file mode 100644 index 00000000..3a3f185f --- /dev/null +++ b/tests/NexusMods.MneumonicDB.Tests/DbTests.CanGetDatomIterator_AVETCurrent_True.verified.txt @@ -0,0 +1,18 @@ ++ | 020000000000000D | (0005) Hash | 0x00000000DEADBEF1 | 0100000000000003 ++ | 0200000000000009 | (0005) Hash | 0x00000000DEADBEF1 | 0100000000000003 ++ | 0200000000000005 | (0005) Hash | 0x00000000DEADBEF1 | 0100000000000003 ++ | 020000000000000C | (0005) Hash | 0x00000000DEADBEF0 | 0100000000000003 ++ | 0200000000000008 | (0005) Hash | 0x00000000DEADBEF0 | 0100000000000003 ++ | 0200000000000004 | (0005) Hash | 0x00000000DEADBEF0 | 0100000000000003 ++ | 020000000000000B | (0005) Hash | 0x00000000DEADBEEF | 0100000000000003 ++ | 0200000000000007 | (0005) Hash | 0x00000000DEADBEEF | 0100000000000003 ++ | 0200000000000003 | (0005) Hash | 0x00000000DEADBEEF | 0100000000000003 ++ | 020000000000000D | (0003) Path | File3 | 0100000000000003 ++ | 0200000000000009 | (0003) Path | File3 | 0100000000000003 ++ | 0200000000000005 | (0003) Path | File3 | 0100000000000003 ++ | 020000000000000C | (0003) Path | File2 | 0100000000000003 ++ | 0200000000000008 | (0003) Path | File2 | 0100000000000003 ++ | 0200000000000004 | (0003) Path | File2 | 0100000000000003 ++ | 020000000000000B | (0003) Path | File1 | 0100000000000003 ++ | 0200000000000007 | (0003) Path | File1 | 0100000000000003 ++ | 0200000000000003 | (0003) Path | File1 | 0100000000000003 diff --git a/tests/NexusMods.MneumonicDB.Tests/DbTests.CanGetDatomIterator_EAVTCurrent_False.verified.txt b/tests/NexusMods.MneumonicDB.Tests/DbTests.CanGetDatomIterator_EAVTCurrent_False.verified.txt new file mode 100644 index 00000000..ddd7d339 --- /dev/null +++ b/tests/NexusMods.MneumonicDB.Tests/DbTests.CanGetDatomIterator_EAVTCurrent_False.verified.txt @@ -0,0 +1,73 @@ ++ | 0000000000000001 | (0001) UniqueId | NexusMods.MneumonicDB.DatomStore/UniqueId | 0100000000000001 ++ | 0000000000000001 | (0002) ValueSerializerId | NexusMods.MneumonicDB....izers/SymbolSerializer | 0100000000000001 ++ | 0000000000000002 | (0001) UniqueId | NexusMods.MneumonicDB....tore/ValueSerializerId | 0100000000000001 ++ | 0000000000000002 | (0002) ValueSerializerId | NexusMods.MneumonicDB....izers/SymbolSerializer | 0100000000000001 ++ | 0000000000000003 | (0001) UniqueId | NexusMods.MneumonicDB....es.FileAttributes/Path | 0100000000000002 ++ | 0000000000000003 | (0002) ValueSerializerId | NexusMods.MneumonicDB....RelativePathSerializer | 0100000000000002 ++ | 0000000000000004 | (0001) UniqueId | NexusMods.MneumonicDB....es.FileAttributes/Size | 0100000000000002 ++ | 0000000000000004 | (0002) ValueSerializerId | NexusMods.MneumonicDB....alizers/SizeSerializer | 0100000000000002 ++ | 0000000000000005 | (0001) UniqueId | NexusMods.MneumonicDB....es.FileAttributes/Hash | 0100000000000002 ++ | 0000000000000005 | (0002) ValueSerializerId | NexusMods.MneumonicDB....alizers/HashSerializer | 0100000000000002 ++ | 0000000000000006 | (0001) UniqueId | NexusMods.MneumonicDB....s.FileAttributes/ModId | 0100000000000002 ++ | 0000000000000006 | (0002) ValueSerializerId | NexusMods.MneumonicDB....ers/EntityIdSerializer | 0100000000000002 ++ | 0000000000000007 | (0001) UniqueId | NexusMods.MneumonicDB....iveFileAttributes/Path | 0100000000000002 ++ | 0000000000000007 | (0002) ValueSerializerId | NexusMods.MneumonicDB....RelativePathSerializer | 0100000000000002 ++ | 0000000000000008 | (0001) UniqueId | NexusMods.MneumonicDB....iveFileAttributes/Hash | 0100000000000002 ++ | 0000000000000008 | (0002) ValueSerializerId | NexusMods.MneumonicDB....alizers/HashSerializer | 0100000000000002 ++ | 0000000000000009 | (0001) UniqueId | NexusMods.MneumonicDB....LoadoutAttributes/Name | 0100000000000002 ++ | 0000000000000009 | (0002) ValueSerializerId | NexusMods.MneumonicDB....izers/StringSerializer | 0100000000000002 ++ | 000000000000000A | (0001) UniqueId | NexusMods.MneumonicDB....utAttributes/UpdatedAt | 0100000000000002 ++ | 000000000000000A | (0002) ValueSerializerId | NexusMods.MneumonicDB....alizers/TxIdSerializer | 0100000000000002 ++ | 000000000000000B | (0001) UniqueId | NexusMods.MneumonicDB....tes.ModAttributes/Name | 0100000000000002 ++ | 000000000000000B | (0002) ValueSerializerId | NexusMods.MneumonicDB....izers/StringSerializer | 0100000000000002 ++ | 000000000000000C | (0001) UniqueId | NexusMods.MneumonicDB....s.ModAttributes/Source | 0100000000000002 ++ | 000000000000000C | (0002) ValueSerializerId | NexusMods.MneumonicDB....ializers/UriSerializer | 0100000000000002 ++ | 000000000000000D | (0001) UniqueId | NexusMods.MneumonicDB....odAttributes/LoadoutId | 0100000000000002 ++ | 000000000000000D | (0002) ValueSerializerId | NexusMods.MneumonicDB....ers/EntityIdSerializer | 0100000000000002 ++ | 0200000000000001 | (0009) Name | Test Loadout | 0100000000000003 ++ | 0200000000000001 | (000A) UpdatedAt | 216172782113783808 | 0100000000000003 ++ | 0200000000000002 | (000B) Name | Mod1 - Updated | 0100000000000004 ++ | 0200000000000002 | (000C) Source | http://somesite.com/Mod1 | 0100000000000003 ++ | 0200000000000002 | (000D) LoadoutId | 0200000000000001 | 0100000000000003 ++ | 0200000000000003 | (0003) Path | File1 | 0100000000000003 ++ | 0200000000000003 | (0004) Size | 0 B | 0100000000000003 ++ | 0200000000000003 | (0005) Hash | 0x00000000DEADBEEF | 0100000000000003 ++ | 0200000000000003 | (0006) ModId | 0200000000000002 | 0100000000000003 ++ | 0200000000000004 | (0003) Path | File2 | 0100000000000003 ++ | 0200000000000004 | (0004) Size | 1 B | 0100000000000003 ++ | 0200000000000004 | (0005) Hash | 0x00000000DEADBEF0 | 0100000000000003 ++ | 0200000000000004 | (0006) ModId | 0200000000000002 | 0100000000000003 ++ | 0200000000000005 | (0003) Path | File3 | 0100000000000003 ++ | 0200000000000005 | (0004) Size | 2 B | 0100000000000003 ++ | 0200000000000005 | (0005) Hash | 0x00000000DEADBEF1 | 0100000000000003 ++ | 0200000000000005 | (0006) ModId | 0200000000000002 | 0100000000000003 ++ | 0200000000000006 | (000B) Name | Mod2 - Updated | 0100000000000004 ++ | 0200000000000006 | (000C) Source | http://somesite.com/Mod2 | 0100000000000003 ++ | 0200000000000006 | (000D) LoadoutId | 0200000000000001 | 0100000000000003 ++ | 0200000000000007 | (0003) Path | File1 | 0100000000000003 ++ | 0200000000000007 | (0004) Size | 0 B | 0100000000000003 ++ | 0200000000000007 | (0005) Hash | 0x00000000DEADBEEF | 0100000000000003 ++ | 0200000000000007 | (0006) ModId | 0200000000000006 | 0100000000000003 ++ | 0200000000000008 | (0003) Path | File2 | 0100000000000003 ++ | 0200000000000008 | (0004) Size | 1 B | 0100000000000003 ++ | 0200000000000008 | (0005) Hash | 0x00000000DEADBEF0 | 0100000000000003 ++ | 0200000000000008 | (0006) ModId | 0200000000000006 | 0100000000000003 ++ | 0200000000000009 | (0003) Path | File3 | 0100000000000003 ++ | 0200000000000009 | (0004) Size | 2 B | 0100000000000003 ++ | 0200000000000009 | (0005) Hash | 0x00000000DEADBEF1 | 0100000000000003 ++ | 0200000000000009 | (0006) ModId | 0200000000000006 | 0100000000000003 ++ | 020000000000000A | (000B) Name | Mod3 - Updated | 0100000000000004 ++ | 020000000000000A | (000C) Source | http://somesite.com/Mod3 | 0100000000000003 ++ | 020000000000000A | (000D) LoadoutId | 0200000000000001 | 0100000000000003 ++ | 020000000000000B | (0003) Path | File1 | 0100000000000003 ++ | 020000000000000B | (0004) Size | 0 B | 0100000000000003 ++ | 020000000000000B | (0005) Hash | 0x00000000DEADBEEF | 0100000000000003 ++ | 020000000000000B | (0006) ModId | 020000000000000A | 0100000000000003 ++ | 020000000000000C | (0003) Path | File2 | 0100000000000003 ++ | 020000000000000C | (0004) Size | 1 B | 0100000000000003 ++ | 020000000000000C | (0005) Hash | 0x00000000DEADBEF0 | 0100000000000003 ++ | 020000000000000C | (0006) ModId | 020000000000000A | 0100000000000003 ++ | 020000000000000D | (0003) Path | File3 | 0100000000000003 ++ | 020000000000000D | (0004) Size | 2 B | 0100000000000003 ++ | 020000000000000D | (0005) Hash | 0x00000000DEADBEF1 | 0100000000000003 ++ | 020000000000000D | (0006) ModId | 020000000000000A | 0100000000000003 diff --git a/tests/NexusMods.MneumonicDB.Tests/DbTests.CanGetDatomIterator_EAVTCurrent_True.verified.txt b/tests/NexusMods.MneumonicDB.Tests/DbTests.CanGetDatomIterator_EAVTCurrent_True.verified.txt new file mode 100644 index 00000000..32bcf02b --- /dev/null +++ b/tests/NexusMods.MneumonicDB.Tests/DbTests.CanGetDatomIterator_EAVTCurrent_True.verified.txt @@ -0,0 +1,73 @@ ++ | 020000000000000D | (0006) ModId | 020000000000000A | 0100000000000003 ++ | 020000000000000D | (0005) Hash | 0x00000000DEADBEF1 | 0100000000000003 ++ | 020000000000000D | (0004) Size | 2 B | 0100000000000003 ++ | 020000000000000D | (0003) Path | File3 | 0100000000000003 ++ | 020000000000000C | (0006) ModId | 020000000000000A | 0100000000000003 ++ | 020000000000000C | (0005) Hash | 0x00000000DEADBEF0 | 0100000000000003 ++ | 020000000000000C | (0004) Size | 1 B | 0100000000000003 ++ | 020000000000000C | (0003) Path | File2 | 0100000000000003 ++ | 020000000000000B | (0006) ModId | 020000000000000A | 0100000000000003 ++ | 020000000000000B | (0005) Hash | 0x00000000DEADBEEF | 0100000000000003 ++ | 020000000000000B | (0004) Size | 0 B | 0100000000000003 ++ | 020000000000000B | (0003) Path | File1 | 0100000000000003 ++ | 020000000000000A | (000D) LoadoutId | 0200000000000001 | 0100000000000003 ++ | 020000000000000A | (000C) Source | http://somesite.com/Mod3 | 0100000000000003 ++ | 020000000000000A | (000B) Name | Mod3 - Updated | 0100000000000004 ++ | 0200000000000009 | (0006) ModId | 0200000000000006 | 0100000000000003 ++ | 0200000000000009 | (0005) Hash | 0x00000000DEADBEF1 | 0100000000000003 ++ | 0200000000000009 | (0004) Size | 2 B | 0100000000000003 ++ | 0200000000000009 | (0003) Path | File3 | 0100000000000003 ++ | 0200000000000008 | (0006) ModId | 0200000000000006 | 0100000000000003 ++ | 0200000000000008 | (0005) Hash | 0x00000000DEADBEF0 | 0100000000000003 ++ | 0200000000000008 | (0004) Size | 1 B | 0100000000000003 ++ | 0200000000000008 | (0003) Path | File2 | 0100000000000003 ++ | 0200000000000007 | (0006) ModId | 0200000000000006 | 0100000000000003 ++ | 0200000000000007 | (0005) Hash | 0x00000000DEADBEEF | 0100000000000003 ++ | 0200000000000007 | (0004) Size | 0 B | 0100000000000003 ++ | 0200000000000007 | (0003) Path | File1 | 0100000000000003 ++ | 0200000000000006 | (000D) LoadoutId | 0200000000000001 | 0100000000000003 ++ | 0200000000000006 | (000C) Source | http://somesite.com/Mod2 | 0100000000000003 ++ | 0200000000000006 | (000B) Name | Mod2 - Updated | 0100000000000004 ++ | 0200000000000005 | (0006) ModId | 0200000000000002 | 0100000000000003 ++ | 0200000000000005 | (0005) Hash | 0x00000000DEADBEF1 | 0100000000000003 ++ | 0200000000000005 | (0004) Size | 2 B | 0100000000000003 ++ | 0200000000000005 | (0003) Path | File3 | 0100000000000003 ++ | 0200000000000004 | (0006) ModId | 0200000000000002 | 0100000000000003 ++ | 0200000000000004 | (0005) Hash | 0x00000000DEADBEF0 | 0100000000000003 ++ | 0200000000000004 | (0004) Size | 1 B | 0100000000000003 ++ | 0200000000000004 | (0003) Path | File2 | 0100000000000003 ++ | 0200000000000003 | (0006) ModId | 0200000000000002 | 0100000000000003 ++ | 0200000000000003 | (0005) Hash | 0x00000000DEADBEEF | 0100000000000003 ++ | 0200000000000003 | (0004) Size | 0 B | 0100000000000003 ++ | 0200000000000003 | (0003) Path | File1 | 0100000000000003 ++ | 0200000000000002 | (000D) LoadoutId | 0200000000000001 | 0100000000000003 ++ | 0200000000000002 | (000C) Source | http://somesite.com/Mod1 | 0100000000000003 ++ | 0200000000000002 | (000B) Name | Mod1 - Updated | 0100000000000004 ++ | 0200000000000001 | (000A) UpdatedAt | 216172782113783808 | 0100000000000003 ++ | 0200000000000001 | (0009) Name | Test Loadout | 0100000000000003 ++ | 000000000000000D | (0002) ValueSerializerId | NexusMods.MneumonicDB....ers/EntityIdSerializer | 0100000000000002 ++ | 000000000000000D | (0001) UniqueId | NexusMods.MneumonicDB....odAttributes/LoadoutId | 0100000000000002 ++ | 000000000000000C | (0002) ValueSerializerId | NexusMods.MneumonicDB....ializers/UriSerializer | 0100000000000002 ++ | 000000000000000C | (0001) UniqueId | NexusMods.MneumonicDB....s.ModAttributes/Source | 0100000000000002 ++ | 000000000000000B | (0002) ValueSerializerId | NexusMods.MneumonicDB....izers/StringSerializer | 0100000000000002 ++ | 000000000000000B | (0001) UniqueId | NexusMods.MneumonicDB....tes.ModAttributes/Name | 0100000000000002 ++ | 000000000000000A | (0002) ValueSerializerId | NexusMods.MneumonicDB....alizers/TxIdSerializer | 0100000000000002 ++ | 000000000000000A | (0001) UniqueId | NexusMods.MneumonicDB....utAttributes/UpdatedAt | 0100000000000002 ++ | 0000000000000009 | (0002) ValueSerializerId | NexusMods.MneumonicDB....izers/StringSerializer | 0100000000000002 ++ | 0000000000000009 | (0001) UniqueId | NexusMods.MneumonicDB....LoadoutAttributes/Name | 0100000000000002 ++ | 0000000000000008 | (0002) ValueSerializerId | NexusMods.MneumonicDB....alizers/HashSerializer | 0100000000000002 ++ | 0000000000000008 | (0001) UniqueId | NexusMods.MneumonicDB....iveFileAttributes/Hash | 0100000000000002 ++ | 0000000000000007 | (0002) ValueSerializerId | NexusMods.MneumonicDB....RelativePathSerializer | 0100000000000002 ++ | 0000000000000007 | (0001) UniqueId | NexusMods.MneumonicDB....iveFileAttributes/Path | 0100000000000002 ++ | 0000000000000006 | (0002) ValueSerializerId | NexusMods.MneumonicDB....ers/EntityIdSerializer | 0100000000000002 ++ | 0000000000000006 | (0001) UniqueId | NexusMods.MneumonicDB....s.FileAttributes/ModId | 0100000000000002 ++ | 0000000000000005 | (0002) ValueSerializerId | NexusMods.MneumonicDB....alizers/HashSerializer | 0100000000000002 ++ | 0000000000000005 | (0001) UniqueId | NexusMods.MneumonicDB....es.FileAttributes/Hash | 0100000000000002 ++ | 0000000000000004 | (0002) ValueSerializerId | NexusMods.MneumonicDB....alizers/SizeSerializer | 0100000000000002 ++ | 0000000000000004 | (0001) UniqueId | NexusMods.MneumonicDB....es.FileAttributes/Size | 0100000000000002 ++ | 0000000000000003 | (0002) ValueSerializerId | NexusMods.MneumonicDB....RelativePathSerializer | 0100000000000002 ++ | 0000000000000003 | (0001) UniqueId | NexusMods.MneumonicDB....es.FileAttributes/Path | 0100000000000002 ++ | 0000000000000002 | (0002) ValueSerializerId | NexusMods.MneumonicDB....izers/SymbolSerializer | 0100000000000001 ++ | 0000000000000002 | (0001) UniqueId | NexusMods.MneumonicDB....tore/ValueSerializerId | 0100000000000001 ++ | 0000000000000001 | (0002) ValueSerializerId | NexusMods.MneumonicDB....izers/SymbolSerializer | 0100000000000001 ++ | 0000000000000001 | (0001) UniqueId | NexusMods.MneumonicDB.DatomStore/UniqueId | 0100000000000001 diff --git a/tests/NexusMods.MneumonicDB.Tests/DbTests.CanGetDatomIterator_TxLog_False.verified.txt b/tests/NexusMods.MneumonicDB.Tests/DbTests.CanGetDatomIterator_TxLog_False.verified.txt new file mode 100644 index 00000000..3af97aa6 --- /dev/null +++ b/tests/NexusMods.MneumonicDB.Tests/DbTests.CanGetDatomIterator_TxLog_False.verified.txt @@ -0,0 +1,76 @@ ++ | 0000000000000001 | (0001) UniqueId | NexusMods.MneumonicDB.DatomStore/UniqueId | 0100000000000001 ++ | 0000000000000001 | (0002) ValueSerializerId | NexusMods.MneumonicDB....izers/SymbolSerializer | 0100000000000001 ++ | 0000000000000002 | (0001) UniqueId | NexusMods.MneumonicDB....tore/ValueSerializerId | 0100000000000001 ++ | 0000000000000002 | (0002) ValueSerializerId | NexusMods.MneumonicDB....izers/SymbolSerializer | 0100000000000001 ++ | 0000000000000003 | (0001) UniqueId | NexusMods.MneumonicDB....es.FileAttributes/Path | 0100000000000002 ++ | 0000000000000003 | (0002) ValueSerializerId | NexusMods.MneumonicDB....RelativePathSerializer | 0100000000000002 ++ | 0000000000000004 | (0001) UniqueId | NexusMods.MneumonicDB....es.FileAttributes/Size | 0100000000000002 ++ | 0000000000000004 | (0002) ValueSerializerId | NexusMods.MneumonicDB....alizers/SizeSerializer | 0100000000000002 ++ | 0000000000000005 | (0001) UniqueId | NexusMods.MneumonicDB....es.FileAttributes/Hash | 0100000000000002 ++ | 0000000000000005 | (0002) ValueSerializerId | NexusMods.MneumonicDB....alizers/HashSerializer | 0100000000000002 ++ | 0000000000000006 | (0001) UniqueId | NexusMods.MneumonicDB....s.FileAttributes/ModId | 0100000000000002 ++ | 0000000000000006 | (0002) ValueSerializerId | NexusMods.MneumonicDB....ers/EntityIdSerializer | 0100000000000002 ++ | 0000000000000007 | (0001) UniqueId | NexusMods.MneumonicDB....iveFileAttributes/Path | 0100000000000002 ++ | 0000000000000007 | (0002) ValueSerializerId | NexusMods.MneumonicDB....RelativePathSerializer | 0100000000000002 ++ | 0000000000000008 | (0001) UniqueId | NexusMods.MneumonicDB....iveFileAttributes/Hash | 0100000000000002 ++ | 0000000000000008 | (0002) ValueSerializerId | NexusMods.MneumonicDB....alizers/HashSerializer | 0100000000000002 ++ | 0000000000000009 | (0001) UniqueId | NexusMods.MneumonicDB....LoadoutAttributes/Name | 0100000000000002 ++ | 0000000000000009 | (0002) ValueSerializerId | NexusMods.MneumonicDB....izers/StringSerializer | 0100000000000002 ++ | 000000000000000A | (0001) UniqueId | NexusMods.MneumonicDB....utAttributes/UpdatedAt | 0100000000000002 ++ | 000000000000000A | (0002) ValueSerializerId | NexusMods.MneumonicDB....alizers/TxIdSerializer | 0100000000000002 ++ | 000000000000000B | (0001) UniqueId | NexusMods.MneumonicDB....tes.ModAttributes/Name | 0100000000000002 ++ | 000000000000000B | (0002) ValueSerializerId | NexusMods.MneumonicDB....izers/StringSerializer | 0100000000000002 ++ | 000000000000000C | (0001) UniqueId | NexusMods.MneumonicDB....s.ModAttributes/Source | 0100000000000002 ++ | 000000000000000C | (0002) ValueSerializerId | NexusMods.MneumonicDB....ializers/UriSerializer | 0100000000000002 ++ | 000000000000000D | (0001) UniqueId | NexusMods.MneumonicDB....odAttributes/LoadoutId | 0100000000000002 ++ | 000000000000000D | (0002) ValueSerializerId | NexusMods.MneumonicDB....ers/EntityIdSerializer | 0100000000000002 ++ | 0200000000000001 | (0009) Name | Test Loadout | 0100000000000003 ++ | 0200000000000001 | (000A) UpdatedAt | 216172782113783808 | 0100000000000003 ++ | 0200000000000002 | (000B) Name | Mod1 | 0100000000000003 ++ | 0200000000000002 | (000C) Source | http://somesite.com/Mod1 | 0100000000000003 ++ | 0200000000000002 | (000D) LoadoutId | 0200000000000001 | 0100000000000003 ++ | 0200000000000003 | (0003) Path | File1 | 0100000000000003 ++ | 0200000000000003 | (0004) Size | 0 B | 0100000000000003 ++ | 0200000000000003 | (0005) Hash | 0x00000000DEADBEEF | 0100000000000003 ++ | 0200000000000003 | (0006) ModId | 0200000000000002 | 0100000000000003 ++ | 0200000000000004 | (0003) Path | File2 | 0100000000000003 ++ | 0200000000000004 | (0004) Size | 1 B | 0100000000000003 ++ | 0200000000000004 | (0005) Hash | 0x00000000DEADBEF0 | 0100000000000003 ++ | 0200000000000004 | (0006) ModId | 0200000000000002 | 0100000000000003 ++ | 0200000000000005 | (0003) Path | File3 | 0100000000000003 ++ | 0200000000000005 | (0004) Size | 2 B | 0100000000000003 ++ | 0200000000000005 | (0005) Hash | 0x00000000DEADBEF1 | 0100000000000003 ++ | 0200000000000005 | (0006) ModId | 0200000000000002 | 0100000000000003 ++ | 0200000000000006 | (000B) Name | Mod2 | 0100000000000003 ++ | 0200000000000006 | (000C) Source | http://somesite.com/Mod2 | 0100000000000003 ++ | 0200000000000006 | (000D) LoadoutId | 0200000000000001 | 0100000000000003 ++ | 0200000000000007 | (0003) Path | File1 | 0100000000000003 ++ | 0200000000000007 | (0004) Size | 0 B | 0100000000000003 ++ | 0200000000000007 | (0005) Hash | 0x00000000DEADBEEF | 0100000000000003 ++ | 0200000000000007 | (0006) ModId | 0200000000000006 | 0100000000000003 ++ | 0200000000000008 | (0003) Path | File2 | 0100000000000003 ++ | 0200000000000008 | (0004) Size | 1 B | 0100000000000003 ++ | 0200000000000008 | (0005) Hash | 0x00000000DEADBEF0 | 0100000000000003 ++ | 0200000000000008 | (0006) ModId | 0200000000000006 | 0100000000000003 ++ | 0200000000000009 | (0003) Path | File3 | 0100000000000003 ++ | 0200000000000009 | (0004) Size | 2 B | 0100000000000003 ++ | 0200000000000009 | (0005) Hash | 0x00000000DEADBEF1 | 0100000000000003 ++ | 0200000000000009 | (0006) ModId | 0200000000000006 | 0100000000000003 ++ | 020000000000000A | (000B) Name | Mod3 | 0100000000000003 ++ | 020000000000000A | (000C) Source | http://somesite.com/Mod3 | 0100000000000003 ++ | 020000000000000A | (000D) LoadoutId | 0200000000000001 | 0100000000000003 ++ | 020000000000000B | (0003) Path | File1 | 0100000000000003 ++ | 020000000000000B | (0004) Size | 0 B | 0100000000000003 ++ | 020000000000000B | (0005) Hash | 0x00000000DEADBEEF | 0100000000000003 ++ | 020000000000000B | (0006) ModId | 020000000000000A | 0100000000000003 ++ | 020000000000000C | (0003) Path | File2 | 0100000000000003 ++ | 020000000000000C | (0004) Size | 1 B | 0100000000000003 ++ | 020000000000000C | (0005) Hash | 0x00000000DEADBEF0 | 0100000000000003 ++ | 020000000000000C | (0006) ModId | 020000000000000A | 0100000000000003 ++ | 020000000000000D | (0003) Path | File3 | 0100000000000003 ++ | 020000000000000D | (0004) Size | 2 B | 0100000000000003 ++ | 020000000000000D | (0005) Hash | 0x00000000DEADBEF1 | 0100000000000003 ++ | 020000000000000D | (0006) ModId | 020000000000000A | 0100000000000003 ++ | 0200000000000002 | (000B) Name | Mod1 - Updated | 0100000000000004 ++ | 0200000000000006 | (000B) Name | Mod2 - Updated | 0100000000000004 ++ | 020000000000000A | (000B) Name | Mod3 - Updated | 0100000000000004 diff --git a/tests/NexusMods.MneumonicDB.Tests/DbTests.CanGetDatomIterator_TxLog_True.verified.txt b/tests/NexusMods.MneumonicDB.Tests/DbTests.CanGetDatomIterator_TxLog_True.verified.txt new file mode 100644 index 00000000..425223d3 --- /dev/null +++ b/tests/NexusMods.MneumonicDB.Tests/DbTests.CanGetDatomIterator_TxLog_True.verified.txt @@ -0,0 +1,76 @@ ++ | 020000000000000A | (000B) Name | Mod3 - Updated | 0100000000000004 ++ | 0200000000000006 | (000B) Name | Mod2 - Updated | 0100000000000004 ++ | 0200000000000002 | (000B) Name | Mod1 - Updated | 0100000000000004 ++ | 020000000000000D | (0006) ModId | 020000000000000A | 0100000000000003 ++ | 020000000000000D | (0005) Hash | 0x00000000DEADBEF1 | 0100000000000003 ++ | 020000000000000D | (0004) Size | 2 B | 0100000000000003 ++ | 020000000000000D | (0003) Path | File3 | 0100000000000003 ++ | 020000000000000C | (0006) ModId | 020000000000000A | 0100000000000003 ++ | 020000000000000C | (0005) Hash | 0x00000000DEADBEF0 | 0100000000000003 ++ | 020000000000000C | (0004) Size | 1 B | 0100000000000003 ++ | 020000000000000C | (0003) Path | File2 | 0100000000000003 ++ | 020000000000000B | (0006) ModId | 020000000000000A | 0100000000000003 ++ | 020000000000000B | (0005) Hash | 0x00000000DEADBEEF | 0100000000000003 ++ | 020000000000000B | (0004) Size | 0 B | 0100000000000003 ++ | 020000000000000B | (0003) Path | File1 | 0100000000000003 ++ | 020000000000000A | (000D) LoadoutId | 0200000000000001 | 0100000000000003 ++ | 020000000000000A | (000C) Source | http://somesite.com/Mod3 | 0100000000000003 ++ | 020000000000000A | (000B) Name | Mod3 | 0100000000000003 ++ | 0200000000000009 | (0006) ModId | 0200000000000006 | 0100000000000003 ++ | 0200000000000009 | (0005) Hash | 0x00000000DEADBEF1 | 0100000000000003 ++ | 0200000000000009 | (0004) Size | 2 B | 0100000000000003 ++ | 0200000000000009 | (0003) Path | File3 | 0100000000000003 ++ | 0200000000000008 | (0006) ModId | 0200000000000006 | 0100000000000003 ++ | 0200000000000008 | (0005) Hash | 0x00000000DEADBEF0 | 0100000000000003 ++ | 0200000000000008 | (0004) Size | 1 B | 0100000000000003 ++ | 0200000000000008 | (0003) Path | File2 | 0100000000000003 ++ | 0200000000000007 | (0006) ModId | 0200000000000006 | 0100000000000003 ++ | 0200000000000007 | (0005) Hash | 0x00000000DEADBEEF | 0100000000000003 ++ | 0200000000000007 | (0004) Size | 0 B | 0100000000000003 ++ | 0200000000000007 | (0003) Path | File1 | 0100000000000003 ++ | 0200000000000006 | (000D) LoadoutId | 0200000000000001 | 0100000000000003 ++ | 0200000000000006 | (000C) Source | http://somesite.com/Mod2 | 0100000000000003 ++ | 0200000000000006 | (000B) Name | Mod2 | 0100000000000003 ++ | 0200000000000005 | (0006) ModId | 0200000000000002 | 0100000000000003 ++ | 0200000000000005 | (0005) Hash | 0x00000000DEADBEF1 | 0100000000000003 ++ | 0200000000000005 | (0004) Size | 2 B | 0100000000000003 ++ | 0200000000000005 | (0003) Path | File3 | 0100000000000003 ++ | 0200000000000004 | (0006) ModId | 0200000000000002 | 0100000000000003 ++ | 0200000000000004 | (0005) Hash | 0x00000000DEADBEF0 | 0100000000000003 ++ | 0200000000000004 | (0004) Size | 1 B | 0100000000000003 ++ | 0200000000000004 | (0003) Path | File2 | 0100000000000003 ++ | 0200000000000003 | (0006) ModId | 0200000000000002 | 0100000000000003 ++ | 0200000000000003 | (0005) Hash | 0x00000000DEADBEEF | 0100000000000003 ++ | 0200000000000003 | (0004) Size | 0 B | 0100000000000003 ++ | 0200000000000003 | (0003) Path | File1 | 0100000000000003 ++ | 0200000000000002 | (000D) LoadoutId | 0200000000000001 | 0100000000000003 ++ | 0200000000000002 | (000C) Source | http://somesite.com/Mod1 | 0100000000000003 ++ | 0200000000000002 | (000B) Name | Mod1 | 0100000000000003 ++ | 0200000000000001 | (000A) UpdatedAt | 216172782113783808 | 0100000000000003 ++ | 0200000000000001 | (0009) Name | Test Loadout | 0100000000000003 ++ | 000000000000000D | (0002) ValueSerializerId | NexusMods.MneumonicDB....ers/EntityIdSerializer | 0100000000000002 ++ | 000000000000000D | (0001) UniqueId | NexusMods.MneumonicDB....odAttributes/LoadoutId | 0100000000000002 ++ | 000000000000000C | (0002) ValueSerializerId | NexusMods.MneumonicDB....ializers/UriSerializer | 0100000000000002 ++ | 000000000000000C | (0001) UniqueId | NexusMods.MneumonicDB....s.ModAttributes/Source | 0100000000000002 ++ | 000000000000000B | (0002) ValueSerializerId | NexusMods.MneumonicDB....izers/StringSerializer | 0100000000000002 ++ | 000000000000000B | (0001) UniqueId | NexusMods.MneumonicDB....tes.ModAttributes/Name | 0100000000000002 ++ | 000000000000000A | (0002) ValueSerializerId | NexusMods.MneumonicDB....alizers/TxIdSerializer | 0100000000000002 ++ | 000000000000000A | (0001) UniqueId | NexusMods.MneumonicDB....utAttributes/UpdatedAt | 0100000000000002 ++ | 0000000000000009 | (0002) ValueSerializerId | NexusMods.MneumonicDB....izers/StringSerializer | 0100000000000002 ++ | 0000000000000009 | (0001) UniqueId | NexusMods.MneumonicDB....LoadoutAttributes/Name | 0100000000000002 ++ | 0000000000000008 | (0002) ValueSerializerId | NexusMods.MneumonicDB....alizers/HashSerializer | 0100000000000002 ++ | 0000000000000008 | (0001) UniqueId | NexusMods.MneumonicDB....iveFileAttributes/Hash | 0100000000000002 ++ | 0000000000000007 | (0002) ValueSerializerId | NexusMods.MneumonicDB....RelativePathSerializer | 0100000000000002 ++ | 0000000000000007 | (0001) UniqueId | NexusMods.MneumonicDB....iveFileAttributes/Path | 0100000000000002 ++ | 0000000000000006 | (0002) ValueSerializerId | NexusMods.MneumonicDB....ers/EntityIdSerializer | 0100000000000002 ++ | 0000000000000006 | (0001) UniqueId | NexusMods.MneumonicDB....s.FileAttributes/ModId | 0100000000000002 ++ | 0000000000000005 | (0002) ValueSerializerId | NexusMods.MneumonicDB....alizers/HashSerializer | 0100000000000002 ++ | 0000000000000005 | (0001) UniqueId | NexusMods.MneumonicDB....es.FileAttributes/Hash | 0100000000000002 ++ | 0000000000000004 | (0002) ValueSerializerId | NexusMods.MneumonicDB....alizers/SizeSerializer | 0100000000000002 ++ | 0000000000000004 | (0001) UniqueId | NexusMods.MneumonicDB....es.FileAttributes/Size | 0100000000000002 ++ | 0000000000000003 | (0002) ValueSerializerId | NexusMods.MneumonicDB....RelativePathSerializer | 0100000000000002 ++ | 0000000000000003 | (0001) UniqueId | NexusMods.MneumonicDB....es.FileAttributes/Path | 0100000000000002 ++ | 0000000000000002 | (0002) ValueSerializerId | NexusMods.MneumonicDB....izers/SymbolSerializer | 0100000000000001 ++ | 0000000000000002 | (0001) UniqueId | NexusMods.MneumonicDB....tore/ValueSerializerId | 0100000000000001 ++ | 0000000000000001 | (0002) ValueSerializerId | NexusMods.MneumonicDB....izers/SymbolSerializer | 0100000000000001 ++ | 0000000000000001 | (0001) UniqueId | NexusMods.MneumonicDB.DatomStore/UniqueId | 0100000000000001 diff --git a/tests/NexusMods.MneumonicDB.Tests/DbTests.CanGetDatomIterator_VAETCurrent_False.verified.txt b/tests/NexusMods.MneumonicDB.Tests/DbTests.CanGetDatomIterator_VAETCurrent_False.verified.txt new file mode 100644 index 00000000..1da9a94e --- /dev/null +++ b/tests/NexusMods.MneumonicDB.Tests/DbTests.CanGetDatomIterator_VAETCurrent_False.verified.txt @@ -0,0 +1,12 @@ ++ | 0200000000000002 | (000D) LoadoutId | 0200000000000001 | 0100000000000003 ++ | 0200000000000006 | (000D) LoadoutId | 0200000000000001 | 0100000000000003 ++ | 020000000000000A | (000D) LoadoutId | 0200000000000001 | 0100000000000003 ++ | 0200000000000003 | (0006) ModId | 0200000000000002 | 0100000000000003 ++ | 0200000000000004 | (0006) ModId | 0200000000000002 | 0100000000000003 ++ | 0200000000000005 | (0006) ModId | 0200000000000002 | 0100000000000003 ++ | 0200000000000007 | (0006) ModId | 0200000000000006 | 0100000000000003 ++ | 0200000000000008 | (0006) ModId | 0200000000000006 | 0100000000000003 ++ | 0200000000000009 | (0006) ModId | 0200000000000006 | 0100000000000003 ++ | 020000000000000B | (0006) ModId | 020000000000000A | 0100000000000003 ++ | 020000000000000C | (0006) ModId | 020000000000000A | 0100000000000003 ++ | 020000000000000D | (0006) ModId | 020000000000000A | 0100000000000003 diff --git a/tests/NexusMods.MneumonicDB.Tests/DbTests.CanGetDatomIterator_VAETCurrent_True.verified.txt b/tests/NexusMods.MneumonicDB.Tests/DbTests.CanGetDatomIterator_VAETCurrent_True.verified.txt new file mode 100644 index 00000000..05c6ce38 --- /dev/null +++ b/tests/NexusMods.MneumonicDB.Tests/DbTests.CanGetDatomIterator_VAETCurrent_True.verified.txt @@ -0,0 +1,12 @@ ++ | 020000000000000D | (0006) ModId | 020000000000000A | 0100000000000003 ++ | 020000000000000C | (0006) ModId | 020000000000000A | 0100000000000003 ++ | 020000000000000B | (0006) ModId | 020000000000000A | 0100000000000003 ++ | 0200000000000009 | (0006) ModId | 0200000000000006 | 0100000000000003 ++ | 0200000000000008 | (0006) ModId | 0200000000000006 | 0100000000000003 ++ | 0200000000000007 | (0006) ModId | 0200000000000006 | 0100000000000003 ++ | 0200000000000005 | (0006) ModId | 0200000000000002 | 0100000000000003 ++ | 0200000000000004 | (0006) ModId | 0200000000000002 | 0100000000000003 ++ | 0200000000000003 | (0006) ModId | 0200000000000002 | 0100000000000003 ++ | 020000000000000A | (000D) LoadoutId | 0200000000000001 | 0100000000000003 ++ | 0200000000000006 | (000D) LoadoutId | 0200000000000001 | 0100000000000003 ++ | 0200000000000002 | (000D) LoadoutId | 0200000000000001 | 0100000000000003 diff --git a/tests/NexusMods.MneumonicDB.Tests/DbTests.CanGetDatomsByAttr.verified.txt b/tests/NexusMods.MneumonicDB.Tests/DbTests.CanGetDatomsByAttr.verified.txt new file mode 100644 index 00000000..f55266b0 --- /dev/null +++ b/tests/NexusMods.MneumonicDB.Tests/DbTests.CanGetDatomsByAttr.verified.txt @@ -0,0 +1,3 @@ ++ | 0200000000000002 | (000B) Name | Mod1 - Updated | 0100000000000004 ++ | 0200000000000006 | (000B) Name | Mod2 - Updated | 0100000000000004 ++ | 020000000000000A | (000B) Name | Mod3 - Updated | 0100000000000004 diff --git a/tests/NexusMods.MneumonicDB.Tests/DbTests.DbIsImmutable.verified.txt b/tests/NexusMods.MneumonicDB.Tests/DbTests.DbIsImmutable.verified.txt new file mode 100644 index 00000000..d7e1a8f2 --- /dev/null +++ b/tests/NexusMods.MneumonicDB.Tests/DbTests.DbIsImmutable.verified.txt @@ -0,0 +1,4 @@ ++ | 0200000000000001 | (0003) Path | C:\test_0.txt_mutate | 0100000000000004 ++ | 0200000000000001 | (0004) Size | 1 B | 0100000000000003 ++ | 0200000000000001 | (0005) Hash | 0x00000000DEADBEF0 | 0100000000000003 ++ | 0200000000000001 | (0006) ModId | 0000000000000001 | 0100000000000003 diff --git a/tests/NexusMods.MneumonicDB.Tests/DbTests.DbIsImmutable_mutated data 0.verified.txt b/tests/NexusMods.MneumonicDB.Tests/DbTests.DbIsImmutable_mutated data 0.verified.txt new file mode 100644 index 00000000..d7e1a8f2 --- /dev/null +++ b/tests/NexusMods.MneumonicDB.Tests/DbTests.DbIsImmutable_mutated data 0.verified.txt @@ -0,0 +1,4 @@ ++ | 0200000000000001 | (0003) Path | C:\test_0.txt_mutate | 0100000000000004 ++ | 0200000000000001 | (0004) Size | 1 B | 0100000000000003 ++ | 0200000000000001 | (0005) Hash | 0x00000000DEADBEF0 | 0100000000000003 ++ | 0200000000000001 | (0006) ModId | 0000000000000001 | 0100000000000003 diff --git a/tests/NexusMods.MneumonicDB.Tests/DbTests.DbIsImmutable_mutated data 1.verified.txt b/tests/NexusMods.MneumonicDB.Tests/DbTests.DbIsImmutable_mutated data 1.verified.txt new file mode 100644 index 00000000..465abc77 --- /dev/null +++ b/tests/NexusMods.MneumonicDB.Tests/DbTests.DbIsImmutable_mutated data 1.verified.txt @@ -0,0 +1,4 @@ ++ | 0200000000000001 | (0003) Path | C:\test_1.txt_mutate | 0100000000000005 ++ | 0200000000000001 | (0004) Size | 1 B | 0100000000000003 ++ | 0200000000000001 | (0005) Hash | 0x00000000DEADBEF0 | 0100000000000003 ++ | 0200000000000001 | (0006) ModId | 0000000000000001 | 0100000000000003 diff --git a/tests/NexusMods.MneumonicDB.Tests/DbTests.DbIsImmutable_mutated data 2.verified.txt b/tests/NexusMods.MneumonicDB.Tests/DbTests.DbIsImmutable_mutated data 2.verified.txt new file mode 100644 index 00000000..4d9bc1e3 --- /dev/null +++ b/tests/NexusMods.MneumonicDB.Tests/DbTests.DbIsImmutable_mutated data 2.verified.txt @@ -0,0 +1,4 @@ ++ | 0200000000000001 | (0003) Path | C:\test_2.txt_mutate | 0100000000000006 ++ | 0200000000000001 | (0004) Size | 1 B | 0100000000000003 ++ | 0200000000000001 | (0005) Hash | 0x00000000DEADBEF0 | 0100000000000003 ++ | 0200000000000001 | (0006) ModId | 0000000000000001 | 0100000000000003 diff --git a/tests/NexusMods.MneumonicDB.Tests/DbTests.DbIsImmutable_original data.verified.txt b/tests/NexusMods.MneumonicDB.Tests/DbTests.DbIsImmutable_original data.verified.txt new file mode 100644 index 00000000..c7b91d70 --- /dev/null +++ b/tests/NexusMods.MneumonicDB.Tests/DbTests.DbIsImmutable_original data.verified.txt @@ -0,0 +1,4 @@ ++ | 0200000000000001 | (0003) Path | C:\test.txt | 0100000000000003 ++ | 0200000000000001 | (0004) Size | 1 B | 0100000000000003 ++ | 0200000000000001 | (0005) Hash | 0x00000000DEADBEF0 | 0100000000000003 ++ | 0200000000000001 | (0006) ModId | 0000000000000001 | 0100000000000003 diff --git a/tests/NexusMods.MneumonicDB.Tests/DbTests.DbIsImmutable_original data0.verified.txt b/tests/NexusMods.MneumonicDB.Tests/DbTests.DbIsImmutable_original data0.verified.txt new file mode 100644 index 00000000..c7b91d70 --- /dev/null +++ b/tests/NexusMods.MneumonicDB.Tests/DbTests.DbIsImmutable_original data0.verified.txt @@ -0,0 +1,4 @@ ++ | 0200000000000001 | (0003) Path | C:\test.txt | 0100000000000003 ++ | 0200000000000001 | (0004) Size | 1 B | 0100000000000003 ++ | 0200000000000001 | (0005) Hash | 0x00000000DEADBEF0 | 0100000000000003 ++ | 0200000000000001 | (0006) ModId | 0000000000000001 | 0100000000000003 diff --git a/tests/NexusMods.MneumonicDB.Tests/DbTests.DbIsImmutable_original data1.verified.txt b/tests/NexusMods.MneumonicDB.Tests/DbTests.DbIsImmutable_original data1.verified.txt new file mode 100644 index 00000000..c7b91d70 --- /dev/null +++ b/tests/NexusMods.MneumonicDB.Tests/DbTests.DbIsImmutable_original data1.verified.txt @@ -0,0 +1,4 @@ ++ | 0200000000000001 | (0003) Path | C:\test.txt | 0100000000000003 ++ | 0200000000000001 | (0004) Size | 1 B | 0100000000000003 ++ | 0200000000000001 | (0005) Hash | 0x00000000DEADBEF0 | 0100000000000003 ++ | 0200000000000001 | (0006) ModId | 0000000000000001 | 0100000000000003 diff --git a/tests/NexusMods.MneumonicDB.Tests/DbTests.DbIsImmutable_original data2.verified.txt b/tests/NexusMods.MneumonicDB.Tests/DbTests.DbIsImmutable_original data2.verified.txt new file mode 100644 index 00000000..c7b91d70 --- /dev/null +++ b/tests/NexusMods.MneumonicDB.Tests/DbTests.DbIsImmutable_original data2.verified.txt @@ -0,0 +1,4 @@ ++ | 0200000000000001 | (0003) Path | C:\test.txt | 0100000000000003 ++ | 0200000000000001 | (0004) Size | 1 B | 0100000000000003 ++ | 0200000000000001 | (0005) Hash | 0x00000000DEADBEF0 | 0100000000000003 ++ | 0200000000000001 | (0006) ModId | 0000000000000001 | 0100000000000003 diff --git a/tests/NexusMods.MneumonicDB.Tests/DbTests.ReadDatomsForEntity.verified.txt b/tests/NexusMods.MneumonicDB.Tests/DbTests.ReadDatomsForEntity.verified.txt new file mode 100644 index 00000000..0b1c4232 --- /dev/null +++ b/tests/NexusMods.MneumonicDB.Tests/DbTests.ReadDatomsForEntity.verified.txt @@ -0,0 +1,40 @@ ++ | 0200000000000001 | (0003) Path | C:\test_0.txt | 0100000000000003 ++ | 0200000000000001 | (0004) Size | 0 B | 0100000000000003 ++ | 0200000000000001 | (0005) Hash | 0x00000000DEADBEEF | 0100000000000003 ++ | 0200000000000001 | (0006) ModId | 0000000000000001 | 0100000000000003 ++ | 0200000000000002 | (0003) Path | C:\test_1.txt | 0100000000000003 ++ | 0200000000000002 | (0004) Size | 1 B | 0100000000000003 ++ | 0200000000000002 | (0005) Hash | 0x00000000DEADBEF0 | 0100000000000003 ++ | 0200000000000002 | (0006) ModId | 0000000000000001 | 0100000000000003 ++ | 0200000000000003 | (0003) Path | C:\test_2.txt | 0100000000000003 ++ | 0200000000000003 | (0004) Size | 2 B | 0100000000000003 ++ | 0200000000000003 | (0005) Hash | 0x00000000DEADBEF1 | 0100000000000003 ++ | 0200000000000003 | (0006) ModId | 0000000000000001 | 0100000000000003 ++ | 0200000000000004 | (0003) Path | C:\test_3.txt | 0100000000000003 ++ | 0200000000000004 | (0004) Size | 3 B | 0100000000000003 ++ | 0200000000000004 | (0005) Hash | 0x00000000DEADBEF2 | 0100000000000003 ++ | 0200000000000004 | (0006) ModId | 0000000000000001 | 0100000000000003 ++ | 0200000000000005 | (0003) Path | C:\test_4.txt | 0100000000000003 ++ | 0200000000000005 | (0004) Size | 4 B | 0100000000000003 ++ | 0200000000000005 | (0005) Hash | 0x00000000DEADBEF3 | 0100000000000003 ++ | 0200000000000005 | (0006) ModId | 0000000000000001 | 0100000000000003 ++ | 0200000000000006 | (0003) Path | C:\test_5.txt | 0100000000000003 ++ | 0200000000000006 | (0004) Size | 5 B | 0100000000000003 ++ | 0200000000000006 | (0005) Hash | 0x00000000DEADBEF4 | 0100000000000003 ++ | 0200000000000006 | (0006) ModId | 0000000000000001 | 0100000000000003 ++ | 0200000000000007 | (0003) Path | C:\test_6.txt | 0100000000000003 ++ | 0200000000000007 | (0004) Size | 6 B | 0100000000000003 ++ | 0200000000000007 | (0005) Hash | 0x00000000DEADBEF5 | 0100000000000003 ++ | 0200000000000007 | (0006) ModId | 0000000000000001 | 0100000000000003 ++ | 0200000000000008 | (0003) Path | C:\test_7.txt | 0100000000000003 ++ | 0200000000000008 | (0004) Size | 7 B | 0100000000000003 ++ | 0200000000000008 | (0005) Hash | 0x00000000DEADBEF6 | 0100000000000003 ++ | 0200000000000008 | (0006) ModId | 0000000000000001 | 0100000000000003 ++ | 0200000000000009 | (0003) Path | C:\test_8.txt | 0100000000000003 ++ | 0200000000000009 | (0004) Size | 8 B | 0100000000000003 ++ | 0200000000000009 | (0005) Hash | 0x00000000DEADBEF7 | 0100000000000003 ++ | 0200000000000009 | (0006) ModId | 0000000000000001 | 0100000000000003 ++ | 020000000000000A | (0003) Path | C:\test_9.txt | 0100000000000003 ++ | 020000000000000A | (0004) Size | 9 B | 0100000000000003 ++ | 020000000000000A | (0005) Hash | 0x00000000DEADBEF8 | 0100000000000003 ++ | 020000000000000A | (0006) ModId | 0000000000000001 | 0100000000000003 diff --git a/tests/NexusMods.MneumonicDB.Tests/DbTests.ReadModelsCanHaveExtraAttributes_archive file data.verified.txt b/tests/NexusMods.MneumonicDB.Tests/DbTests.ReadModelsCanHaveExtraAttributes_archive file data.verified.txt new file mode 100644 index 00000000..dac4603e --- /dev/null +++ b/tests/NexusMods.MneumonicDB.Tests/DbTests.ReadModelsCanHaveExtraAttributes_archive file data.verified.txt @@ -0,0 +1,4 @@ ++ | 0200000000000001 | (0003) Path | C:\test.txt | 0100000000000003 ++ | 0200000000000001 | (0004) Size | 1 B | 0100000000000003 ++ | 0200000000000001 | (0007) Path | C:\test.zip | 0100000000000003 ++ | 0200000000000001 | (0008) Hash | 0x00000000FEEDBEEF | 0100000000000003 diff --git a/tests/NexusMods.MneumonicDB.Tests/DbTests.ReadModelsCanHaveExtraAttributes_file data.verified.txt b/tests/NexusMods.MneumonicDB.Tests/DbTests.ReadModelsCanHaveExtraAttributes_file data.verified.txt new file mode 100644 index 00000000..c7b91d70 --- /dev/null +++ b/tests/NexusMods.MneumonicDB.Tests/DbTests.ReadModelsCanHaveExtraAttributes_file data.verified.txt @@ -0,0 +1,4 @@ ++ | 0200000000000001 | (0003) Path | C:\test.txt | 0100000000000003 ++ | 0200000000000001 | (0004) Size | 1 B | 0100000000000003 ++ | 0200000000000001 | (0005) Hash | 0x00000000DEADBEF0 | 0100000000000003 ++ | 0200000000000001 | (0006) ModId | 0000000000000001 | 0100000000000003 diff --git a/tests/NexusMods.EventSourcing.Tests/DbTests.cs b/tests/NexusMods.MneumonicDB.Tests/DbTests.cs similarity index 56% rename from tests/NexusMods.EventSourcing.Tests/DbTests.cs rename to tests/NexusMods.MneumonicDB.Tests/DbTests.cs index 2e563fee..4d240c0b 100644 --- a/tests/NexusMods.EventSourcing.Tests/DbTests.cs +++ b/tests/NexusMods.MneumonicDB.Tests/DbTests.cs @@ -1,11 +1,16 @@ -using NexusMods.EventSourcing.Abstractions; -using NexusMods.EventSourcing.TestModel.Model; -using NexusMods.EventSourcing.TestModel.Model.Attributes; -using File = NexusMods.EventSourcing.TestModel.Model.File; - -namespace NexusMods.EventSourcing.Tests; - -public class DbTests(IServiceProvider provider) : AEventSourcingTest(provider) +using NexusMods.MneumonicDB.Abstractions; +using NexusMods.MneumonicDB.Abstractions.DatomIterators; +using NexusMods.MneumonicDB.TestModel.ComplexModel.Attributes; +using NexusMods.MneumonicDB.TestModel.ComplexModel.ReadModels; +using NexusMods.MneumonicDB.TestModel.Helpers; +using NexusMods.Hashing.xxHash64; +using NexusMods.Paths; +using File = NexusMods.MneumonicDB.TestModel.ComplexModel.ReadModels.File; +using FileAttributes = NexusMods.MneumonicDB.TestModel.ComplexModel.Attributes.FileAttributes; + +namespace NexusMods.MneumonicDB.Tests; + +public class DbTests(IServiceProvider provider) : AMneumonicDBTest(provider) { [Fact] public async Task ReadDatomsForEntity() @@ -20,8 +25,9 @@ public async Task ReadDatomsForEntity() var file = new File(tx) { Path = $"C:\\test_{idx}.txt", - Hash = idx + 0xDEADBEEF, - Index = idx + Hash = Hash.From(idx + 0xDEADBEEF), + Size = Size.From(idx), + ModId = EntityId.From(1) }; ids.Add(file.Id); } @@ -35,32 +41,27 @@ public async Task ReadDatomsForEntity() var db = Connection.Db; var resolved = db.Get(ids.Select(id => result[id])).ToArray(); - - resolved.Should().HaveCount(totalCount); - foreach (var readModel in resolved) - { - var idx = readModel.Index; - readModel.Hash.Should().Be(idx + 0xDEADBEEF); - readModel.Path.Should().Be($"C:\\test_{idx}.txt"); - readModel.Index.Should().Be(idx); - } + await VerifyModel(resolved); } [Fact] public async Task DbIsImmutable() { - const int times = 10; + const int times = 3; // Insert some data var tx = Connection.BeginTransaction(); + var file = new File(tx) { - Path = "C:\\test.txt_mutate", - Hash = 0xDEADBEEF, - Index = 0 + Path = "C:\\test.txt", + Hash = Hash.From(1 + 0xDEADBEEF), + Size = Size.From(1), + ModId = EntityId.From(1) }; + var result = await tx.Commit(); var realId = result[file.Id]; @@ -68,15 +69,15 @@ public async Task DbIsImmutable() // Validate the data var found = originalDb.Get([realId]).First(); - found.Path.Should().Be("C:\\test.txt_mutate"); - found.Hash.Should().Be(0xDEADBEEF); - found.Index.Should().Be(0); + await VerifyModel(found).UseTextForParameters("original data"); + // Mutate the data for (var i = 0; i < times; i++) { var newTx = Connection.BeginTransaction(); - ModFileAttributes.Path.Add(newTx, realId, $"C:\\test_{i}.txt_mutate"); + FileAttributes. + Path.Add(newTx, realId, $"C:\\test_{i}.txt_mutate"); await newTx.Commit(); @@ -86,11 +87,11 @@ public async Task DbIsImmutable() "transaction id should be incremented by 1 for each mutation at iteration " + i); var newFound = newDb.Get([realId]).First(); - newFound.Path.Should().Be($"C:\\test_{i}.txt_mutate"); + await VerifyModel(newFound).UseTextForParameters("mutated data " + i); // Validate the original data var orignalFound = originalDb.Get([realId]).First(); - orignalFound.Path.Should().Be("C:\\test.txt_mutate"); + await VerifyModel(orignalFound).UseTextForParameters("original data" + i); } } @@ -103,29 +104,28 @@ public async Task ReadModelsCanHaveExtraAttributes() var file = new File(tx) { Path = "C:\\test.txt", - Hash = 0xDEADBEEF, - Index = 77 + Hash = Hash.From(1 + 0xDEADBEEF), + Size = Size.From(1), + ModId = EntityId.From(1) }; + // Attach extra attributes to the entity ArchiveFileAttributes.Path.Add(tx, file.Id, "C:\\test.zip"); - ArchiveFileAttributes.ArchiveHash.Add(tx, file.Id, 0xFEEDBEEF); + ArchiveFileAttributes.Hash.Add(tx, file.Id, Hash.From(0xFEEDBEEF)); var result = await tx.Commit(); var realId = result[file.Id]; var db = Connection.Db; + // Original data exists var readModel = db.Get([realId]).First(); - readModel.Path.Should().Be("C:\\test.txt"); - readModel.Hash.Should().Be(0xDEADBEEF); - readModel.Index.Should().Be(77); + await VerifyModel(readModel).UseTextForParameters("file data"); + // Extra data exists and can be read with a different read model var archiveReadModel = db.Get([realId]).First(); - archiveReadModel.ModPath.Should().Be("C:\\test.txt"); - archiveReadModel.Path.Should().Be("C:\\test.zip"); - archiveReadModel.Hash.Should().Be(0xFEEDBEEF); - archiveReadModel.Index.Should().Be(77); + await VerifyModel(archiveReadModel).UseTextForParameters("archive file data"); } [Fact] @@ -138,8 +138,9 @@ public async Task CanGetCommitUpdates() var file = new File(tx) { Path = "C:\\test.txt", - Hash = 0xDEADBEEF, - Index = 77 + Hash = Hash.From((ulong)0xDEADBEEF), + Size = Size.From(1), + ModId = EntityId.From(1) }; var result = await tx.Commit(); @@ -153,20 +154,19 @@ public async Task CanGetCommitUpdates() updates.Add(datoms); }); - for (var idx = 0; idx < 10; idx++) + for (var idx = 0; idx < 4; idx++) { tx = Connection.BeginTransaction(); - ModFileAttributes.Index.Add(tx, realId, (ulong)idx); + FileAttributes.Hash.Add(tx, realId, Hash.From(0xDEADBEEF + (ulong)idx)); result = await tx.Commit(); await Task.Delay(100); updates.Should().HaveCount(idx + 1); - var updateDatom = updates[idx] - .First(); + var updateDatom = updates[idx]; - var value = ((ScalarAttribute.ReadDatom)updateDatom).V; - value.Should().Be((ulong)idx); + await VerifyTable(updateDatom) + .UseTextForParameters("update_datom_" + idx); } } @@ -175,8 +175,8 @@ public async Task CanGetChildEntities() { var tx = Connection.BeginTransaction(); var loadout = Loadout.Create(tx, "Test Loadout"); - Mod.Create(tx, "Test Mod 1", loadout.Id); - Mod.Create(tx, "Test Mod 2", loadout.Id); + Mod.Create(tx, "Test Mod 1", new Uri("http://somesite.com/mod1"), loadout); + Mod.Create(tx, "Test Mod 2", new Uri("http://somesite.com/mod1"), loadout); var result = await tx.Commit(); var newDb = Connection.Db; @@ -195,4 +195,36 @@ public async Task CanGetChildEntities() loadout.Name.Should().Be("Test Loadout"); firstMod.Loadout.Name.Should().Be("Test Loadout"); } + + [Fact] + public async Task CanGetDatomsByAttr() + { + await InsertExampleData(); + await VerifyTable(Connection.Db.Datoms()); + } + + [Theory] + [InlineData(IndexType.EAVTCurrent, false)] + [InlineData(IndexType.EAVTCurrent, true)] + [InlineData(IndexType.AEVTCurrent, false)] + [InlineData(IndexType.AEVTCurrent, true)] + [InlineData(IndexType.AVETCurrent, false)] + [InlineData(IndexType.AVETCurrent, true)] + [InlineData(IndexType.VAETCurrent, false)] + [InlineData(IndexType.VAETCurrent, true)] + [InlineData(IndexType.TxLog, true)] + [InlineData(IndexType.TxLog, false)] + public async Task CanGetDatomIterator(IndexType index, bool reverse) + { + await InsertExampleData(); + + var db = Connection.Db; + using var iterator = db.Iterate(index); + var datoms = iterator.SeekStart(); + + if (reverse) + datoms = iterator.SeekLast().Reverse(); + + await VerifyTable(datoms.Resolve()).UseTextForParameters($"{index}_{reverse}"); + } } diff --git a/tests/NexusMods.EventSourcing.Tests/GlobalUsings.cs b/tests/NexusMods.MneumonicDB.Tests/GlobalUsings.cs similarity index 100% rename from tests/NexusMods.EventSourcing.Tests/GlobalUsings.cs rename to tests/NexusMods.MneumonicDB.Tests/GlobalUsings.cs diff --git a/tests/NexusMods.EventSourcing.Tests/NexusMods.EventSourcing.Tests.csproj b/tests/NexusMods.MneumonicDB.Tests/NexusMods.MneumonicDB.Tests.csproj similarity index 84% rename from tests/NexusMods.EventSourcing.Tests/NexusMods.EventSourcing.Tests.csproj rename to tests/NexusMods.MneumonicDB.Tests/NexusMods.MneumonicDB.Tests.csproj index ff0405a0..d395399c 100644 --- a/tests/NexusMods.EventSourcing.Tests/NexusMods.EventSourcing.Tests.csproj +++ b/tests/NexusMods.MneumonicDB.Tests/NexusMods.MneumonicDB.Tests.csproj @@ -2,7 +2,7 @@ true - NexusMods.EventSourcing.Tests + NexusMods.MneumonicDB.Tests @@ -39,8 +39,14 @@ - - + + + + + + + DbTests.cs + diff --git a/tests/NexusMods.EventSourcing.Tests/Startup.cs b/tests/NexusMods.MneumonicDB.Tests/Startup.cs similarity index 68% rename from tests/NexusMods.EventSourcing.Tests/Startup.cs rename to tests/NexusMods.MneumonicDB.Tests/Startup.cs index 019bdc1a..8e3c37e4 100644 --- a/tests/NexusMods.EventSourcing.Tests/Startup.cs +++ b/tests/NexusMods.MneumonicDB.Tests/Startup.cs @@ -1,10 +1,10 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -using NexusMods.EventSourcing.Storage; -using NexusMods.EventSourcing.TestModel; +using NexusMods.MneumonicDB.Storage; +using NexusMods.MneumonicDB.TestModel; using Xunit.DependencyInjection.Logging; -namespace NexusMods.EventSourcing.Tests; +namespace NexusMods.MneumonicDB.Tests; public class Startup { @@ -12,6 +12,6 @@ public void ConfigureServices(IServiceCollection services) { services.AddTestModel() .AddLogging(builder => builder.AddXunitOutput().SetMinimumLevel(LogLevel.Debug)) - .AddEventSourcingStorage(); + .AddMneumonicDBStorage(); } } diff --git a/tests/SharedUsings.cs b/tests/SharedUsings.cs index b3ab511c..5d390106 100644 --- a/tests/SharedUsings.cs +++ b/tests/SharedUsings.cs @@ -5,7 +5,7 @@ global using AutoFixture; global using AutoFixture.Xunit2; using System.Runtime.CompilerServices; -using NexusMods.EventSourcing.TestModel.Helpers; +using NexusMods.MneumonicDB.TestModel.Helpers; public static class Initializer {