You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by la...@apache.org on 2023/04/11 03:27:07 UTC
[lucenenet] branch master updated: BREAKING: remove virtual call from the constructor for IndexSearcher (#818)
This is an automated email from the ASF dual-hosted git repository.
laimis 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 fb8265a71 BREAKING: remove virtual call from the constructor for IndexSearcher (#818)
fb8265a71 is described below
commit fb8265a7162d8c1e75b8646cb0b3d66f1db75718
Author: Laimonas Simutis <la...@gmail.com>
AuthorDate: Mon Apr 10 20:27:00 2023 -0700
BREAKING: remove virtual call from the constructor for IndexSearcher (#818)
* remove virtual call from the constructor
---
src/Lucene.Net/Search/IndexSearcher.cs | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/src/Lucene.Net/Search/IndexSearcher.cs b/src/Lucene.Net/Search/IndexSearcher.cs
index f00a2d3ff..211029752 100644
--- a/src/Lucene.Net/Search/IndexSearcher.cs
+++ b/src/Lucene.Net/Search/IndexSearcher.cs
@@ -141,7 +141,7 @@ namespace Lucene.Net.Search
this.executor = executor;
this.m_readerContext = context;
m_leafContexts = context.Leaves;
- this.m_leafSlices = executor is null ? null : Slices(m_leafContexts);
+ this.m_leafSlices = executor is null ? null : GetSlicesInternal(m_leafContexts);
}
/// <summary>
@@ -160,8 +160,18 @@ namespace Lucene.Net.Search
/// Expert: Creates an array of leaf slices each holding a subset of the given leaves.
/// Each <see cref="LeafSlice"/> is executed in a single thread. By default there
/// will be one <see cref="LeafSlice"/> per leaf (<see cref="AtomicReaderContext"/>).
+ ///
+ /// NOTE: When overriding this method, be aware that the constructor of this class calls
+ /// a private method and not this virtual method. So if you need to override
+ /// the behavior during the initialization, call your own private method from the constructor
+ /// with whatever custom behavior you need.
/// </summary>
- protected virtual LeafSlice[] Slices(IList<AtomicReaderContext> leaves)
+ // LUCENENET specific - renamed to GetSlices to better indicate the purpose of this method
+ protected virtual LeafSlice[] GetSlices(IList<AtomicReaderContext> leaves)
+ => GetSlicesInternal(leaves);
+
+ // LUCENENET specific - creating this so that we can call it from the constructor
+ protected LeafSlice[] GetSlicesInternal(IList<AtomicReaderContext> leaves)
{
LeafSlice[] slices = new LeafSlice[leaves.Count];
for (int i = 0; i < slices.Length; i++)