From 99199b1fed1ecbc63ebc67469f46d02c1dc32b9e Mon Sep 17 00:00:00 2001 From: Ahmed Yasin Koculu Date: Wed, 16 Oct 2024 06:41:09 +0200 Subject: [PATCH] Assign opIndex only if needed. --- src/ZoneTree/Segments/InMemory/MutableSegment.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ZoneTree/Segments/InMemory/MutableSegment.cs b/src/ZoneTree/Segments/InMemory/MutableSegment.cs index fb134ef..1e80d9b 100644 --- a/src/ZoneTree/Segments/InMemory/MutableSegment.cs +++ b/src/ZoneTree/Segments/InMemory/MutableSegment.cs @@ -207,12 +207,18 @@ public AddOrUpdateResult Delete(in TKey key, out long opIndex) try { Interlocked.Increment(ref WritesInProgress); - opIndex = 0; + if (IsFrozenFlag) + { + opIndex = 0; return AddOrUpdateResult.RETRY_SEGMENT_IS_FROZEN; + } if (BTree.Length >= MutableSegmentMaxItemCount) + { + opIndex = 0; return AddOrUpdateResult.RETRY_SEGMENT_IS_FULL; + } TValue insertedValue = default;