-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #94 from koculu/93-enhancement-provide-operation-i…
…ndex-to-support-asynchronous-replication-and-audits Added operation index to support asynchronous replication and audits
- Loading branch information
Showing
17 changed files
with
212 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System.Collections.Concurrent; | ||
using Tenray.ZoneTree.PresetTypes; | ||
using Tenray.ZoneTree.Serializers; | ||
|
||
namespace Tenray.ZoneTree.UnitTests; | ||
|
||
public sealed class OpIndexTests | ||
{ | ||
[Test] | ||
public void TestOpIndex() | ||
{ | ||
var dataPath = "data/TestOpIndex"; | ||
if (Directory.Exists(dataPath)) | ||
Directory.Delete(dataPath, true); | ||
var recordCount = 10_000; | ||
var opIndexes = new ConcurrentBag<long>(); | ||
void CreateData() | ||
{ | ||
using var zoneTree = new ZoneTreeFactory<int, int>() | ||
.SetDataDirectory(dataPath) | ||
.SetMutableSegmentMaxItemCount(100) | ||
.OpenOrCreate(); | ||
|
||
using var maintainer = zoneTree.CreateMaintainer(); | ||
Parallel.For(0, recordCount, (i) => | ||
{ | ||
var opIndex = zoneTree.Upsert(i, i); | ||
opIndexes.Add(opIndex); | ||
}); | ||
maintainer.EvictToDisk(); | ||
maintainer.WaitForBackgroundThreads(); | ||
} | ||
|
||
void ReloadData() | ||
{ | ||
using var zoneTree = new ZoneTreeFactory<int, int>() | ||
.SetDataDirectory(dataPath) | ||
.SetMutableSegmentMaxItemCount(100) | ||
.Open(); | ||
|
||
var opIndex = zoneTree.Upsert(recordCount + 1, recordCount + 1); | ||
Assert.That(opIndex, Is.EqualTo(recordCount + 1)); | ||
zoneTree.Maintenance.Drop(); | ||
} | ||
CreateData(); | ||
ReloadData(); | ||
Assert.IsTrue( | ||
opIndexes.Order().ToArray() | ||
.SequenceEqual(Enumerable.Range(1, recordCount).Select(x => (long)x))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.