diff --git a/src/ZoneTree.UnitTests/AtomicUpdateTests.cs b/src/ZoneTree.UnitTests/AtomicUpdateTests.cs index c664c83..39147fd 100644 --- a/src/ZoneTree.UnitTests/AtomicUpdateTests.cs +++ b/src/ZoneTree.UnitTests/AtomicUpdateTests.cs @@ -74,7 +74,7 @@ public void IntIntAtomicIncrement(WriteAheadLogMode walMode) data.Maintenance.StartMergeOperation().Join(); data.TryGet(counterKey, out var finalValue); Assert.That(finalValue, Is.EqualTo(off)); - data.Maintenance.DestroyTree(); + data.Maintenance.Drop(); } [TestCase(WriteAheadLogMode.Sync)] @@ -140,7 +140,7 @@ public void IntIntAtomicIncrementForBTree(WriteAheadLogMode walMode) data.TryGet(3999, out var finalValue); Assert.That(finalValue, Is.EqualTo(off)); - data.Maintenance.DestroyTree(); + data.Maintenance.Drop(); } [TestCase(WriteAheadLogMode.Sync)] @@ -206,7 +206,7 @@ public void IntIntMutableSegmentOnlyAtomicIncrement(WriteAheadLogMode walMode) data.TryGet(counterKey, out var finalValue); Assert.That(finalValue, Is.EqualTo(off)); - data.Maintenance.DestroyTree(); + data.Maintenance.Drop(); } [TestCase(WriteAheadLogMode.Sync)] @@ -255,6 +255,6 @@ public void IntIntMutableSegmentSeveralUpserts(WriteAheadLogMode walMode) }); } - data.Maintenance.DestroyTree(); + data.Maintenance.Drop(); } } \ No newline at end of file diff --git a/src/ZoneTree.UnitTests/BottomSegmentMergeTests.cs b/src/ZoneTree.UnitTests/BottomSegmentMergeTests.cs index 863fc51..bec8062 100644 --- a/src/ZoneTree.UnitTests/BottomSegmentMergeTests.cs +++ b/src/ZoneTree.UnitTests/BottomSegmentMergeTests.cs @@ -64,7 +64,7 @@ public void IntIntBottomMerge() lens = m.BottomSegments.Select(x => x.Length).ToArray(); Assert.That(lens, Is.EqualTo(expected2)); - zoneTree.Maintenance.DestroyTree(); + zoneTree.Maintenance.Drop(); zoneTree.Dispose(); } } \ No newline at end of file diff --git a/src/ZoneTree.UnitTests/CountTests.cs b/src/ZoneTree.UnitTests/CountTests.cs index 2f19480..c44dcb2 100644 --- a/src/ZoneTree.UnitTests/CountTests.cs +++ b/src/ZoneTree.UnitTests/CountTests.cs @@ -62,7 +62,7 @@ public void CountRecordsDuringAMerge( mergeThread?.Join(); isMergeFinished = true; task.Wait(); - zoneTree.Maintenance.DestroyTree(); + zoneTree.Maintenance.Drop(); Assert.That(failedCount, Is.EqualTo(0)); } diff --git a/src/ZoneTree.UnitTests/ExceptionlessTransactionTests.cs b/src/ZoneTree.UnitTests/ExceptionlessTransactionTests.cs index 05d86d9..133eeaa 100644 --- a/src/ZoneTree.UnitTests/ExceptionlessTransactionTests.cs +++ b/src/ZoneTree.UnitTests/ExceptionlessTransactionTests.cs @@ -52,7 +52,7 @@ public void TransactionWithNoThrowAPI(int compactionThreshold) Assert.Throws(() => zoneTree.CommitNoThrow(tx1)); - zoneTree.Maintenance.DestroyTree(); + zoneTree.Maintenance.Drop(); } [TestCase(0)] @@ -106,6 +106,6 @@ await Parallel.ForEachAsync(Enumerable.Range(0, 1000), async (x, cancel) => Console.WriteLine("pending:" + transaction.TotalPendingTransactionsRetried); }); - zoneTree.Maintenance.DestroyTree(); + zoneTree.Maintenance.Drop(); } } \ No newline at end of file diff --git a/src/ZoneTree.UnitTests/FixedSizeKeyAndValueTests.cs b/src/ZoneTree.UnitTests/FixedSizeKeyAndValueTests.cs index 84aac46..4c54a06 100644 --- a/src/ZoneTree.UnitTests/FixedSizeKeyAndValueTests.cs +++ b/src/ZoneTree.UnitTests/FixedSizeKeyAndValueTests.cs @@ -31,7 +31,7 @@ public void IntIntTreeTest() Assert.That(v, Is.EqualTo(i + i)); Assert.That(data.ContainsKey(i), Is.True); } - data.Maintenance.DestroyTree(); + data.Maintenance.Drop(); } [Test] @@ -62,7 +62,7 @@ public void IntStringTreeTest() Assert.That(data.ContainsKey(i), Is.True); } Assert.That(data.TryGet(n + 1, out var _), Is.False); - data.Maintenance.DestroyTree(); + data.Maintenance.Drop(); } [Test] @@ -266,7 +266,7 @@ public void StringIntTreeTest(bool useSparseArray) Assert.That(data.ContainsKey(i.ToString()), Is.True); } Assert.That(data.TryGet(n + 1.ToString(), out var _), Is.False); - data.Maintenance.DestroyTree(); + data.Maintenance.Drop(); } [TestCase(true)] @@ -301,7 +301,7 @@ public void StringStringTreeTest(bool useSparseArray) Assert.That(data.ContainsKey(i.ToString()), Is.True); } Assert.That(data.TryGet(n + 1.ToString(), out var _), Is.False); - data.Maintenance.DestroyTree(); + data.Maintenance.Drop(); } static void ReloadIntIntTreeTestHelper(string dataPath, bool destroy) @@ -342,7 +342,7 @@ static void ReloadIntIntTreeTestHelper(string dataPath, bool destroy) } Assert.That(data.Count(), Is.EqualTo(n - deleted.Count)); if (destroy) - data.Maintenance.DestroyTree(); + data.Maintenance.Drop(); } [Test] public void ReloadIntIntTreeTest() diff --git a/src/ZoneTree.UnitTests/IteratorTests.cs b/src/ZoneTree.UnitTests/IteratorTests.cs index f6c2b11..b741f29 100644 --- a/src/ZoneTree.UnitTests/IteratorTests.cs +++ b/src/ZoneTree.UnitTests/IteratorTests.cs @@ -75,7 +75,7 @@ public void IntIntIterator() zoneTree.Maintenance.SaveMetaData(); iterator.Dispose(); reverseIterator.Dispose(); - zoneTree.Maintenance.DestroyTree(); + zoneTree.Maintenance.Drop(); } [Test] @@ -166,7 +166,7 @@ public void IntIntIteratorSeek() zoneTree.Maintenance.SaveMetaData(); iterator.Dispose(); reverseIterator.Dispose(); - zoneTree.Maintenance.DestroyTree(); + zoneTree.Maintenance.Drop(); } [Test] @@ -230,7 +230,7 @@ public void IntIntIteratorReflectNewInserts() Assert.That(zoneTree.Count(), Is.EqualTo(b / 2 - 2)); zoneTree.Maintenance.SaveMetaData(); iterator.Dispose(); - zoneTree.Maintenance.DestroyTree(); + zoneTree.Maintenance.Drop(); } [Test] @@ -278,7 +278,7 @@ public void IntIntIteratorParallelInserts() }); task.Wait(); - zoneTree.Maintenance.DestroyTree(); + zoneTree.Maintenance.Drop(); } [TestCase(true)] @@ -342,7 +342,7 @@ public void IntIntReverseIteratorParallelInserts(bool reverse) }); task.Wait(); - zoneTree.Maintenance.DestroyTree(); + zoneTree.Maintenance.Drop(); } [Test] @@ -389,7 +389,7 @@ public void IntIntSnapshotIteratorParallelInserts() }); task.Wait(); - zoneTree.Maintenance.DestroyTree(); + zoneTree.Maintenance.Drop(); } [Test] @@ -431,7 +431,7 @@ public void ReversePrefixSearch() Assert.That(reverseIterator.Next(), Is.False); Assert.That(zoneTree.Count(), Is.EqualTo(b - a + 1)); - zoneTree.Maintenance.DestroyTree(); + zoneTree.Maintenance.Drop(); } [Test] @@ -473,7 +473,7 @@ public void PrefixSearch() Assert.That(iterator.Next(), Is.False); Assert.That(zoneTree.Count(), Is.EqualTo(b - a + 1)); - zoneTree.Maintenance.DestroyTree(); + zoneTree.Maintenance.Drop(); } [TestCase(true, DiskSegmentMode.SingleDiskSegment, 0, 0)] @@ -516,7 +516,7 @@ public void SeekIteratorsAfterMerge( DoPrefixSearch(zoneTree, list, random); zoneTree.Maintenance.DiskSegment.InitSparseArray(100); DoPrefixSearch(zoneTree, list, random); - zoneTree.Maintenance.DestroyTree(); + zoneTree.Maintenance.Drop(); } static List> PrepareData1(IZoneTree zoneTree, int n) diff --git a/src/ZoneTree.UnitTests/MergeEmptySegmentsTest.cs b/src/ZoneTree.UnitTests/MergeEmptySegmentsTest.cs index 08f5282..6c539d8 100644 --- a/src/ZoneTree.UnitTests/MergeEmptySegmentsTest.cs +++ b/src/ZoneTree.UnitTests/MergeEmptySegmentsTest.cs @@ -48,7 +48,7 @@ public void MergeEmptySegments( } zoneTree.Maintenance.SaveMetaData(); - zoneTree.Maintenance.DestroyTree(); + zoneTree.Maintenance.Drop(); } [TestCase(DiskSegmentMode.SingleDiskSegment, 33, 77)] @@ -108,7 +108,7 @@ public void MergeDeletedSegments( } zoneTree.Maintenance.SaveMetaData(); - zoneTree.Maintenance.DestroyTree(); + zoneTree.Maintenance.Drop(); } [TestCase(DiskSegmentMode.SingleDiskSegment, 33, 77)] @@ -173,6 +173,6 @@ public void MergeDeletedBottomSegments( Assert.That(hasRecord, Is.False); } zoneTree.Maintenance.SaveMetaData(); - zoneTree.Maintenance.DestroyTree(); + zoneTree.Maintenance.Drop(); } } \ No newline at end of file diff --git a/src/ZoneTree.UnitTests/OptimisticTransactionTests.cs b/src/ZoneTree.UnitTests/OptimisticTransactionTests.cs index 79b877a..0828c03 100644 --- a/src/ZoneTree.UnitTests/OptimisticTransactionTests.cs +++ b/src/ZoneTree.UnitTests/OptimisticTransactionTests.cs @@ -52,7 +52,7 @@ public void FirstTransaction(int compactionThreshold) Assert.Throws(() => zoneTree.Commit(tx1)); - zoneTree.Maintenance.DestroyTree(); + zoneTree.Maintenance.Drop(); } [TestCase(WriteAheadLogMode.Sync)] @@ -80,7 +80,7 @@ public void SeveralParallelTransactions(WriteAheadLogMode walMode) zoneTree.Commit(tx); }); - zoneTree.Maintenance.DestroyTree(); + zoneTree.Maintenance.Drop(); } [TestCase(WriteAheadLogMode.Sync)] @@ -105,7 +105,7 @@ public void SeveralParallelUpserts(WriteAheadLogMode walMode) zoneTree.Upsert(-x, -x - x); }); - zoneTree.Maintenance.DestroyTree(); + zoneTree.Maintenance.Drop(); } [TestCase(0)] @@ -158,7 +158,7 @@ public void ReadCommittedTest(int compactionThreshold) Assert.That(zoneTree.ReadCommittedContainsKey(7), Is.False); Assert.That(zoneTree.ReadCommittedTryGet(7, out var _), Is.False); - zoneTree.Maintenance.DestroyTree(); + zoneTree.Maintenance.Drop(); } [TestCase(0)] @@ -205,7 +205,7 @@ public void TransactionLogCompactionTest(int compactionThreshold) Assert.That(v6, Is.EqualTo(14)); zoneTree.Rollback(tx3); - zoneTree.Maintenance.DestroyTree(); + zoneTree.Maintenance.Drop(); } [TestCase(0)] @@ -240,7 +240,7 @@ public void TransactionLogCompactionWithSkipWriteRule(int compactionThreshold) Assert.That(zoneTree.ReadCommittedTryGet(5, out var v5), Is.True); Assert.That(v5, Is.EqualTo(12)); - zoneTree.Maintenance.DestroyTree(); + zoneTree.Maintenance.Drop(); } [TestCase(0)] @@ -276,6 +276,6 @@ public void TransactionIsolationTest(int compactionThreshold) // tx2 depends on tx1 bcs of read of key 9. tx1 aborted and so tx2. Assert.That(zoneTree.PrepareAndCommitNoThrow(tx2).IsAborted, Is.True); - zoneTree.Maintenance.DestroyTree(); + zoneTree.Maintenance.Drop(); } } diff --git a/src/ZoneTree.UnitTests/StringTreeTests.cs b/src/ZoneTree.UnitTests/StringTreeTests.cs index 34a8e22..0a8a505 100644 --- a/src/ZoneTree.UnitTests/StringTreeTests.cs +++ b/src/ZoneTree.UnitTests/StringTreeTests.cs @@ -54,7 +54,7 @@ public void NullStringKeyTest() Assert.That(iterator2.CurrentValue, Is.EqualTo(values[j])); ++j; } - zoneTree.Maintenance.DestroyTree(); + zoneTree.Maintenance.Drop(); } [Test] diff --git a/src/ZoneTree.UnitTests/TTLTests.cs b/src/ZoneTree.UnitTests/TTLTests.cs index 88cfc3a..4627092 100644 --- a/src/ZoneTree.UnitTests/TTLTests.cs +++ b/src/ZoneTree.UnitTests/TTLTests.cs @@ -46,6 +46,6 @@ public void TestTTL() Assert.That(f1, Is.True); Assert.That(f2, Is.False); - zoneTree.Maintenance.DestroyTree(); + zoneTree.Maintenance.Drop(); } } diff --git a/src/ZoneTree/Core/TypeExtensions.cs b/src/ZoneTree/Core/TypeExtensions.cs new file mode 100644 index 0000000..337e33c --- /dev/null +++ b/src/ZoneTree/Core/TypeExtensions.cs @@ -0,0 +1,37 @@ +using System.Text; + +namespace Tenray.ZoneTree.Core; + +public static class TypeExtensions +{ + public static string SimplifiedFullName(this Type type) + { + if (!type.IsGenericType) + return type.FullName; + var builder = new StringBuilder(); + var typeName = type.Namespace + "." + type.Name; + int index = typeName.IndexOf('`'); + if (index > 0) + { + builder.Append(typeName.Substring(0, index)); + } + else + { + builder.Append(typeName); + } + + builder.Append("<"); + var genericArguments = type.GetGenericArguments(); + var len = genericArguments.Length; + for (var i = 0; i < len; i++) + { + if (i > 0) + { + builder.Append(", "); + } + builder.Append(genericArguments[i].SimplifiedFullName()); + } + builder.Append(">"); + return builder.ToString(); + } +} \ No newline at end of file diff --git a/src/ZoneTree/Core/ZoneTree.cs b/src/ZoneTree/Core/ZoneTree.cs index f04d788..2921e93 100644 --- a/src/ZoneTree/Core/ZoneTree.cs +++ b/src/ZoneTree/Core/ZoneTree.cs @@ -185,11 +185,11 @@ void FillZoneTreeMeta() { if (MutableSegment != null) ZoneTreeMeta.MutableSegment = MutableSegment.SegmentId; - ZoneTreeMeta.ComparerType = Options.Comparer.GetType().FullName; - ZoneTreeMeta.KeyType = typeof(TKey).FullName; - ZoneTreeMeta.ValueType = typeof(TValue).FullName; - ZoneTreeMeta.KeySerializerType = Options.KeySerializer.GetType().FullName; - ZoneTreeMeta.ValueSerializerType = Options.ValueSerializer.GetType().FullName; + ZoneTreeMeta.ComparerType = Options.Comparer.GetType().SimplifiedFullName(); + ZoneTreeMeta.KeyType = typeof(TKey).SimplifiedFullName(); + ZoneTreeMeta.ValueType = typeof(TValue).SimplifiedFullName(); + ZoneTreeMeta.KeySerializerType = Options.KeySerializer.GetType().SimplifiedFullName(); + ZoneTreeMeta.ValueSerializerType = Options.ValueSerializer.GetType().SimplifiedFullName(); ZoneTreeMeta.DiskSegment = DiskSegment.SegmentId; ZoneTreeMeta.ReadOnlySegments = ReadOnlySegmentQueue.Select(x => x.SegmentId).ToArray(); ZoneTreeMeta.BottomSegments = BottomSegmentQueue.Select(x => x.SegmentId).ToArray(); @@ -264,7 +264,7 @@ public void Dispose() bs.ReleaseResources(); } - public void DestroyTree() + public void Drop() { MetaWal.Dispose(); MutableSegment.Drop(); diff --git a/src/ZoneTree/Core/ZoneTreeLoader.cs b/src/ZoneTree/Core/ZoneTreeLoader.cs index 97985c6..5006303 100644 --- a/src/ZoneTree/Core/ZoneTreeLoader.cs +++ b/src/ZoneTree/Core/ZoneTreeLoader.cs @@ -1,4 +1,5 @@ using System.Collections.Concurrent; +using System.Text; using Tenray.ZoneTree.Exceptions; using Tenray.ZoneTree.Options; using Tenray.ZoneTree.Segments; @@ -54,30 +55,30 @@ void ValidateZoneTreeMeta() Version.Parse(version), ZoneTreeInfo.ProductVersion); - if (!string.Equals(ZoneTreeMeta.KeyType, typeof(TKey).FullName, StringComparison.Ordinal)) + if (!string.Equals(ZoneTreeMeta.KeyType, typeof(TKey).SimplifiedFullName(), StringComparison.Ordinal)) throw new TreeKeyTypeMismatchException( ZoneTreeMeta.KeyType, - typeof(TKey).FullName); + typeof(TKey).SimplifiedFullName()); - if (!string.Equals(ZoneTreeMeta.ValueType, typeof(TValue).FullName, StringComparison.Ordinal)) + if (!string.Equals(ZoneTreeMeta.ValueType, typeof(TValue).SimplifiedFullName(), StringComparison.Ordinal)) throw new TreeValueTypeMismatchException( ZoneTreeMeta.ValueType, - typeof(TValue).FullName); + typeof(TValue).SimplifiedFullName()); - if (!string.Equals(ZoneTreeMeta.ComparerType, Options.Comparer.GetType().FullName, StringComparison.Ordinal)) + if (!string.Equals(ZoneTreeMeta.ComparerType, Options.Comparer.GetType().SimplifiedFullName(), StringComparison.Ordinal)) throw new TreeComparerMismatchException( ZoneTreeMeta.ComparerType, - Options.Comparer.GetType().FullName); + Options.Comparer.GetType().SimplifiedFullName()); - if (!string.Equals(ZoneTreeMeta.KeySerializerType, Options.KeySerializer.GetType().FullName, StringComparison.Ordinal)) + if (!string.Equals(ZoneTreeMeta.KeySerializerType, Options.KeySerializer.GetType().SimplifiedFullName(), StringComparison.Ordinal)) throw new TreeKeySerializerTypeMismatchException( ZoneTreeMeta.KeySerializerType, - Options.KeySerializer.GetType().FullName); + Options.KeySerializer.GetType().SimplifiedFullName()); - if (!string.Equals(ZoneTreeMeta.ValueSerializerType, Options.ValueSerializer.GetType().FullName, StringComparison.Ordinal)) + if (!string.Equals(ZoneTreeMeta.ValueSerializerType, Options.ValueSerializer.GetType().SimplifiedFullName(), StringComparison.Ordinal)) throw new TreeValueSerializerTypeMismatchException( ZoneTreeMeta.ValueSerializerType, - Options.ValueSerializer.GetType().FullName); + Options.ValueSerializer.GetType().SimplifiedFullName()); } void LoadZoneTreeMetaWAL() @@ -267,4 +268,4 @@ public ZoneTree LoadZoneTree() ReadOnlySegments, MutableSegment, DiskSegment, BottomSegments, maximumSegmentId); return zoneTree; } -} \ No newline at end of file +} diff --git a/src/ZoneTree/Directory.Build.props b/src/ZoneTree/Directory.Build.props index 8567e00..e24b4a7 100644 --- a/src/ZoneTree/Directory.Build.props +++ b/src/ZoneTree/Directory.Build.props @@ -5,8 +5,8 @@ Ahmed Yasin Koculu ZoneTree ZoneTree - 1.7.6.0 - 1.7.6.0 + 1.7.8.0 + 1.7.8.0 Ahmed Yasin Koculu ZoneTree ZoneTree is a persistent, high-performance, transactional, ACID-compliant ordered key-value database for NET. It can operate in memory or on local/cloud storage. diff --git a/src/ZoneTree/ITransactionalZoneTreeMaintenance.cs b/src/ZoneTree/ITransactionalZoneTreeMaintenance.cs index 2ccd3fd..278821b 100644 --- a/src/ZoneTree/ITransactionalZoneTreeMaintenance.cs +++ b/src/ZoneTree/ITransactionalZoneTreeMaintenance.cs @@ -42,7 +42,7 @@ public interface ITransactionalZoneTreeMaintenance /// Removes the transactional tree from the universe. /// Destroys the tree, transaction logs, entire data and WAL store or folder. /// - void DestroyTree(); + void Drop(); /// /// Rollbacks all uncommitted transactions. diff --git a/src/ZoneTree/IZoneTreeMaintenance.cs b/src/ZoneTree/IZoneTreeMaintenance.cs index e6a67b6..04458a2 100644 --- a/src/ZoneTree/IZoneTreeMaintenance.cs +++ b/src/ZoneTree/IZoneTreeMaintenance.cs @@ -141,7 +141,7 @@ public interface IZoneTreeMaintenance /// /// Destroys the tree, deletes entire data and WAL store or folder. /// - void DestroyTree(); + void Drop(); /// /// Event is fired when mutable segment is moved forward. diff --git a/src/ZoneTree/Transactional/OptimisticZoneTree.cs b/src/ZoneTree/Transactional/OptimisticZoneTree.cs index 96126c5..f13a4ab 100644 --- a/src/ZoneTree/Transactional/OptimisticZoneTree.cs +++ b/src/ZoneTree/Transactional/OptimisticZoneTree.cs @@ -255,10 +255,10 @@ public void Delete(long transactionId, in TKey key) throw new TransactionAbortedException(transactionId); } - public void DestroyTree() + public void Drop() { TransactionLog.Dispose(); - ZoneTree.Maintenance.DestroyTree(); + ZoneTree.Maintenance.Drop(); } public void SaveMetaData()