You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ja...@apache.org on 2023/10/26 10:37:17 UTC
[lucene] branch branch_9x updated: Make IndexSearcher#getSlices final and clarify docs (#12718)
This is an automated email from the ASF dual-hosted git repository.
javanna pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/lucene.git
The following commit(s) were added to refs/heads/branch_9x by this push:
new 2bb54320c33 Make IndexSearcher#getSlices final and clarify docs (#12718)
2bb54320c33 is described below
commit 2bb54320c3376d967ac1ef4979d389ba27d6990f
Author: Luca Cavanna <ja...@apache.org>
AuthorDate: Thu Oct 26 12:34:37 2023 +0200
Make IndexSearcher#getSlices final and clarify docs (#12718)
IndexSearcher exposes a public getSlices method, that is used to
retrieve the slices that the searcher executes queries against, as well
as slices, which is supposed to be overridden to customize the creation
of slices.
I believe that getSlices should be final: there is no reason to override
the method. Also, it is too easy to confuse the two and end up
overriding the wrong one by mistake.
---
lucene/CHANGES.txt | 2 ++
.../core/src/java/org/apache/lucene/search/IndexSearcher.java | 11 ++++++-----
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index a649e041f65..7ca10b9310d 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -156,6 +156,8 @@ API Changes
* GITHUB#12646: Move FST#addNode to FSTCompiler to avoid a circular dependency between FST and FSTCompiler
(Anh Dung Bui via Alan Woodward)
+* GITHUB#12718: Make IndexSearcher#getSlices final as it is not expected to be overridden (Luca Cavanna)
+
New Features
---------------------
diff --git a/lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java b/lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java
index f776cbe0841..d69c3f8bdeb 100644
--- a/lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java
+++ b/lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java
@@ -118,10 +118,10 @@ public class IndexSearcher {
protected final List<LeafReaderContext> leafContexts;
/**
- * used with executor - LeafSlice supplier where each slice holds a set of leafs executed within
+ * Used with executor - LeafSlice supplier where each slice holds a set of leafs executed within
* one thread. We are caching it instead of creating it eagerly to avoid calling a protected
- * method from constructor, which is a bad practice. This is {@code null} if no executor is
- * provided
+ * method from constructor, which is a bad practice. Always non-null, regardless of whether an
+ * executor is provided or not.
*/
private final Supplier<LeafSlice[]> leafSlicesSupplier;
@@ -463,11 +463,12 @@ public class IndexSearcher {
}
/**
- * Returns the leaf slices used for concurrent searching
+ * Returns the leaf slices used for concurrent searching. Override {@link #slices(List)} to
+ * customize how slices are created.
*
* @lucene.experimental
*/
- public LeafSlice[] getSlices() {
+ public final LeafSlice[] getSlices() {
return leafSlicesSupplier.get();
}