Class Sorter

java.lang.Object
org.apache.lucene.index.Sorter

public final class Sorter extends Object
Sorts documents of a given index by returning a permutation on the document IDs.
  • Field Details

    • sort

      final Sort sort
  • Constructor Details

    • Sorter

      Sorter(Sort sort)
      Creates a new Sorter to sort the index with sort
  • Method Details

    • isConsistent

      static boolean isConsistent(Sorter.DocMap docMap)
      Check consistency of a Sorter.DocMap, useful for assertions.
    • sort

      private static Sorter.DocMap sort(int maxDoc, IndexSorter.DocComparator comparator)
      Computes the old-to-new permutation over the given comparator.
    • sort

      Sorter.DocMap sort(LeafReader reader) throws IOException
      Returns a mapping from the old document ID to its new location in the sorted index. Implementations can use the auxiliary sort(int, IndexSorter.DocComparator) to compute the old-to-new permutation given a list of documents and their corresponding values.

      A return value of null is allowed and means that reader is already sorted.

      NOTE: deleted documents are expected to appear in the mapping as well, they will however be marked as deleted in the sorted view.

      Throws:
      IOException
    • sort

      Sorter.DocMap sort(int maxDoc, IndexSorter.DocComparator[] comparators) throws IOException
      Throws:
      IOException
    • getID

      public String getID()
      Returns the identifier of this Sorter.

      This identifier is similar to Object.hashCode() and should be chosen so that two instances of this class that sort documents likewise will have the same identifier. On the contrary, this identifier should be different on different sorts.

    • toString

      public String toString()
      Overrides:
      toString in class Object