mirror of https://github.com/apache/lucene.git
LUCENE-8412: Further simplification.
This commit is contained in:
parent
e264d03920
commit
3a837ca374
|
@ -38,8 +38,8 @@ public abstract class FieldValueHitQueue<T extends FieldValueHitQueue.Entry> ext
|
|||
public 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -117,8 +117,6 @@ public abstract class TopFieldCollector extends TopDocsCollector<Entry> {
|
|||
|
||||
@Override
|
||||
public 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 & adjustTop
|
||||
comparator.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 queue
|
||||
comparator.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 & adjustTop
|
||||
comparator.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 queue
|
||||
comparator.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.
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue