Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed FEATURE_DICTIONARY_REMOVE_CONTINUEENUMERATION from the codebase #980

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
11 changes: 3 additions & 8 deletions src/Lucene.Net.Facet/Taxonomy/WriterCache/NameIntCacheLRU.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using JCG = J2N.Collections.Generic;

namespace Lucene.Net.Facet.Taxonomy.WriterCache
{
Expand Down Expand Up @@ -162,13 +163,7 @@ private void CreateCache(int maxSize)
}
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);
}
}

Expand Down Expand Up @@ -255,4 +250,4 @@ bool IInternalNameInt32CacheLru.MakeRoomLRU()
return true;
}
}
}
}
14 changes: 5 additions & 9 deletions src/Lucene.Net.TestFramework/Util/Fst/FSTTester.cs
Original file line number Diff line number Diff line change
Expand Up @@ -833,13 +833,9 @@ private void VerifyPruned(int inputMode, FST<T> fst, int prune1, int prune2)

// 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)
{
Expand Down Expand Up @@ -927,7 +923,7 @@ private void VerifyPruned(int inputMode, FST<T> fst, int prune1, int prune2)
if (!keep)
{
//it.remove();
prefixes.Remove(ent);
prefixes.Remove(prefix);
//System.out.println(" remove");
}
else
Expand Down Expand Up @@ -1028,4 +1024,4 @@ private void VerifyPruned(int inputMode, FST<T> fst, int prune1, int prune2)
}
}
}
}
}
9 changes: 2 additions & 7 deletions src/Lucene.Net/Index/IndexWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -471,13 +471,8 @@ public ReaderPool(IndexWriter outerInstance)
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)
Expand Down
Loading