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


##########
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 considered that option as well, but I think creating a new docValues 
iterator is cheaper than allocating a bitset for liveDocs, so I chose this 
approach.



-- 
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