Package org.apache.lucene.index.sorter
Class Sorter
- java.lang.Object
-
- org.apache.lucene.index.sorter.Sorter
-
- Direct Known Subclasses:
BlockJoinSorter,NumericDocValuesSorter
public abstract class Sorter extends java.lang.ObjectSorts documents of a given index by returning a permutation on the document IDs.NOTE: A
Sorterimplementation can be easily written from adocument comparatorby using thesort(int, DocComparator)helper method. This is especially useful when documents are directly comparable by their field values.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSorter.DocComparatorA comparator of doc IDs.static classSorter.DocMapA permutation of doc IDs.
-
Field Summary
Fields Modifier and Type Field Description static Sorter.DocComparatorINDEX_ORDER_COMPARATORA comparator that keeps documents in index order.static SorterREVERSE_DOCSSorts documents in reverse order.
-
Constructor Summary
Constructors Constructor Description Sorter()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract java.lang.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.java.lang.StringtoString()
-
-
-
Field Detail
-
INDEX_ORDER_COMPARATOR
public static final Sorter.DocComparator INDEX_ORDER_COMPARATOR
A comparator that keeps documents in index order.
-
REVERSE_DOCS
public static final Sorter REVERSE_DOCS
Sorts documents in reverse order. NOTE: ThisSorteris not idempotent. Sorting anAtomicReaderonce or twice will return two differentAtomicReaderviews. ThisSortershould not be used withSortingMergePolicy.
-
-
Method Detail
-
sort
public abstract Sorter.DocMap sort(AtomicReader reader) throws java.io.IOException
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:
java.io.IOException
-
getID
public abstract java.lang.String getID()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-