You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by iv...@apache.org on 2026/06/03 10:12:57 UTC

(lucene) branch main updated: Simplify how we collect hits in the LRU cache from a DocIdStream (#16178)

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

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


The following commit(s) were added to refs/heads/main by this push:
     new 4858f3717c6 Simplify how we collect hits in the LRU cache from a DocIdStream (#16178)
4858f3717c6 is described below

commit 4858f3717c66e55bd99da0e3899fb4a0fe4f09c0
Author: Ignacio Vera <iv...@apache.org>
AuthorDate: Wed Jun 3 11:12:50 2026 +0100

    Simplify how we collect hits in the LRU cache from a DocIdStream (#16178)
---
 lucene/CHANGES.txt                                          |  3 +++
 .../src/java/org/apache/lucene/search/LRUQueryCache.java    | 13 ++-----------
 2 files changed, 5 insertions(+), 11 deletions(-)

diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 6741ae45603..cf0503b3902 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -586,6 +586,9 @@ Other
 
 * GITHUB##16135: Disable external entities in hyphenation PatternParser. (metsw24-max, Uwe Schindler)
 
+* GITHUB#16178: Simplify how we collect hits in the LRU cache from a DocIdStream into a RoaringDocIdSet.
+  (Ignacio Vera)
+
 ======================= Lucene 10.4.0 =======================
 
 API Changes
diff --git a/lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java b/lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java
index bc87550837e..cc35845f7d8 100644
--- a/lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java
+++ b/lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java
@@ -649,8 +649,6 @@ public class LRUQueryCache implements QueryCache, Accountable, Closeable {
     scorer.score(
         new LeafCollector() {
 
-          private int[] buffer = null;
-
           @Override
           public void setScorer(Scorable scorer) {}
 
@@ -665,15 +663,8 @@ public class LRUQueryCache implements QueryCache, Accountable, Closeable {
           }
 
           @Override
-          public void collect(DocIdStream stream) {
-            if (buffer == null) {
-              buffer = new int[128];
-            }
-            for (int c = stream.intoArray(buffer); c != 0; c = stream.intoArray(buffer)) {
-              for (int i = 0; i < c; ++i) {
-                builder.add(buffer[i]);
-              }
-            }
+          public void collect(DocIdStream stream) throws IOException {
+            stream.forEach(builder::add);
           }
         },
         null,