AllGroupHeadsCollector.GroupHead (Lucene 10.5.0 grouping API)
Description: declaration: package: org.apache.lucene.search.grouping, class: AllGroupHeadsCollector, class: GroupHead

Package org.apache.lucene.search.grouping

# Class AllGroupHeadsCollector.GroupHead<T>

java.lang.Object
org.apache.lucene.search.grouping.AllGroupHeadsCollector.GroupHead<T>

Enclosing class:
  `AllGroupHeadsCollector<T>`

public abstract static class AllGroupHeadsCollector.GroupHead<T> extends Object
Represents a group head. A group head is the most relevant document for a particular group. The relevancy is based is usually based on the sort.

The group head contains a group value with its associated most relevant document id.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `int`
  `doc`
  `protected int`
  `docBase`
  `final T`
  `groupValue`

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `GroupHead(T groupValue, int doc, int docBase)`
  Create a new GroupHead for the given value

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected abstract int`
  `compare(int compIDX, int doc)`
  Compares the specified document for a specified comparator against the current most relevant document.
  `protected abstract FieldComparator[]`
  `getComparators()`
  Returns the field comparators used to determine the group head ordering.
  `protected abstract Object[]`
  `getSortValues()`
  Returns the sort values for this group head.
  `protected void`
  `setNextReader(LeafReaderContext ctx)`
  Called for each segment
  `protected abstract void`
  `setScorer(Scorable scorer)`
  Called for each segment
  `protected abstract void`
  `updateDocHead(int doc)`
  Updates the current most relevant document with the specified document.

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

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

- ## Field Details

  - ### groupValue

    public final T groupValue

  - ### doc

    public int doc

  - ### docBase

    protected int docBase

- ## Constructor Details

  - ### GroupHead

    protected GroupHead(T groupValue, int doc, int docBase)
    Create a new GroupHead for the given value

- ## Method Details

  - ### setNextReader

    protected void setNextReader(LeafReaderContext ctx) throws IOException
    Called for each segment
    Throws:
      `IOException`

  - ### setScorer

    protected abstract void setScorer(Scorable scorer) throws IOException
    Called for each segment
    Throws:
      `IOException`

  - ### compare

    protected abstract int compare(int compIDX, int doc) throws IOException
    Compares the specified document for a specified comparator against the current most relevant document.
    Parameters:
      `compIDX` - The comparator index of the specified comparator.
      `doc` - The specified document.
    Returns:
      -1 if the specified document wasn't competitive against the current most relevant document, 1 if the specified document was competitive against the current most relevant document. Otherwise 0.
    Throws:
      `IOException` - If I/O related errors occur

  - ### updateDocHead

    protected abstract void updateDocHead(int doc) throws IOException
    Updates the current most relevant document with the specified document.
    Parameters:
      `doc` - The specified document
    Throws:
      `IOException` - If I/O related errors occur

  - ### getSortValues

    protected abstract Object[] getSortValues()
    Returns the sort values for this group head.
    Returns:
      the sort values, or null if not stored

  - ### getComparators

    protected abstract FieldComparator[] getComparators()
    Returns the field comparators used to determine the group head ordering.
    Returns:
      the comparators, one per sort field