org.apache.lucene.search.comparators

## Class NumericComparator.NumericLeafComparator

- java.lang.Object
- - org.apache.lucene.search.comparators.NumericComparator.NumericLeafComparator

All Implemented Interfaces:
  LeafFieldComparator

Direct Known Subclasses:
  DoubleComparator.DoubleLeafComparator, FloatComparator.FloatLeafComparator, IntComparator.IntLeafComparator, LongComparator.LongLeafComparator

Enclosing class:
  NumericComparator<T extends Number>

    public abstract class NumericComparator.NumericLeafComparator
    extends Object
    implements LeafFieldComparator

Leaf comparator for `NumericComparator` that provides skipping functionality

### Field Summary

Fields
`protected NumericDocValues` `docValues`

### Constructor Summary

Constructors
Constructor and Description
`NumericLeafComparator(LeafReaderContext context)`

### Method Summary

All Methods Instance Methods Abstract Methods Concrete Methods
`DocIdSetIterator` `competitiveIterator()` Returns a competitive iterator
`void` `copy(int slot, int doc)` This method is called when a new hit is competitive.
`protected abstract void` `encodeBottom(byte[] packedValue)`
`protected abstract void` `encodeTop(byte[] packedValue)`
`protected NumericDocValues` `getNumericDocValues(LeafReaderContext context, String field)` Retrieves the NumericDocValues for the field in this segment
`protected PointValues` `getPointValues(LeafReaderContext context, String field)` Retrieves point values for the field in this segment
`protected abstract boolean` `isMissingValueCompetitive()`
`void` `setBottom(int slot)` Set the bottom slot, ie the "weakest" (sorted last) entry in the queue.
`void` `setHitsThresholdReached()` Informs this leaf comparator that hits threshold is reached.
`void` `setScorer(Scorable scorer)` Sets the Scorer to use in case a document's score is needed.

### 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.search.LeafFieldComparator

`compareBottom, compareTop`

### Field Detail

#### docValues

    protected final NumericDocValues docValues

### Constructor Detail

#### NumericLeafComparator

    public NumericLeafComparator(LeafReaderContext context)
                          throws IOException

Throws:
  `IOException`

### Method Detail

#### getNumericDocValues

    protected NumericDocValues getNumericDocValues(LeafReaderContext context,
                                                   String field)
                                            throws IOException

Retrieves the NumericDocValues for the field in this segment

If you override this method, you must also override `getPointValues(LeafReaderContext, String)` This class uses sort optimization that leverages points to filter out non-competitive matches, which relies on the assumption that points and doc values record the same information.

Parameters:
  `context` - – reader context
  `field` - - field name
Returns:
  numeric doc values for the field in this segment.
Throws:
  `IOException` - If there is a low-level I/O error

#### getPointValues

    protected PointValues getPointValues(LeafReaderContext context,
                                         String field)
                                  throws IOException

Retrieves point values for the field in this segment

If you override this method, you must also override `getNumericDocValues(LeafReaderContext, String)` This class uses sort optimization that leverages points to filter out non-competitive matches, which relies on the assumption that points and doc values record the same information. Return `null` even if no points implementation is available, in this case sort optimization with points will be disabled.

Parameters:
  `context` - – reader context
  `field` - - field name
Returns:
  point values for the field in this segment if they are available or `null` if sort optimization with points should be disabled.
Throws:
  `IOException` - If there is a low-level I/O error

#### setBottom

    public void setBottom(int slot)
                   throws IOException

Description copied from interface: `LeafFieldComparator`
Set the bottom slot, ie the "weakest" (sorted last) entry in the queue. When `LeafFieldComparator.compareBottom(int)` is called, you should compare against this slot. This will always be called before `LeafFieldComparator.compareBottom(int)`.

Specified by:
  `setBottom` in interface `LeafFieldComparator`
Parameters:
  `slot` - the currently weakest (sorted last) slot in the queue
Throws:
  `IOException`

#### copy

    public void copy(int slot,
                     int doc)
              throws IOException

Description copied from interface: `LeafFieldComparator`
This method is called when a new hit is competitive. You should copy any state associated with this document that will be required for future comparisons, into the specified slot.

Specified by:
  `copy` in interface `LeafFieldComparator`
Parameters:
  `slot` - which slot to copy the hit to
  `doc` - docID relative to current reader
Throws:
  `IOException`

#### setScorer

    public void setScorer(Scorable scorer)
                   throws IOException

Description copied from interface: `LeafFieldComparator`
Sets the Scorer to use in case a document's score is needed.

Specified by:
  `setScorer` in interface `LeafFieldComparator`
Parameters:
  `scorer` - Scorer instance that you should use to obtain the current hit's score, if necessary.
Throws:
  `IOException`

#### setHitsThresholdReached

    public void setHitsThresholdReached()
                                 throws IOException

Description copied from interface: `LeafFieldComparator`
Informs this leaf comparator that hits threshold is reached. This method is called from a collector when hits threshold is reached.

Specified by:
  `setHitsThresholdReached` in interface `LeafFieldComparator`
Throws:
  `IOException`

#### competitiveIterator

    public DocIdSetIterator competitiveIterator()

Description copied from interface: `LeafFieldComparator`
Returns a competitive iterator

Specified by:
  `competitiveIterator` in interface `LeafFieldComparator`
Returns:
  an iterator over competitive docs that are stronger than already collected docs or `null` if such an iterator is not available for the current comparator or segment.

#### isMissingValueCompetitive

    protected abstract boolean isMissingValueCompetitive()

#### encodeBottom

    protected abstract void encodeBottom(byte[] packedValue)

#### encodeTop

    protected abstract void encodeTop(byte[] packedValue)