Interface IndexSorter
-
- All Known Implementing Classes:
IndexSorter.DoubleSorter,IndexSorter.FloatSorter,IndexSorter.IntSorter,IndexSorter.LongSorter,IndexSorter.StringSorter
public interface IndexSorterHandles how documents should be sorted in an index, both within a segment and between segments.Implementers must provide the following methods:
getDocComparator(LeafReader,int)- an object that determines how documents within a segment are to be sortedgetComparableProviders(List)- an array of objects that return a sortable long value per document and segmentgetProviderName()- the SPI-registered name of aSortFieldProviderto serialize the sortThe companion
SortFieldProvidershould be registered with SPI viaMETA-INF/services
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceIndexSorter.ComparableProviderUsed for sorting documents across segmentsstatic interfaceIndexSorter.DocComparatorA comparator of doc IDs, used for sorting documents within a segmentstatic classIndexSorter.DoubleSorterSorts documents based on double values from a NumericDocValues instancestatic classIndexSorter.FloatSorterSorts documents based on float values from a NumericDocValues instancestatic classIndexSorter.IntSorterSorts documents based on integer values from a NumericDocValues instancestatic classIndexSorter.LongSorterSorts documents based on long values from a NumericDocValues instancestatic interfaceIndexSorter.NumericDocValuesProviderProvide a NumericDocValues instance for a LeafReaderstatic interfaceIndexSorter.SortedDocValuesProviderProvide a SortedDocValues instance for a LeafReaderstatic classIndexSorter.StringSorterSorts documents based on terms from a SortedDocValues instance
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description IndexSorter.ComparableProvider[]getComparableProviders(List<? extends LeafReader> readers)Get an array ofIndexSorter.ComparableProvider, one per segment, for merge sorting documents in different segmentsIndexSorter.DocComparatorgetDocComparator(LeafReader reader, int maxDoc)Get a comparator that determines the sort order of docs within a single Reader.StringgetProviderName()The SPI-registered name of aSortFieldProviderthat will deserialize the parent SortField
-
-
-
Method Detail
-
getComparableProviders
IndexSorter.ComparableProvider[] getComparableProviders(List<? extends LeafReader> readers) throws IOException
Get an array ofIndexSorter.ComparableProvider, one per segment, for merge sorting documents in different segments- Parameters:
readers- the readers to be merged- Throws:
IOException
-
getDocComparator
IndexSorter.DocComparator getDocComparator(LeafReader reader, int maxDoc) throws IOException
Get a comparator that determines the sort order of docs within a single Reader.NB We cannot simply use the
FieldComparatorAPI because it requires docIDs to be sent in-order. The default implementations allocate array[maxDoc] to hold native values for comparison, but 1) they are transient (only alive while sorting this one segment) and 2) in the typical index sorting case, they are only used to sort newly flushed segments, which will be smaller than merged segments- Parameters:
reader- the Reader to sortmaxDoc- the number of documents in the Reader- Throws:
IOException
-
getProviderName
String getProviderName()
The SPI-registered name of aSortFieldProviderthat will deserialize the parent SortField
-
-