RoaringDocIdSet (Lucene 10.5.0 core API)
Description: declaration: package: org.apache.lucene.util, class: RoaringDocIdSet

Package org.apache.lucene.util

# Class RoaringDocIdSet

java.lang.Object
org.apache.lucene.search.DocIdSet
org.apache.lucene.util.RoaringDocIdSet

All Implemented Interfaces:
  `Accountable`

public class RoaringDocIdSet extends DocIdSet
`DocIdSet` implementation inspired from http://roaringbitmap.org/

The space is divided into blocks of 2^16 bits and each block is encoded independently. In each block, if less than 2^12 bits are set, then documents are simply stored in a short[]. If more than 2^16-2^12 bits are set, then the inverse of the set is encoded in a simple short[]. Otherwise a `FixedBitSet` is used.

NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `RoaringDocIdSet.Builder`
  A builder of `RoaringDocIdSet`s.

- ## Field Summary

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

  `EMPTY`

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

  `NULL_ACCOUNTABLE`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `cardinality()`
  Return the exact number of documents that are contained in 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.
  `String`
  `toString()`

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

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

  `getChildResources`

- ## Method Details

  - ### 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() throws IOException
    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`
    Throws:
      `IOException`

  - ### cardinality

    public int cardinality()
    Return the exact number of documents that are contained in this set.

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`