From 765f8b8f32e4c7ea5cdeee82db3756510d3632c8 Mon Sep 17 00:00:00 2001 From: Ahmed Yasin Koculu Date: Sat, 17 Jun 2023 01:33:49 +0200 Subject: [PATCH] Add B+Tree Node and Leaf size fine tuning options. --- src/ZoneTree/Options/ZoneTreeOptions.cs | 10 ++++++++++ src/ZoneTree/Segments/InMemory/MutableSegment.cs | 11 +++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/ZoneTree/Options/ZoneTreeOptions.cs b/src/ZoneTree/Options/ZoneTreeOptions.cs index f2c3ba8..3c01ad2 100644 --- a/src/ZoneTree/Options/ZoneTreeOptions.cs +++ b/src/ZoneTree/Options/ZoneTreeOptions.cs @@ -99,6 +99,16 @@ public sealed class ZoneTreeOptions /// public BTreeLockMode BTreeLockMode { get; set; } = BTreeLockMode.NodeLevelMonitor; + /// + /// The B+Tree node size. + /// + public int BTreeNodeSize { get; set; } = 128; + + /// + /// The B+Tree leaf size. + /// + public int BTreeLeafSize { get; set; } = 128; + /// /// ZoneTree Logger. /// diff --git a/src/ZoneTree/Segments/InMemory/MutableSegment.cs b/src/ZoneTree/Segments/InMemory/MutableSegment.cs index 88270b7..1818181 100644 --- a/src/ZoneTree/Segments/InMemory/MutableSegment.cs +++ b/src/ZoneTree/Segments/InMemory/MutableSegment.cs @@ -54,7 +54,9 @@ public sealed class MutableSegment : IMutableSegment BTree = new(Comparer, Options.BTreeLockMode, - indexOpProvider); + indexOpProvider, + Options.BTreeNodeSize, + Options.BTreeLeafSize); MarkValueDeleted = options.MarkValueDeleted; MutableSegmentMaxItemCount = options.MutableSegmentMaxItemCount; @@ -73,7 +75,12 @@ public sealed class MutableSegment : IMutableSegment Options = options; Comparer = options.Comparer; - BTree = new(Comparer, Options.BTreeLockMode); + BTree = new( + Comparer, + Options.BTreeLockMode, + null, + Options.BTreeNodeSize, + Options.BTreeLeafSize); BTree.SetNextOpIndex(nextOpIndex); MarkValueDeleted = options.MarkValueDeleted;