FacetRecorder (Lucene 10.5.0 sandbox API)
Description: declaration: package: org.apache.lucene.sandbox.facet.recorders, interface: FacetRecorder

Package org.apache.lucene.sandbox.facet.recorders

# Interface FacetRecorder

All Known Implementing Classes:
  `CountFacetRecorder`, `LongAggregationsFacetRecorder`, `MultiFacetsRecorder`

public interface FacetRecorder
Record data for each facet of each doc.

TODO: In the next iteration we can add an extra layer between FacetRecorder and LeafFacetRecorder, e.g. SliceFacetRecorder. The new layer will be created per `Collector`, which means that collecting of multiple leafs (segments) within a slice is sequential and can be done to a single non-sync map to improve performance and reduce memory consumption. We already tried that, but didn't see any performance improvement. Given that it also makes lazy leaf recorder init in `FacetFieldCollector` trickier, it was decided to rollback the initial attempt and try again later, in the next iteration.

WARNING: This API is experimental and might change in incompatible ways in the next release.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `contains(int ordinal)`
  Check if any data was recorded for provided facet ordinal.
  `LeafFacetRecorder`
  `getLeafRecorder(LeafReaderContext context)`
  Get leaf recorder.
  `boolean`
  `isEmpty()`
  True if there are no records
  `OrdinalIterator`
  `recordedOrds()`
  Return next collected ordinal, or `OrdinalIterator.NO_MORE_ORDS`
  `void`
  `reduce(FacetCutter facetCutter)`
  Reduce leaf recorder results into this recorder.

- ## Method Details

  - ### getLeafRecorder

    LeafFacetRecorder getLeafRecorder(LeafReaderContext context) throws IOException
    Get leaf recorder.
    Throws:
      `IOException`

  - ### recordedOrds

    OrdinalIterator recordedOrds()
    Return next collected ordinal, or `OrdinalIterator.NO_MORE_ORDS`

  - ### isEmpty

    boolean isEmpty()
    True if there are no records

  - ### reduce

    void reduce(FacetCutter facetCutter) throws IOException
    Reduce leaf recorder results into this recorder. If `FacetCutter.getOrdinalsToRollup()` result is not null, it also rolls up values.

    After this method is called, it's illegal to add values to recorder, i.e. calling `getLeafRecorder(org.apache.lucene.index.LeafReaderContext)` or `LeafFacetRecorder.record(int, int)` on its leaf recorders.

    Throws:
      `UnsupportedOperationException` - if `FacetCutter.getOrdinalsToRollup()` returns not null but this recorder doesn't support rollup.
      `IOException`

  - ### contains

    boolean contains(int ordinal)
    Check if any data was recorded for provided facet ordinal.