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.Object
Sorts documents of a given index by returning a permutation on the document IDs.NOTE: A
Sorter
implementation can be easily written from adocument comparator
by 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 class
Sorter.DocComparator
A comparator of doc IDs.static class
Sorter.DocMap
A permutation of doc IDs.
-
Field Summary
Fields Modifier and Type Field Description static Sorter.DocComparator
INDEX_ORDER_COMPARATOR
A comparator that keeps documents in index order.static Sorter
REVERSE_DOCS
Sorts 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.String
getID()
Returns the identifier of thisSorter
.abstract Sorter.DocMap
sort(AtomicReader reader)
Returns a mapping from the old document ID to its new location in the sorted index.java.lang.String
toString()
-
-
-
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: ThisSorter
is not idempotent. Sorting anAtomicReader
once or twice will return two differentAtomicReader
views. ThisSorter
should 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
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:
java.io.IOException
-
getID
public abstract java.lang.String getID()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-