mirror of https://github.com/apache/lucene.git
Update TestTopDocsMerge to not rely on search(Query, Collector) (#13601)
Relates to #12892
This commit is contained in:
parent
d491dfe131
commit
97d066dd6b
|
@ -292,26 +292,25 @@ public class TestTopDocsMerge extends LuceneTestCase {
|
||||||
topHits = searcher.search(query, numHits);
|
topHits = searcher.search(query, numHits);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
final TopFieldCollector c = TopFieldCollector.create(sort, numHits, Integer.MAX_VALUE);
|
TopFieldDocs topFieldDocs =
|
||||||
searcher.search(query, c);
|
searcher.search(query, new TopFieldCollectorManager(sort, numHits, Integer.MAX_VALUE));
|
||||||
if (useFrom) {
|
if (useFrom) {
|
||||||
from = TestUtil.nextInt(random(), 0, numHits - 1);
|
from = TestUtil.nextInt(random(), 0, numHits - 1);
|
||||||
size = numHits - from;
|
size = numHits - from;
|
||||||
TopDocs tempTopHits = c.topDocs();
|
if (from < topFieldDocs.scoreDocs.length) {
|
||||||
if (from < tempTopHits.scoreDocs.length) {
|
|
||||||
// Can't use TopDocs#topDocs(start, howMany), since it has different behaviour when
|
// Can't use TopDocs#topDocs(start, howMany), since it has different behaviour when
|
||||||
// start >= hitCount
|
// start >= hitCount
|
||||||
// than TopDocs#merge currently has
|
// than TopDocs#merge currently has
|
||||||
ScoreDoc[] newScoreDocs =
|
ScoreDoc[] newScoreDocs =
|
||||||
new ScoreDoc[Math.min(size, tempTopHits.scoreDocs.length - from)];
|
new ScoreDoc[Math.min(size, topFieldDocs.scoreDocs.length - from)];
|
||||||
System.arraycopy(tempTopHits.scoreDocs, from, newScoreDocs, 0, newScoreDocs.length);
|
System.arraycopy(topFieldDocs.scoreDocs, from, newScoreDocs, 0, newScoreDocs.length);
|
||||||
tempTopHits.scoreDocs = newScoreDocs;
|
topFieldDocs.scoreDocs = newScoreDocs;
|
||||||
topHits = tempTopHits;
|
topHits = topFieldDocs;
|
||||||
} else {
|
} else {
|
||||||
topHits = new TopDocs(tempTopHits.totalHits, new ScoreDoc[0]);
|
topHits = new TopDocs(topFieldDocs.totalHits, new ScoreDoc[0]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
topHits = c.topDocs(0, numHits);
|
topHits = topFieldDocs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue