org.apache.lucene.search

## Class DocIdSet

- java.lang.Object
- - org.apache.lucene.search.DocIdSet

- All Implemented Interfaces:
    Accountable
  Direct Known Subclasses:
    BitDocIdSet, NotDocIdSet, RoaringDocIdSet

      public abstract class DocIdSet
      extends Object
      implements Accountable

  A DocIdSet contains a set of doc ids. Implementing classes must only implement `iterator()` to provide access to the set.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static DocIdSet` | `EMPTY` An empty `DocIdSet` instance

    - ### Fields inherited from interface org.apache.lucene.util.Accountable

      `NULL_ACCOUNTABLE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DocIdSet()`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Bits` | `bits()` Optionally provides a `Bits` interface for random access to matching documents.
    `abstract DocIdSetIterator` | `iterator()` Provides a `DocIdSetIterator` to access the set.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.apache.lucene.util.Accountable

      `getChildResources, ramBytesUsed`

- - ### Field Detail

    - #### EMPTY

          public static final DocIdSet EMPTY

      An empty `DocIdSet` instance

  - ### Constructor Detail

    - #### DocIdSet

          public DocIdSet()

  - ### Method Detail

    - #### iterator

          public abstract DocIdSetIterator iterator()
                                             throws IOException

      Provides a `DocIdSetIterator` to access the set. This implementation can return `null` if there are no docs that match.
      Throws:
        `IOException`

    - #### bits

          public Bits bits()
                    throws IOException

      Optionally provides a `Bits` interface for random access to matching documents.
      Returns:
        `null`, if this `DocIdSet` does not support random access. In contrast to `iterator()`, a return value of `null` does not imply that no documents match the filter! The default implementation does not provide random access, so you only need to implement this method if your DocIdSet can guarantee random access to every docid in O(1) time without external disk access (as `Bits` interface cannot throw `IOException`). This is generally true for bit sets like `FixedBitSet`, which return itself if they are used as `DocIdSet`.
      Throws:
        `IOException`

Copyright © 2000-2022 Apache Software Foundation. All Rights Reserved.