Apache Lucene open-source search software
LUCENE-8412: Further simplification.
Adrien Grand3a837ca3745c
diff --git a/lucene/core/src/java/org/apache/lucene/search/FieldValueHitQueue.java b/lucene/core/src/java/org/apache/lucene/search/FieldValueHitQueue.javaindex bd1967b1c3b..d282a0af54a 100644--- a/lucene/core/src/java/org/apache/lucene/search/FieldValueHitQueue.java+++ b/lucene/core/src/java/org/apache/lucene/search/FieldValueHitQueue.java@@ -38,8 +38,8 @@ public abstract class FieldValueHitQueue<T extends FieldValueHitQueue.Entry> extpublic static class Entry extends ScoreDoc {public int slot;- public Entry(int slot, int doc, float score) {- super(doc, score);+ public Entry(int slot, int doc) {+ super(doc, Float.NaN);this.slot = slot;}diff --git a/lucene/core/src/java/org/apache/lucene/search/TopFieldCollector.java b/lucene/core/src/java/org/apache/lucene/search/TopFieldCollector.javaindex f8a8ff7ca4a..99f4e2ca53b 100644--- a/lucene/core/src/java/org/apache/lucene/search/TopFieldCollector.java+++ b/lucene/core/src/java/org/apache/lucene/search/TopFieldCollector.java@@ -117,8 +117,6 @@ public abstract class TopFieldCollector extends TopDocsCollector<Entry> {@Overridepublic void collect(int doc) throws IOException {- float score = Float.NaN;-++totalHits;if (queueFull) {if (reverseMul * comparator.compareBottom(doc) <= 0) {@@ -139,7 +137,7 @@ public abstract class TopFieldCollector extends TopDocsCollector<Entry> {// This hit is competitive - replace bottom element in queue & adjustTopcomparator.copy(bottom.slot, doc);- updateBottom(doc, score);+ updateBottom(doc);comparator.setBottom(bottom.slot);} else {// Startup transient: queue hasn't gathered numHits yet@@ -147,7 +145,7 @@ public abstract class TopFieldCollector extends TopDocsCollector<Entry> {// Copy hit into queuecomparator.copy(slot, doc);- add(slot, doc, score);+ add(slot, doc);if (queueFull) {comparator.setBottom(bottom.slot);}@@ -204,8 +202,6 @@ public abstract class TopFieldCollector extends TopDocsCollector<Entry> {totalHits++;- float score = Float.NaN;-if (queueFull) {// Fastmatch: return if this hit is no better than// the worst hit currently in the queue:@@ -235,7 +231,7 @@ public abstract class TopFieldCollector extends TopDocsCollector<Entry> {// This hit is competitive - replace bottom element in queue & adjustTopcomparator.copy(bottom.slot, doc);- updateBottom(doc, score);+ updateBottom(doc);comparator.setBottom(bottom.slot);} else {@@ -247,7 +243,7 @@ public abstract class TopFieldCollector extends TopDocsCollector<Entry> {// Copy hit into queuecomparator.copy(slot, doc);- bottom = pq.add(new Entry(slot, docBase + doc, score));+ bottom = pq.add(new Entry(slot, docBase + doc));queueFull = collectedHits == numHits;if (queueFull) {comparator.setBottom(bottom.slot);@@ -395,8 +391,8 @@ public abstract class TopFieldCollector extends TopDocsCollector<Entry> {}}- final void add(int slot, int doc, float score) {- bottom = pq.add(new Entry(slot, docBase + doc, score));+ final void add(int slot, int doc) {+ bottom = pq.add(new Entry(slot, docBase + doc));queueFull = totalHits == numHits;}@@ -406,12 +402,6 @@ public abstract class TopFieldCollector extends TopDocsCollector<Entry> {bottom = pq.updateTop();}- final void updateBottom(int doc, float score) {- bottom.doc = docBase + doc;- bottom.score = score;- bottom = pq.updateTop();- }-/** Only the following callback methods need to be overridden since* topDocs(int, int) calls them to return the results.diff --git a/solr/core/src/test/org/apache/solr/search/TestFilteredDocIdSet.java b/solr/core/src/test/org/apache/solr/search/TestFilteredDocIdSet.javaindex 044723b82c9..88b16ae6666 100644--- a/solr/core/src/test/org/apache/solr/search/TestFilteredDocIdSet.java+++ b/solr/core/src/test/org/apache/solr/search/TestFilteredDocIdSet.java@@ -153,7 +153,7 @@ public class TestFilteredDocIdSet extends LuceneTestCase {.add(new MatchAllDocsQuery(), Occur.MUST).add(f, Occur.FILTER).build();- Assert.assertEquals(0, searcher.search(filtered, 10).totalHits);+ Assert.assertEquals(0, searcher.search(filtered, 10).totalHits.value);reader.close();dir.close();}@@ -214,7 +214,7 @@ public class TestFilteredDocIdSet extends LuceneTestCase {.add(new MatchAllDocsQuery(), Occur.MUST).add(f, Occur.FILTER).build();- Assert.assertEquals(0, searcher.search(filtered, 10).totalHits);+ Assert.assertEquals(0, searcher.search(filtered, 10).totalHits.value);reader.close();dir.close();}diff --git a/solr/core/src/test/org/apache/solr/search/join/BJQParserTest.java b/solr/core/src/test/org/apache/solr/search/join/BJQParserTest.javaindex 250e0769571..a2f625c849f 100644--- a/solr/core/src/test/org/apache/solr/search/join/BJQParserTest.java+++ b/solr/core/src/test/org/apache/solr/search/join/BJQParserTest.java@@ -469,8 +469,8 @@ public class BJQParserTest extends SolrTestCaseJ4 {req(elFilterQuery), "//*[@numFound='2']");try(final SolrQueryRequest req = req()) {- final TopDocs topDocs = req.getSearcher().search(query, 10);- assertEquals("expecting new doc is visible to old query", 2, topDocs.totalHits);+ final int count = req.getSearcher().count(query);+ assertEquals("expecting new doc is visible to old query", 2, count);}}