jpountz commented on code in PR #13895:
URL: https://github.com/apache/lucene/pull/13895#discussion_r1797605709


##########
lucene/core/src/java/org/apache/lucene/index/PendingSoftDeletes.java:
##########
@@ -76,15 +76,14 @@ void onNewReader(CodecReader reader, SegmentCommitInfo 
info) throws IOException
     hardDeletes.onNewReader(reader, info);
     // only re-calculate this if we haven't seen this generation
     if (dvGeneration < info.getDocValuesGen()) {
-      final DocIdSetIterator iterator =
-          FieldExistsQuery.getDocValuesDocIdSetIterator(field, reader);
-      int newDelCount;
-      if (iterator
-          != null) { // nothing is deleted we don't have a soft deletes field 
in this segment
-        assert info.info.maxDoc() > 0 : "maxDoc is 0";
+      final int newDelCount;
+      var iterator = FieldExistsQuery.getDocValuesDocIdSetIterator(field, 
reader);
+      if (iterator != null && iterator.nextDoc() != 
DocIdSetIterator.NO_MORE_DOCS) {
+        iterator = FieldExistsQuery.getDocValuesDocIdSetIterator(field, 
reader);

Review Comment:
   I wonder if we could change `applySoftDeletes` to start with the current doc 
ID so that we don't need to re-create an iterator here?



-- 
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: issues-unsubscr...@lucene.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to