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 2025/02/21 18:18:44 UTC

(lucene) branch branch_10_1 updated: Stop cloning index input when loading NRTSuggester (#14271)

This is an automated email from the ASF dual-hosted git repository.

javanna pushed a commit to branch branch_10_1
in repository https://gitbox.apache.org/repos/asf/lucene.git


The following commit(s) were added to refs/heads/branch_10_1 by this push:
     new 576c449cce6 Stop cloning index input when loading NRTSuggester (#14271)
576c449cce6 is described below

commit 576c449cce64fa497cbc9000bb2c7600b3b7efe0
Author: Luca Cavanna <ja...@apache.org>
AuthorDate: Fri Feb 21 19:02:25 2025 +0100

    Stop cloning index input when loading NRTSuggester (#14271)
    
    Cloning the index input is not necessary when loading the NRTSUggester. Also,
    it causes a bug as the clone gets closed right before the suggester instance
    gets returned, which makes it unusable in the later lookup method which slices
    the index input while it's already closed.
    
    This was not discovered so far due to a testing gap that is fixed by #14270
---
 lucene/CHANGES.txt                                                  | 1 +
 .../lucene/search/suggest/document/CompletionsTermsReader.java      | 6 ++----
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index d360f27ff47..3c3cb0fac86 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -130,6 +130,7 @@ Bug Fixes
 * GITHUB#14008: Counts provided by taxonomy facets in addition to another aggregation are now returned together with
   their corresponding ordinals. (Paul King)
 * GITHUB#14027: Make SegmentInfos#readCommit(Directory, String, int) public (Luca Cavanna)
+* GITHUB#14271: Stop closing index input when loading NRTSuggester (Luca Cavanna)
 
 Build
 ---------------------
diff --git a/lucene/suggest/src/java/org/apache/lucene/search/suggest/document/CompletionsTermsReader.java b/lucene/suggest/src/java/org/apache/lucene/search/suggest/document/CompletionsTermsReader.java
index 9aac363b2d0..f8e22256f75 100644
--- a/lucene/suggest/src/java/org/apache/lucene/search/suggest/document/CompletionsTermsReader.java
+++ b/lucene/suggest/src/java/org/apache/lucene/search/suggest/document/CompletionsTermsReader.java
@@ -72,10 +72,8 @@ public final class CompletionsTermsReader implements Accountable {
    */
   public synchronized NRTSuggester suggester() throws IOException {
     if (suggester == null) {
-      try (IndexInput dictClone = dictIn.clone()) { // let multiple fields load concurrently
-        dictClone.seek(offset);
-        suggester = NRTSuggester.load(dictClone, fstLoadMode);
-      }
+      IndexInput indexInput = dictIn.slice("NRTSuggester", offset, dictIn.length() - offset);
+      suggester = NRTSuggester.load(indexInput, fstLoadMode);
     }
     return suggester;
   }