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

Package org.apache.lucene.util

# Class StringSorter

java.lang.Object
org.apache.lucene.util.Sorter
org.apache.lucene.util.StringSorter

public abstract class StringSorter extends Sorter
A `BytesRef` sorter tries to use a efficient radix sorter if `cmp` is a `BytesRefComparator`, otherwise fallback to `fallbackSorter(java.util.Comparator<org.apache.lucene.util.BytesRef>)`

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
  `protected class`
  `StringSorter.MSBStringRadixSorter`
  A radix sorter for `BytesRef`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected final BytesRef`
  `pivot`
  `protected final BytesRefBuilder`
  `pivotBuilder`
  `protected final BytesRefBuilder`
  `scratch1`
  `protected final BytesRefBuilder`
  `scratch2`
  `protected final BytesRef`
  `scratchBytes1`
  `protected final BytesRef`
  `scratchBytes2`

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `StringSorter(Comparator<BytesRef> cmp)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected int`
  `compare(int i, int j)`
  Compare entries found in slots `i` and `j`.
  `protected Sorter`
  `fallbackSorter(Comparator<BytesRef> cmp)`
  `protected abstract void`
  `get(BytesRefBuilder builder, BytesRef result, int i)`
  `protected Sorter`
  `radixSorter(BytesRefComparator cmp)`
  `void`
  `sort(int from, int to)`
  Sort the slice which starts at `from` (inclusive) and ends at `to` (exclusive).

  ### Methods inherited from class org.apache.lucene.util.Sorter

  `comparePivot, setPivot, swap`

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

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

- ## Field Details

  - ### scratch1

    protected final BytesRefBuilder scratch1

  - ### scratch2

    protected final BytesRefBuilder scratch2

  - ### pivotBuilder

    protected final BytesRefBuilder pivotBuilder

  - ### scratchBytes1

    protected final BytesRef scratchBytes1

  - ### scratchBytes2

    protected final BytesRef scratchBytes2

  - ### pivot

    protected final BytesRef pivot

- ## Constructor Details

  - ### StringSorter

    protected StringSorter(Comparator<BytesRef> cmp)

- ## Method Details

  - ### get

    protected abstract void get(BytesRefBuilder builder, BytesRef result, int i)

  - ### compare

    protected int compare(int i, int j)
    Description copied from class: `Sorter`
    Compare entries found in slots `i` and `j`. The contract for the returned value is the same as `Comparator.compare(Object, Object)`.
    Specified by:
      `compare` in class `Sorter`

  - ### sort

    public void sort(int from, int to)
    Description copied from class: `Sorter`
    Sort the slice which starts at `from` (inclusive) and ends at `to` (exclusive).
    Specified by:
      `sort` in class `Sorter`

  - ### radixSorter

    protected Sorter radixSorter(BytesRefComparator cmp)

  - ### fallbackSorter

    protected Sorter fallbackSorter(Comparator<BytesRef> cmp)