Skip to content

Apache Lucene open-source search software

LUCENE-5579: BitDocIdSet.Builder.isDefinitelyEmpty()

David Wayne Smiley6a8bd4c2c3c1
diff --git a/lucene/core/src/java/org/apache/lucene/util/BitDocIdSet.java b/lucene/core/src/java/org/apache/lucene/util/BitDocIdSet.java
index dd3b24b8335..51220ac3cfb 100644
--- a/lucene/core/src/java/org/apache/lucene/util/BitDocIdSet.java
+++ b/lucene/core/src/java/org/apache/lucene/util/BitDocIdSet.java
@@ -106,6 +106,15 @@ public class BitDocIdSet extends DocIdSet {
return denseSet != null;
}
+ /**
+ * Is this builder definitely empty? If so, {@link #build()} will return null. This is usually the same as
+ * simply being empty but if this builder was constructed with the {@code full} option or if an iterator was passed
+ * that iterated over no documents, then we're not sure.
+ */
+ public boolean isDefinitelyEmpty() {
+ return sparseSet == null && denseSet == null;
+ }
+
/**
* Add the content of the provided {@link DocIdSetIterator} to this builder.
*/