Package org.apache.lucene.index
Class Sorter
java.lang.Object
org.apache.lucene.index.Sorter
Sorts documents of a given index by returning a permutation on the document IDs.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class
A permutation of doc IDs.private static final class
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetID()
Returns the identifier of thisSorter
.(package private) static boolean
isConsistent
(Sorter.DocMap docMap) Check consistency of aSorter.DocMap
, useful for assertions.private static Sorter.DocMap
sort
(int maxDoc, IndexSorter.DocComparator comparator) Computes the old-to-new permutation over the given comparator.(package private) Sorter.DocMap
sort
(int maxDoc, IndexSorter.DocComparator[] comparators) (package private) Sorter.DocMap
sort
(LeafReader reader) Returns a mapping from the old document ID to its new location in the sorted index.toString()
-
Field Details
-
sort
-
-
Constructor Details
-
Sorter
Sorter(Sort sort) Creates a new Sorter to sort the index withsort
-
-
Method Details
-
isConsistent
Check consistency of aSorter.DocMap
, useful for assertions. -
sort
Computes the old-to-new permutation over the given comparator. -
sort
Returns a mapping from the old document ID to its new location in the sorted index. Implementations can use the auxiliarysort(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 thatreader
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
- Throws:
IOException
-
getID
Returns the identifier of thisSorter
.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 differentsorts
. -
toString
-