public abstract class SortComparator extends Object implements SortComparatorSource
This class should only be used if the other SortField types (SCORE, DOC, STRING, INT, FLOAT) do not provide an adequate sorting. It maintains an internal cache of values which could be quite large. The cache is an array of Comparable, one for each document in the index. There is a distinct Comparable for each unique term in the field - if some documents have the same term in the field, the cache array will have entries which reference the same Comparable.
Created: Apr 21, 2004 5:08:38 PM
|Constructor and Description|
|Modifier and Type||Method and Description|
Returns an object which, when sorted according to natural order, will order the Term values in the correct order.
Creates a comparator for the field in the given index.
public ScoreDocComparator newComparator(IndexReader reader, String fieldname) throws IOException
reader- Index to create comparator for.
fieldname- Field to create comparator for.
IOException- If an error occurs reading the index.
protected abstract Comparable getComparable(String termtext)
For example, if the Terms contained integer values, this method
new Integer(termtext). Note that this
might not always be the most efficient implementation - for this
particular example, a better implementation might be to make a
ScoreDocLookupComparator that uses an internal lookup table of int.
termtext- The textual value of the term.
termtextthat sorts according to the natural order of
Copyright © 2023 GATE. All rights reserved.