dnhatn commented on a change in pull request #326:
URL: https://github.com/apache/lucene/pull/326#discussion_r718495134
##########
File path:
lucene/core/src/test/org/apache/lucene/search/TestSortOptimization.java
##########
@@ -483,6 +484,42 @@ public void testDocSortOptimizationWithAfter() throws
IOException {
dir.close();
}
+ public void testDocSortOptimizationWithAfterCollectsAllDocs() throws
IOException {
+ final Directory dir = newDirectory();
+ final IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig());
+ final int numDocs = atLeast(TEST_NIGHTLY ? 50_000 : 5_000);
+ final boolean multipleSegments = random().nextBoolean();
+ final int numDocsInSegment = numDocs / 10 + random().nextInt(numDocs / 10);
+
+ for (int i = 1; i <= numDocs; ++i) {
+ final Document doc = new Document();
+ writer.addDocument(doc);
+ if (multipleSegments && (i % numDocsInSegment == 0)) {
+ writer.flush();
+ }
+ }
+ writer.flush();
+
+ IndexReader reader = DirectoryReader.open(writer);
+ IndexSearcher searcher = newSearcher(reader);
+ int visitedHits = 0;
+ ScoreDoc after = null;
+ while (visitedHits < numDocs) {
+ int batch = 1 + random().nextInt(500);
+ Query query = new MatchAllDocsQuery();
+ TopDocs topDocs = searcher.searchAfter(after, query, batch, new
Sort(FIELD_DOC));
+ int expectedHits = Math.min(numDocs - visitedHits, batch);
+ assertEquals(expectedHits, topDocs.scoreDocs.length);
+ after = topDocs.scoreDocs[expectedHits - 1];
+ for (int i = 0; i < topDocs.scoreDocs.length; i++) {
+ assertEquals(visitedHits, topDocs.scoreDocs[i].doc);
+ visitedHits++;
+ }
+ }
+ assert (visitedHits == numDocs);
Review comment:
assertEquals instead?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]