LUCENE-8412: Further simplification.

This commit is contained in:
Adrien Grand 2018-07-30 09:49:34 +02:00
parent e264d03920
commit 3a837ca374
4 changed files with 12 additions and 22 deletions

View File

@ -38,8 +38,8 @@ public abstract class FieldValueHitQueue<T extends FieldValueHitQueue.Entry> ext
public static class Entry extends ScoreDoc { public static class Entry extends ScoreDoc {
public int slot; public int slot;
public Entry(int slot, int doc, float score) { public Entry(int slot, int doc) {
super(doc, score); super(doc, Float.NaN);
this.slot = slot; this.slot = slot;
} }

View File

@ -117,8 +117,6 @@ public abstract class TopFieldCollector extends TopDocsCollector<Entry> {
@Override @Override
public void collect(int doc) throws IOException { public void collect(int doc) throws IOException {
float score = Float.NaN;
++totalHits; ++totalHits;
if (queueFull) { if (queueFull) {
if (reverseMul * comparator.compareBottom(doc) <= 0) { 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 & adjustTop // This hit is competitive - replace bottom element in queue & adjustTop
comparator.copy(bottom.slot, doc); comparator.copy(bottom.slot, doc);
updateBottom(doc, score); updateBottom(doc);
comparator.setBottom(bottom.slot); comparator.setBottom(bottom.slot);
} else { } else {
// Startup transient: queue hasn't gathered numHits yet // Startup transient: queue hasn't gathered numHits yet
@ -147,7 +145,7 @@ public abstract class TopFieldCollector extends TopDocsCollector<Entry> {
// Copy hit into queue // Copy hit into queue
comparator.copy(slot, doc); comparator.copy(slot, doc);
add(slot, doc, score); add(slot, doc);
if (queueFull) { if (queueFull) {
comparator.setBottom(bottom.slot); comparator.setBottom(bottom.slot);
} }
@ -204,8 +202,6 @@ public abstract class TopFieldCollector extends TopDocsCollector<Entry> {
totalHits++; totalHits++;
float score = Float.NaN;
if (queueFull) { if (queueFull) {
// Fastmatch: return if this hit is no better than // Fastmatch: return if this hit is no better than
// the worst hit currently in the queue: // 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 & adjustTop // This hit is competitive - replace bottom element in queue & adjustTop
comparator.copy(bottom.slot, doc); comparator.copy(bottom.slot, doc);
updateBottom(doc, score); updateBottom(doc);
comparator.setBottom(bottom.slot); comparator.setBottom(bottom.slot);
} else { } else {
@ -247,7 +243,7 @@ public abstract class TopFieldCollector extends TopDocsCollector<Entry> {
// Copy hit into queue // Copy hit into queue
comparator.copy(slot, doc); comparator.copy(slot, doc);
bottom = pq.add(new Entry(slot, docBase + doc, score)); bottom = pq.add(new Entry(slot, docBase + doc));
queueFull = collectedHits == numHits; queueFull = collectedHits == numHits;
if (queueFull) { if (queueFull) {
comparator.setBottom(bottom.slot); comparator.setBottom(bottom.slot);
@ -395,8 +391,8 @@ public abstract class TopFieldCollector extends TopDocsCollector<Entry> {
} }
} }
final void add(int slot, int doc, float score) { final void add(int slot, int doc) {
bottom = pq.add(new Entry(slot, docBase + doc, score)); bottom = pq.add(new Entry(slot, docBase + doc));
queueFull = totalHits == numHits; queueFull = totalHits == numHits;
} }
@ -406,12 +402,6 @@ public abstract class TopFieldCollector extends TopDocsCollector<Entry> {
bottom = pq.updateTop(); 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 * Only the following callback methods need to be overridden since
* topDocs(int, int) calls them to return the results. * topDocs(int, int) calls them to return the results.

View File

@ -153,7 +153,7 @@ public class TestFilteredDocIdSet extends LuceneTestCase {
.add(new MatchAllDocsQuery(), Occur.MUST) .add(new MatchAllDocsQuery(), Occur.MUST)
.add(f, Occur.FILTER) .add(f, Occur.FILTER)
.build(); .build();
Assert.assertEquals(0, searcher.search(filtered, 10).totalHits); Assert.assertEquals(0, searcher.search(filtered, 10).totalHits.value);
reader.close(); reader.close();
dir.close(); dir.close();
} }
@ -214,7 +214,7 @@ public class TestFilteredDocIdSet extends LuceneTestCase {
.add(new MatchAllDocsQuery(), Occur.MUST) .add(new MatchAllDocsQuery(), Occur.MUST)
.add(f, Occur.FILTER) .add(f, Occur.FILTER)
.build(); .build();
Assert.assertEquals(0, searcher.search(filtered, 10).totalHits); Assert.assertEquals(0, searcher.search(filtered, 10).totalHits.value);
reader.close(); reader.close();
dir.close(); dir.close();
} }

View File

@ -469,8 +469,8 @@ public class BJQParserTest extends SolrTestCaseJ4 {
req(elFilterQuery), "//*[@numFound='2']"); req(elFilterQuery), "//*[@numFound='2']");
try(final SolrQueryRequest req = req()) { try(final SolrQueryRequest req = req()) {
final TopDocs topDocs = req.getSearcher().search(query, 10); final int count = req.getSearcher().count(query);
assertEquals("expecting new doc is visible to old query", 2, topDocs.totalHits); assertEquals("expecting new doc is visible to old query", 2, count);
} }
} }