DocsWithFieldSet (Lucene 10.5.1 core API)
Description: declaration: package: org.apache.lucene.index, class: DocsWithFieldSet

Package org.apache.lucene.index

# Class DocsWithFieldSet

java.lang.Object
org.apache.lucene.search.DocIdSet
org.apache.lucene.index.DocsWithFieldSet

All Implemented Interfaces:
  `Accountable`

public final class DocsWithFieldSet extends DocIdSet
Accumulator for documents that have a value for a field. This is optimized for the case that all documents have a value.

- ## Field Summary

  ### Fields inherited from class org.apache.lucene.search.DocIdSet

  `EMPTY`

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

  `NULL_ACCOUNTABLE`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `DocsWithFieldSet()`
  Creates an empty DocsWithFieldSet.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `add(int docID)`
  Add a document to the set
  `void`
  `addRange(int from, int toExclusive)`
  Add a contiguous range of document IDs to the set.
  `int`
  `cardinality()`
  Return the number of documents of this set.
  `DocIdSetIterator`
  `iterator()`
  Provides a `DocIdSetIterator` to access the set.
  `long`
  `ramBytesUsed()`
  Returns an estimate of the JVM heap memory used by this object in bytes.

  ### Methods inherited from class org.apache.lucene.search.DocIdSet

  `all, bits`

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

- ## Constructor Details

  - ### DocsWithFieldSet

    public DocsWithFieldSet()
    Creates an empty DocsWithFieldSet.

- ## Method Details

  - ### add

    public void add(int docID)
    Add a document to the set
    Parameters:
      `docID` - – document ID to be added

  - ### addRange

    public void addRange(int from, int toExclusive)
    Add a contiguous range of document IDs to the set.
    Parameters:
      `from` - first document ID (inclusive)
      `toExclusive` - one past the last document ID (exclusive)

  - ### ramBytesUsed

    public long ramBytesUsed()
    Description copied from interface: `Accountable`
    Returns an estimate of the JVM heap memory used by this object in bytes. The method name uses "ram" for historical reasons; only JVM heap memory should be reported. Off-heap resources such as memory-mapped files or native direct buffers should not be included. Negative values are illegal.

  - ### iterator

    public DocIdSetIterator iterator()
    Description copied from class: `DocIdSet`
    Provides a `DocIdSetIterator` to access the set. This implementation can return `null` if there are no docs that match.
    Specified by:
      `iterator` in class `DocIdSet`

  - ### cardinality

    public int cardinality()
    Return the number of documents of this set.