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

Package org.apache.lucene.search

# Class DocIdStream

java.lang.Object
org.apache.lucene.search.DocIdStream

public abstract class DocIdStream extends Object
A stream of doc IDs. Doc IDs may be consumed at most once.

See Also:
  - `LeafCollector.collect(DocIdStream)`
WARNING: This API is experimental and might change in incompatible ways in the next release.

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `DocIdStream()`
  Sole constructor, for invocation by sub classes.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `count()`
  Count the number of entries in this stream.
  `abstract int`
  `count(int upTo)`
  Count the number of doc IDs in this stream that are below the given `upTo`.
  `abstract void`
  `forEach(int upTo, CheckedIntConsumer<IOException> consumer)`
  Iterate over doc IDs contained in this doc ID stream up to the given `upTo` exclusive, calling the given `CheckedIntConsumer` on them.
  `void`
  `forEach(CheckedIntConsumer<IOException> consumer)`
  Iterate over doc IDs contained in this stream in order, calling the given `CheckedIntConsumer` on them.
  `int`
  `intoArray(int[] array)`
  Copy some matching doc IDs into the provided array and return the number of copied elements.
  `abstract int`
  `intoArray(int upTo, int[] array)`
  Copy some matching doc IDs under `upTo` (exclusive) into the provided array and return the number of copied elements.
  `abstract boolean`
  `mayHaveRemaining()`
  Return `true` if this stream may have remaining doc IDs.

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

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

- ## Constructor Details

  - ### DocIdStream

    protected DocIdStream()
    Sole constructor, for invocation by sub classes.

- ## Method Details

  - ### forEach

    public void forEach(CheckedIntConsumer<IOException> consumer) throws IOException
    Iterate over doc IDs contained in this stream in order, calling the given `CheckedIntConsumer` on them. This is a terminal operation.
    Throws:
      `IOException`

  - ### forEach

    public abstract void forEach(int upTo, CheckedIntConsumer<IOException> consumer) throws IOException
    Iterate over doc IDs contained in this doc ID stream up to the given `upTo` exclusive, calling the given `CheckedIntConsumer` on them. It is not possible to iterate these doc IDs again later on.
    Throws:
      `IOException`

  - ### count

    public int count() throws IOException
    Count the number of entries in this stream. This is a terminal operation.
    Throws:
      `IOException`

  - ### count

    public abstract int count(int upTo) throws IOException
    Count the number of doc IDs in this stream that are below the given `upTo`. These doc IDs may not be consumed again later.
    Throws:
      `IOException`

  - ### intoArray

    public int intoArray(int[] array)
    Copy some matching doc IDs into the provided array and return the number of copied elements. A return value of `0` indicates that there are no remaining doc IDs. The given array must not be empty.

  - ### intoArray

    public abstract int intoArray(int upTo, int[] array)
    Copy some matching doc IDs under `upTo` (exclusive) into the provided array and return the number of copied elements. A return value of `0` indicates that there are no matching doc IDs under `upTo` anymore. The given array must not be empty.

  - ### mayHaveRemaining

    public abstract boolean mayHaveRemaining()
    Return `true` if this stream may have remaining doc IDs. This must eventually return `false` when the stream is exhausted.