Apache Lucene open-source search software
Simplify how we collect hits in the LRU cache from a DocIdStream (#16178)
Ignacio Vera4858f3717c66
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txtindex 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 Changesdiff --git a/lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java b/lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.javaindex 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;-@Overridepublic 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,