diff --git a/benchmarks/OneBillionDatomsTest/Program.cs b/benchmarks/OneBillionDatomsTest/Program.cs index a153457c..4c4336e1 100644 --- a/benchmarks/OneBillionDatomsTest/Program.cs +++ b/benchmarks/OneBillionDatomsTest/Program.cs @@ -60,7 +60,7 @@ var tasks = new List>(); - for (int i = 0; i < 4; i++) + for (int i = 0; i < 1; i++) { var task = Task.Run(() => { diff --git a/src/NexusMods.MneumonicDB.Abstractions/IAttribute.cs b/src/NexusMods.MneumonicDB.Abstractions/IAttribute.cs index ebfcdda8..c32c989d 100644 --- a/src/NexusMods.MneumonicDB.Abstractions/IAttribute.cs +++ b/src/NexusMods.MneumonicDB.Abstractions/IAttribute.cs @@ -69,6 +69,14 @@ public interface IAttribute : IAttribute /// public static abstract IWriteDatom Assert(EntityId e, TVal v); + /// + /// Construct a new write Datom for the retraction of the given entity and value + /// + /// + /// + /// + public static abstract IWriteDatom Retract(EntityId e, TVal v); + /// /// Gets the serializer for the attribute /// diff --git a/src/NexusMods.MneumonicDB.Abstractions/IDatomStore.cs b/src/NexusMods.MneumonicDB.Abstractions/IDatomStore.cs index f33e2daf..460d688f 100644 --- a/src/NexusMods.MneumonicDB.Abstractions/IDatomStore.cs +++ b/src/NexusMods.MneumonicDB.Abstractions/IDatomStore.cs @@ -40,53 +40,6 @@ public interface IDatomStore : IDisposable /// Task RegisterAttributes(IEnumerable newAttrs); - /// - /// Gets the entities that have the given attribute that reference the given entity id. - /// - IEnumerable GetReferencesToEntityThroughAttribute(EntityId id, TxId txId) - where TAttribute : IAttribute; - - /// - /// Gets the value of the given attribute for the given entity id where the transaction id exactly matches the given - /// txId. - /// - bool TryGetExact(EntityId e, TxId tx, out TValue val) where TAttr : IAttribute; - - /// - /// Gets the latest value of the given attribute for the given entity id where the transaction id is less than or equal - /// to the given txId. - /// - bool TryGetLatest(EntityId e, TxId tx, out TValue value) where TAttribute : IAttribute; - - /// - /// Gets all the entities that have the given attribute. - /// - IEnumerable GetEntitiesWithAttribute(TxId tx) where TAttribute : IAttribute; - - /// - /// Gets all the attributes for the given entity id where the transaction id is less than or equal to the given txId. - /// - IEnumerable GetAttributesForEntity(EntityId realId, TxId txId); - - /// - /// Gets the maximum entity id in the store. - /// - EntityId GetMaxEntityId(); - - /// - /// Gets the type of the read datom for the given attribute. - /// - Type GetReadDatomType(Type attribute); - - - /// - /// Get all the datoms in a given index, not super useful as this may return a TOOON of datoms. - /// - /// - /// - /// - public IEnumerable Datoms(ISnapshot snapshot, IndexType type); - /// /// Create a snapshot of the current state of the store. /// diff --git a/src/NexusMods.MneumonicDB.Abstractions/ScalarAttribute.cs b/src/NexusMods.MneumonicDB.Abstractions/ScalarAttribute.cs index 25f57189..04046265 100644 --- a/src/NexusMods.MneumonicDB.Abstractions/ScalarAttribute.cs +++ b/src/NexusMods.MneumonicDB.Abstractions/ScalarAttribute.cs @@ -105,7 +105,18 @@ public static IWriteDatom Assert(EntityId e, TValueType v) return new WriteDatom { E = e, - V = v + V = v, + IsRetract = false + }; + } + + public static IWriteDatom Retract(EntityId e, TValueType v) + { + return new WriteDatom + { + E = e, + V = v, + IsRetract = true }; } @@ -146,11 +157,16 @@ public TValueType Read(ReadOnlySpan buffer) /// public required EntityId E { get; init; } + /// + /// True if this is a retraction + /// + public required bool IsRetract { get; init; } + public void Explode(IAttributeRegistry registry, Func remapFn, out EntityId e, out AttributeId a, TWriter vWriter, out bool isRetract) where TWriter : IBufferWriter { - isRetract = false; + isRetract = IsRetract; e = EntityId.From(Ids.IsPartition(E.Value, Ids.Partition.Tmp) ? remapFn(E).Value : E.Value); if (V is EntityId id) diff --git a/src/NexusMods.MneumonicDB.Storage/DatomStore.cs b/src/NexusMods.MneumonicDB.Storage/DatomStore.cs index aebd0522..2e0e6a23 100644 --- a/src/NexusMods.MneumonicDB.Storage/DatomStore.cs +++ b/src/NexusMods.MneumonicDB.Storage/DatomStore.cs @@ -201,15 +201,6 @@ public ISnapshot GetSnapshot() return _backend.GetSnapshot(); } - - public IEnumerable Datoms(ISnapshot snapshot, IndexType type) - { - using var source = snapshot.GetIterator(type); - var iter = source.SeekStart(); - foreach (var datom in iter.Resolve()) - yield return datom; - } - public void Dispose() { _updatesSubject.Dispose(); @@ -326,7 +317,7 @@ private EntityId MaybeRemap(EntityId id, Dictionary remaps, } - private void Log(PendingTransaction pendingTransaction, out StoreResult result) + private unsafe void Log(PendingTransaction pendingTransaction, out StoreResult result) { var thisTx = TxId.From(_asOfTxId.Value + 1); @@ -345,9 +336,9 @@ private void Log(PendingTransaction pendingTransaction, out StoreResult result) } var isRemapped = Ids.IsPartition(datom.E.Value, Ids.Partition.Tmp); - datom.Explode(_registry, remapFn, out var e, out var a, _writer, out var isAssert); + datom.Explode(_registry, remapFn, out var e, out var a, _writer, out var isRetract); var keyPrefix = _writer.GetWrittenSpanWritable().CastFast(); - keyPrefix[0].Set(e, a, thisTx, isAssert); + keyPrefix[0].Set(e, a, thisTx, isRetract); var attr = _registry.GetAttribute(a); var isReference = attr.IsReference; @@ -357,8 +348,19 @@ private void Log(PendingTransaction pendingTransaction, out StoreResult result) if (!isRemapped) havePrevious = GetPrevious(keyPrefix[0]); + // Put it in the tx log first + var newSpan = _writer.GetWrittenSpan(); + _txLog.Put(batch, newSpan); + + // Remove the previous if it exists if (havePrevious) { + var prevValSpan = _prevWriter.GetWrittenSpan().SliceFast(sizeof(KeyPrefix)); + var currValSpan = _writer.GetWrittenSpan().SliceFast(sizeof(KeyPrefix)); + + if (!isRetract && prevValSpan.SequenceEqual(currValSpan)) + continue; + // Move the previous to the history index var span = _prevWriter.GetWrittenSpan(); _eavtCurrent.Delete(batch, span); @@ -380,16 +382,30 @@ private void Log(PendingTransaction pendingTransaction, out StoreResult result) } } - var newSpan = _writer.GetWrittenSpan(); - _eavtCurrent.Put(batch, newSpan); - _aevtCurrent.Put(batch, newSpan); - _txLog.Put(batch, newSpan); - if (isReference) - _vaetCurrent.Put(batch, newSpan); + // Add new state + if (!isRetract) + { + _eavtCurrent.Put(batch, newSpan); + _aevtCurrent.Put(batch, newSpan); + + if (isReference) + _vaetCurrent.Put(batch, newSpan); - if (isIndexed) - _avetCurrent.Put(batch, newSpan); + if (isIndexed) + _avetCurrent.Put(batch, newSpan); + } + else + { + _eavtHistory.Put(batch, newSpan); + _aevtHistory.Put(batch, newSpan); + + if (isReference) + _vaetHistory.Put(batch, newSpan); + + if (isIndexed) + _aevtHistory.Put(batch, newSpan); + } } var swWrite = Stopwatch.StartNew(); diff --git a/tests/NexusMods.MneumonicDB.Storage.Tests/ABackendTest.cs b/tests/NexusMods.MneumonicDB.Storage.Tests/ABackendTest.cs index 1aff00b7..f0214bda 100644 --- a/tests/NexusMods.MneumonicDB.Storage.Tests/ABackendTest.cs +++ b/tests/NexusMods.MneumonicDB.Storage.Tests/ABackendTest.cs @@ -3,6 +3,7 @@ using NexusMods.MneumonicDB.TestModel.ComplexModel.Attributes; using NexusMods.MneumonicDB.TestModel.Helpers; using NexusMods.Hashing.xxHash64; +using NexusMods.MneumonicDB.Abstractions.DatomIterators; using NexusMods.Paths; using FileAttributes = NexusMods.MneumonicDB.TestModel.ComplexModel.Attributes.FileAttributes; @@ -55,10 +56,47 @@ public async Task InsertedDatomsShowUpInTheIndex(IndexType type) FileAttributes.ModId.Assert(id1, modId2) ]); - var snapshot = DatomStore.GetSnapshot(); - var results = DatomStore.Datoms(snapshot, type).ToList(); + using var iterator = tx.Snapshot.GetIterator(type); + await Verify(iterator.SeekStart().Resolve().ToTable(Registry)) + .UseDirectory("BackendTestVerifyData") + .UseParameters(type); + } + + [Theory] + [InlineData(IndexType.TxLog)] + [InlineData(IndexType.EAVTHistory)] + [InlineData(IndexType.EAVTCurrent)] + [InlineData(IndexType.AEVTCurrent)] + [InlineData(IndexType.AEVTHistory)] + [InlineData(IndexType.VAETCurrent)] + [InlineData(IndexType.VAETHistory)] + [InlineData(IndexType.AVETCurrent)] + [InlineData(IndexType.AVETHistory)] + public async Task RetractedValuesAreSupported(IndexType type) + { + var id = NextTempId(); + var modId = NextTempId(); + + var tx1 = await DatomStore.Transact([ + FileAttributes.Path.Assert(id, "/foo/bar"), + FileAttributes.Hash.Assert(id, Hash.From(0xDEADBEEF)), + FileAttributes.Size.Assert(id, Size.From(42)), + FileAttributes.ModId.Assert(id, modId), + ]); + + id = tx1.Remaps[id]; + modId = tx1.Remaps[modId]; + + var tx2 = await DatomStore.Transact([ + FileAttributes.Path.Retract(id, "/foo/bar"), + FileAttributes.Hash.Retract(id, Hash.From(0xDEADBEEF)), + FileAttributes.Size.Retract(id, Size.From(42)), + FileAttributes.ModId.Retract(id, modId) + ]); + - await Verify(results.ToTable(Registry)) + using var iterator = tx2.Snapshot.GetIterator(type); + await Verify(iterator.SeekStart().Resolve().ToTable(Registry)) .UseDirectory("BackendTestVerifyData") .UseParameters(type); } diff --git a/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/InMemoryTests.RetractedValuesAreSupported_type=AEVTCurrent.verified.txt b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/InMemoryTests.RetractedValuesAreSupported_type=AEVTCurrent.verified.txt new file mode 100644 index 00000000..6ea7dccc --- /dev/null +++ b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/InMemoryTests.RetractedValuesAreSupported_type=AEVTCurrent.verified.txt @@ -0,0 +1,4 @@ ++ | 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 diff --git a/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/InMemoryTests.RetractedValuesAreSupported_type=AEVTHistory.verified.txt b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/InMemoryTests.RetractedValuesAreSupported_type=AEVTHistory.verified.txt new file mode 100644 index 00000000..8ee3b995 --- /dev/null +++ b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/InMemoryTests.RetractedValuesAreSupported_type=AEVTHistory.verified.txt @@ -0,0 +1,8 @@ ++ | 0200000000000001 | (0014) Path | /foo/bar | 0100000000000002 +- | 0200000000000001 | (0014) Path | /foo/bar | 0100000000000003 ++ | 0200000000000001 | (0015) Hash | 0x00000000DEADBEEF | 0100000000000002 +- | 0200000000000001 | (0015) Hash | 0x00000000DEADBEEF | 0100000000000003 ++ | 0200000000000001 | (0016) Size | 42 B | 0100000000000002 +- | 0200000000000001 | (0016) Size | 42 B | 0100000000000003 ++ | 0200000000000001 | (0017) ModId | 0200000000000002 | 0100000000000002 +- | 0200000000000001 | (0017) ModId | 0200000000000002 | 0100000000000003 diff --git a/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/InMemoryTests.RetractedValuesAreSupported_type=AVETCurrent.verified.txt b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/InMemoryTests.RetractedValuesAreSupported_type=AVETCurrent.verified.txt new file mode 100644 index 00000000..c1b8d743 --- /dev/null +++ b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/InMemoryTests.RetractedValuesAreSupported_type=AVETCurrent.verified.txt @@ -0,0 +1 @@ +emptyString \ No newline at end of file diff --git a/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/InMemoryTests.RetractedValuesAreSupported_type=AVETHistory.verified.txt b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/InMemoryTests.RetractedValuesAreSupported_type=AVETHistory.verified.txt new file mode 100644 index 00000000..2d6a17d3 --- /dev/null +++ b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/InMemoryTests.RetractedValuesAreSupported_type=AVETHistory.verified.txt @@ -0,0 +1,2 @@ ++ | 0200000000000001 | (0014) Path | /foo/bar | 0100000000000002 ++ | 0200000000000001 | (0015) Hash | 0x00000000DEADBEEF | 0100000000000002 diff --git a/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/InMemoryTests.RetractedValuesAreSupported_type=EAVTCurrent.verified.txt b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/InMemoryTests.RetractedValuesAreSupported_type=EAVTCurrent.verified.txt new file mode 100644 index 00000000..ed3ab5ec --- /dev/null +++ b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/InMemoryTests.RetractedValuesAreSupported_type=EAVTCurrent.verified.txt @@ -0,0 +1,4 @@ ++ | 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 diff --git a/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/InMemoryTests.RetractedValuesAreSupported_type=EAVTHistory.verified.txt b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/InMemoryTests.RetractedValuesAreSupported_type=EAVTHistory.verified.txt new file mode 100644 index 00000000..8ee3b995 --- /dev/null +++ b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/InMemoryTests.RetractedValuesAreSupported_type=EAVTHistory.verified.txt @@ -0,0 +1,8 @@ ++ | 0200000000000001 | (0014) Path | /foo/bar | 0100000000000002 +- | 0200000000000001 | (0014) Path | /foo/bar | 0100000000000003 ++ | 0200000000000001 | (0015) Hash | 0x00000000DEADBEEF | 0100000000000002 +- | 0200000000000001 | (0015) Hash | 0x00000000DEADBEEF | 0100000000000003 ++ | 0200000000000001 | (0016) Size | 42 B | 0100000000000002 +- | 0200000000000001 | (0016) Size | 42 B | 0100000000000003 ++ | 0200000000000001 | (0017) ModId | 0200000000000002 | 0100000000000002 +- | 0200000000000001 | (0017) ModId | 0200000000000002 | 0100000000000003 diff --git a/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/InMemoryTests.RetractedValuesAreSupported_type=TxLog.verified.txt b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/InMemoryTests.RetractedValuesAreSupported_type=TxLog.verified.txt new file mode 100644 index 00000000..e0b336d4 --- /dev/null +++ b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/InMemoryTests.RetractedValuesAreSupported_type=TxLog.verified.txt @@ -0,0 +1,12 @@ ++ | 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 ++ | 0200000000000001 | (0017) ModId | 0200000000000002 | 0100000000000002 +- | 0200000000000001 | (0014) Path | /foo/bar | 0100000000000003 +- | 0200000000000001 | (0015) Hash | 0x00000000DEADBEEF | 0100000000000003 +- | 0200000000000001 | (0016) Size | 42 B | 0100000000000003 +- | 0200000000000001 | (0017) ModId | 0200000000000002 | 0100000000000003 diff --git a/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/InMemoryTests.RetractedValuesAreSupported_type=VAETCurrent.verified.txt b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/InMemoryTests.RetractedValuesAreSupported_type=VAETCurrent.verified.txt new file mode 100644 index 00000000..c1b8d743 --- /dev/null +++ b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/InMemoryTests.RetractedValuesAreSupported_type=VAETCurrent.verified.txt @@ -0,0 +1 @@ +emptyString \ No newline at end of file diff --git a/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/InMemoryTests.RetractedValuesAreSupported_type=VAETHistory.verified.txt b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/InMemoryTests.RetractedValuesAreSupported_type=VAETHistory.verified.txt new file mode 100644 index 00000000..acadb847 --- /dev/null +++ b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/InMemoryTests.RetractedValuesAreSupported_type=VAETHistory.verified.txt @@ -0,0 +1,2 @@ ++ | 0200000000000001 | (0017) ModId | 0200000000000002 | 0100000000000002 +- | 0200000000000001 | (0017) ModId | 0200000000000002 | 0100000000000003 diff --git a/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/RocksDB.RetractedValuesAreSupported_type=AEVTCurrent.verified.txt b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/RocksDB.RetractedValuesAreSupported_type=AEVTCurrent.verified.txt new file mode 100644 index 00000000..6ea7dccc --- /dev/null +++ b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/RocksDB.RetractedValuesAreSupported_type=AEVTCurrent.verified.txt @@ -0,0 +1,4 @@ ++ | 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 diff --git a/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/RocksDB.RetractedValuesAreSupported_type=AEVTHistory.verified.txt b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/RocksDB.RetractedValuesAreSupported_type=AEVTHistory.verified.txt new file mode 100644 index 00000000..8ee3b995 --- /dev/null +++ b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/RocksDB.RetractedValuesAreSupported_type=AEVTHistory.verified.txt @@ -0,0 +1,8 @@ ++ | 0200000000000001 | (0014) Path | /foo/bar | 0100000000000002 +- | 0200000000000001 | (0014) Path | /foo/bar | 0100000000000003 ++ | 0200000000000001 | (0015) Hash | 0x00000000DEADBEEF | 0100000000000002 +- | 0200000000000001 | (0015) Hash | 0x00000000DEADBEEF | 0100000000000003 ++ | 0200000000000001 | (0016) Size | 42 B | 0100000000000002 +- | 0200000000000001 | (0016) Size | 42 B | 0100000000000003 ++ | 0200000000000001 | (0017) ModId | 0200000000000002 | 0100000000000002 +- | 0200000000000001 | (0017) ModId | 0200000000000002 | 0100000000000003 diff --git a/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/RocksDB.RetractedValuesAreSupported_type=AVETCurrent.verified.txt b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/RocksDB.RetractedValuesAreSupported_type=AVETCurrent.verified.txt new file mode 100644 index 00000000..c1b8d743 --- /dev/null +++ b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/RocksDB.RetractedValuesAreSupported_type=AVETCurrent.verified.txt @@ -0,0 +1 @@ +emptyString \ No newline at end of file diff --git a/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/RocksDB.RetractedValuesAreSupported_type=AVETHistory.verified.txt b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/RocksDB.RetractedValuesAreSupported_type=AVETHistory.verified.txt new file mode 100644 index 00000000..2d6a17d3 --- /dev/null +++ b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/RocksDB.RetractedValuesAreSupported_type=AVETHistory.verified.txt @@ -0,0 +1,2 @@ ++ | 0200000000000001 | (0014) Path | /foo/bar | 0100000000000002 ++ | 0200000000000001 | (0015) Hash | 0x00000000DEADBEEF | 0100000000000002 diff --git a/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/RocksDB.RetractedValuesAreSupported_type=EAVTCurrent.verified.txt b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/RocksDB.RetractedValuesAreSupported_type=EAVTCurrent.verified.txt new file mode 100644 index 00000000..ed3ab5ec --- /dev/null +++ b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/RocksDB.RetractedValuesAreSupported_type=EAVTCurrent.verified.txt @@ -0,0 +1,4 @@ ++ | 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 diff --git a/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/RocksDB.RetractedValuesAreSupported_type=EAVTHistory.verified.txt b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/RocksDB.RetractedValuesAreSupported_type=EAVTHistory.verified.txt new file mode 100644 index 00000000..8ee3b995 --- /dev/null +++ b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/RocksDB.RetractedValuesAreSupported_type=EAVTHistory.verified.txt @@ -0,0 +1,8 @@ ++ | 0200000000000001 | (0014) Path | /foo/bar | 0100000000000002 +- | 0200000000000001 | (0014) Path | /foo/bar | 0100000000000003 ++ | 0200000000000001 | (0015) Hash | 0x00000000DEADBEEF | 0100000000000002 +- | 0200000000000001 | (0015) Hash | 0x00000000DEADBEEF | 0100000000000003 ++ | 0200000000000001 | (0016) Size | 42 B | 0100000000000002 +- | 0200000000000001 | (0016) Size | 42 B | 0100000000000003 ++ | 0200000000000001 | (0017) ModId | 0200000000000002 | 0100000000000002 +- | 0200000000000001 | (0017) ModId | 0200000000000002 | 0100000000000003 diff --git a/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/RocksDB.RetractedValuesAreSupported_type=TxLog.verified.txt b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/RocksDB.RetractedValuesAreSupported_type=TxLog.verified.txt new file mode 100644 index 00000000..e0b336d4 --- /dev/null +++ b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/RocksDB.RetractedValuesAreSupported_type=TxLog.verified.txt @@ -0,0 +1,12 @@ ++ | 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 ++ | 0200000000000001 | (0017) ModId | 0200000000000002 | 0100000000000002 +- | 0200000000000001 | (0014) Path | /foo/bar | 0100000000000003 +- | 0200000000000001 | (0015) Hash | 0x00000000DEADBEEF | 0100000000000003 +- | 0200000000000001 | (0016) Size | 42 B | 0100000000000003 +- | 0200000000000001 | (0017) ModId | 0200000000000002 | 0100000000000003 diff --git a/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/RocksDB.RetractedValuesAreSupported_type=VAETCurrent.verified.txt b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/RocksDB.RetractedValuesAreSupported_type=VAETCurrent.verified.txt new file mode 100644 index 00000000..c1b8d743 --- /dev/null +++ b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/RocksDB.RetractedValuesAreSupported_type=VAETCurrent.verified.txt @@ -0,0 +1 @@ +emptyString \ No newline at end of file diff --git a/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/RocksDB.RetractedValuesAreSupported_type=VAETHistory.verified.txt b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/RocksDB.RetractedValuesAreSupported_type=VAETHistory.verified.txt new file mode 100644 index 00000000..acadb847 --- /dev/null +++ b/tests/NexusMods.MneumonicDB.Storage.Tests/BackendTestVerifyData/RocksDB.RetractedValuesAreSupported_type=VAETHistory.verified.txt @@ -0,0 +1,2 @@ ++ | 0200000000000001 | (0017) ModId | 0200000000000002 | 0100000000000002 +- | 0200000000000001 | (0017) ModId | 0200000000000002 | 0100000000000003 diff --git a/tests/NexusMods.MneumonicDB.TestModel/Helpers/ExtensionMethods.cs b/tests/NexusMods.MneumonicDB.TestModel/Helpers/ExtensionMethods.cs index 98189527..95397881 100644 --- a/tests/NexusMods.MneumonicDB.TestModel/Helpers/ExtensionMethods.cs +++ b/tests/NexusMods.MneumonicDB.TestModel/Helpers/ExtensionMethods.cs @@ -38,12 +38,12 @@ string TruncateOrPad(string val, int length) var sb = new StringBuilder(); foreach (var datom in datoms) { - var isAssert = true; + var isRetract = datom.IsRetract; var symColumn = TruncateOrPad(registry.GetSymbolForAttribute(datom.AttributeType).Name, 24); var attrId = registry.GetAttributeId(datom.AttributeType).Value.ToString("X4"); - sb.Append(isAssert ? "+" : "-"); + sb.Append(isRetract ? "-" : "+"); sb.Append(" | "); sb.Append(datom.E.Value.ToString("X16")); sb.Append(" | ");