This is an automated email from the ASF dual-hosted git repository.
paulirwin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucenenet.git
The following commit(s) were added to refs/heads/master by this push:
new 78e40ac5e SWEEP: Removed
FEATURE_DICTIONARY_REMOVE_CONTINUEENUMERATION. Updated private fields to use
J2N.Collections.Generic.Dictionary<TKey,TValue> for a performance boost when we
upgrade to J2N 3.x (GetEnumerator() currently boxes from struct to interface).
(fixes #978) (#980)
78e40ac5e is described below
commit 78e40ac5ebba67958652b416cab865540bca3d4b
Author: Shad Storhaug <[email protected]>
AuthorDate: Tue Oct 22 03:22:08 2024 +0700
SWEEP: Removed FEATURE_DICTIONARY_REMOVE_CONTINUEENUMERATION. Updated
private fields to use J2N.Collections.Generic.Dictionary<TKey,TValue> for a
performance boost when we upgrade to J2N 3.x (GetEnumerator() currently boxes
from struct to interface). (fixes #978) (#980)
---
Directory.Build.targets | 1 -
.../Taxonomy/WriterCache/NameIntCacheLRU.cs | 11 +++--------
src/Lucene.Net.TestFramework/Util/Fst/FSTTester.cs | 14 +++++---------
src/Lucene.Net/Index/IndexWriter.cs | 9 ++-------
4 files changed, 10 insertions(+), 25 deletions(-)
diff --git a/Directory.Build.targets b/Directory.Build.targets
index 35988f656..b0bcc3b8c 100644
--- a/Directory.Build.targets
+++ b/Directory.Build.targets
@@ -46,7 +46,6 @@
<PropertyGroup Condition=" $(TargetFramework.StartsWith('netcoreapp3.')) Or
$(TargetFramework.StartsWith('net5.')) Or
$(TargetFramework.StartsWith('net6.')) Or
$(TargetFramework.StartsWith('net7.')) Or
$(TargetFramework.StartsWith('net8.')) ">
<DefineConstants>$(DefineConstants);FEATURE_ARGITERATOR</DefineConstants>
-
<DefineConstants>$(DefineConstants);FEATURE_DICTIONARY_REMOVE_CONTINUEENUMERATION</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_PROCESS_KILL_ENTIREPROCESSTREE</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_STRING_CONCAT_READONLYSPAN</DefineConstants>
diff --git a/src/Lucene.Net.Facet/Taxonomy/WriterCache/NameIntCacheLRU.cs
b/src/Lucene.Net.Facet/Taxonomy/WriterCache/NameIntCacheLRU.cs
index e18927595..ba990dbc4 100644
--- a/src/Lucene.Net.Facet/Taxonomy/WriterCache/NameIntCacheLRU.cs
+++ b/src/Lucene.Net.Facet/Taxonomy/WriterCache/NameIntCacheLRU.cs
@@ -4,6 +4,7 @@ using Lucene.Net.Support.Threading;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
+using JCG = J2N.Collections.Generic;
namespace Lucene.Net.Facet.Taxonomy.WriterCache
{
@@ -162,13 +163,7 @@ namespace Lucene.Net.Facet.Taxonomy.WriterCache
}
else
{
-#if FEATURE_DICTIONARY_REMOVE_CONTINUEENUMERATION
- cache = new Dictionary<TName, int>(capacity: 1000);
-#else
- // LUCENENET specific - we use ConcurrentDictionary here
because it supports deleting while
- // iterating through the collection, but Dictionary does not.
- cache = new ConcurrentDictionary<TName, int>(concurrencyLevel:
3, capacity: 1000); //no need for LRU
-#endif
+ cache = new JCG.Dictionary<TName, int>(capacity: 1000);
}
}
@@ -255,4 +250,4 @@ namespace Lucene.Net.Facet.Taxonomy.WriterCache
return true;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Lucene.Net.TestFramework/Util/Fst/FSTTester.cs
b/src/Lucene.Net.TestFramework/Util/Fst/FSTTester.cs
index 9b4decc83..e173c6f72 100644
--- a/src/Lucene.Net.TestFramework/Util/Fst/FSTTester.cs
+++ b/src/Lucene.Net.TestFramework/Util/Fst/FSTTester.cs
@@ -833,13 +833,9 @@ namespace Lucene.Net.Util.Fst
// build all prefixes
-#if FEATURE_DICTIONARY_REMOVE_CONTINUEENUMERATION
- IDictionary<Int32sRef, CountMinOutput<T>> prefixes = new
Dictionary<Int32sRef, CountMinOutput<T>>();
-#else
- // LUCENENET: We use ConcurrentDictionary<TKey, TValue> because
Dictionary<TKey, TValue> doesn't support
- // deletion while iterating, but ConcurrentDictionary does.
- IDictionary<Int32sRef, CountMinOutput<T>> prefixes = new
ConcurrentDictionary<Int32sRef, CountMinOutput<T>>();
-#endif
+ // LUCENENET specific - using concrete type for the readerMap
field, since it will eliminate boxing to an interface on GetEnumerator() calls
+ JCG.Dictionary<Int32sRef, CountMinOutput<T>> prefixes = new
JCG.Dictionary<Int32sRef, CountMinOutput<T>>();
+
Int32sRef scratch = new Int32sRef(10);
foreach (InputOutput<T> pair in pairs)
{
@@ -927,7 +923,7 @@ namespace Lucene.Net.Util.Fst
if (!keep)
{
//it.remove();
- prefixes.Remove(ent);
+ prefixes.Remove(prefix);
//System.out.println(" remove");
}
else
@@ -1028,4 +1024,4 @@ namespace Lucene.Net.Util.Fst
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Lucene.Net/Index/IndexWriter.cs
b/src/Lucene.Net/Index/IndexWriter.cs
index 23c93846e..829c7fcd5 100644
--- a/src/Lucene.Net/Index/IndexWriter.cs
+++ b/src/Lucene.Net/Index/IndexWriter.cs
@@ -471,13 +471,8 @@ namespace Lucene.Net.Index
this.outerInstance = outerInstance;
}
-#if FEATURE_DICTIONARY_REMOVE_CONTINUEENUMERATION
- private readonly IDictionary<SegmentCommitInfo, ReadersAndUpdates>
readerMap = new Dictionary<SegmentCommitInfo, ReadersAndUpdates>();
-#else
- // LUCENENET: We use ConcurrentDictionary<TKey, TValue> because
Dictionary<TKey, TValue> doesn't support
- // deletion while iterating, but ConcurrentDictionary does.
- private readonly IDictionary<SegmentCommitInfo, ReadersAndUpdates>
readerMap = new ConcurrentDictionary<SegmentCommitInfo, ReadersAndUpdates>();
-#endif
+ // LUCENENET specific - using concrete type for the readerMap
field, since it will eliminate boxing to an interface on GetEnumerator() calls
+ private readonly JCG.Dictionary<SegmentCommitInfo,
ReadersAndUpdates> readerMap = new JCG.Dictionary<SegmentCommitInfo,
ReadersAndUpdates>();
// used only by asserts
public virtual bool InfoIsLive(SegmentCommitInfo info)