Package org.apache.lucene.index.sorter
Class Sorter
java.lang.Object
org.apache.lucene.index.sorter.Sorter
- Direct Known Subclasses:
BlockJoinSorter,NumericDocValuesSorter
Sorts documents of a given index by returning a permutation on the document
IDs.
NOTE: A Sorter implementation can be easily written from
a document comparator by using the
sort(int, DocComparator) helper method. This is especially useful
when documents are directly comparable by their field values.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA comparator of doc IDs.static classA permutation of doc IDs. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Sorter.DocComparatorA comparator that keeps documents in index order.static final SorterSorts documents in reverse order. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract StringgetID()Returns the identifier of thisSorter.abstract Sorter.DocMapsort(AtomicReader reader) Returns a mapping from the old document ID to its new location in the sorted index.toString()
-
Field Details
-
INDEX_ORDER_COMPARATOR
A comparator that keeps documents in index order. -
REVERSE_DOCS
Sorts documents in reverse order. NOTE: ThisSorteris not idempotent. Sorting anAtomicReaderonce or twice will return two differentAtomicReaderviews. ThisSortershould not be used withSortingMergePolicy.
-
-
Constructor Details
-
Sorter
public Sorter()
-
-
Method Details
-
sort
Returns a mapping from the old document ID to its new location in the sorted index. Implementations can use the auxiliarysort(int, 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
readeris 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
-
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 differentsorters. -
toString
-