Package org.apache.lucene.index
Interface IndexSorter.ComparableValues
- Enclosing interface:
IndexSorter
public static interface IndexSorter.ComparableValues
Caches the sort value of the current document of every segment being merged, and compares them.
This is the merge-sort counterpart of IndexSorter.DocComparator. Most sorts reduce a document to
a single sortable long and should implement IndexSorter.getComparableProviders(List)
instead; the fromComparableProviders(org.apache.lucene.index.IndexSorter.ComparableProvider[]) adapter exposes them through this interface with
no change in behaviour. Sorts whose value cannot be represented as a long (for example
raw bytes) implement IndexSorter.getComparableValues(List) directly.
-
Method Summary
Modifier and TypeMethodDescriptionintcompare(int readerIndexA, int readerIndexB) Compares the values previously read bysetTopValue(int, int)for the two segments.static IndexSorter.ComparableValuesfromComparableProviders(IndexSorter.ComparableProvider[] providers) Adapts an array ofIndexSorter.ComparableProvider(one per segment) toIndexSorter.ComparableValuesvoidsetTopValue(int readerIndex, int docID) Reads the value of the current document of the given segment so that it can later be compared bycompare(int, int).
-
Method Details
-
setTopValue
Reads the value of the current document of the given segment so that it can later be compared bycompare(int, int).The merge sort visits the documents of each segment in increasing docID order, so
docIDis non-decreasing for a givenreaderIndexbetween consecutive calls.- Parameters:
readerIndex- the index of the segment in the list passed toIndexSorter.getComparableValues(List)docID- the document whose value should be read- Throws:
IOException
-
compare
int compare(int readerIndexA, int readerIndexB) Compares the values previously read bysetTopValue(int, int)for the two segments. The returned value follows the same contract asComparator.compare(Object, Object), without applying thereverseflag (the caller is responsible for that). -
fromComparableProviders
static IndexSorter.ComparableValues fromComparableProviders(IndexSorter.ComparableProvider[] providers) Adapts an array ofIndexSorter.ComparableProvider(one per segment) toIndexSorter.ComparableValues
-