Expert: a FieldComparator compares hits so as to determine their
sort order when collecting the top results with {@link
TopFieldCollector}. The concrete public FieldComparator
classes here correspond to the SortField types.
This API is designed to achieve high performance
sorting, by exposing a tight interaction with {@link
FieldValueHitQueue} as it visits hits. Whenever a hit is
competitive, it's enrolled into a virtual slot, which is
an int ranging from 0 to numHits-1. The {@link
FieldComparator} is made aware of segment transitions
during searching in case any internal state it's tracking
needs to be recomputed during these transitions.A comparator must define these functions:
- {@link #compare} Compare a hit at 'slot a' with hit 'slot b'.
- {@link #setBottom} This method is called by {@link FieldValueHitQueue} to notify the FieldComparator of the current weakest ("bottom") slot. Note that this slot may not hold the weakest value according to your comparator, in cases where your comparator is not the primary one (ie, is only used to break ties from the comparators before it).
- {@link #compareBottom} Compare a new hit (docID) against the "weakest" (bottom) entry in the queue.
- {@link #copy} Installs a new hit into the priority queue. The {@link FieldValueHitQueue} calls this method when a new hit is competitive.
- {@link #setNextReader} Invoked when the search is switching to the next segment. You may need to update internal state of the comparator, for example retrieving new values from the {@link FieldCache}.
- {@link #value} Return the sort value stored in the specified slot. This is only called at the end of the search, in order to populate {@link FieldDoc#fields} when returning the top results.
The FieldComparator..::..StringOrdValComparator type exposes the following members.
Constructors
Name | Description | |
---|---|---|
FieldComparator..::..StringOrdValComparator | Initializes a new instance of the FieldComparator..::..StringOrdValComparator class |
Methods
Name | Description | |
---|---|---|
Compare | (Overrides FieldComparator..::..Compare(Int32, Int32).) | |
CompareBottom | (Overrides FieldComparator..::..CompareBottom(Int32).) | |
Copy | (Overrides FieldComparator..::..Copy(Int32, Int32).) | |
Equals | (Inherited from Object.) | |
Finalize | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.) | |
GetBottomSlot | ||
GetField | ||
GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
GetValues | ||
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
SetBottom | (Overrides FieldComparator..::..SetBottom(Int32).) | |
SetNextReader | (Overrides FieldComparator..::..SetNextReader(IndexReader, Int32).) | |
SetScorer | Sets the Scorer to use in case a document's score is
needed.
(Inherited from FieldComparator.) | |
ToString | (Inherited from Object.) | |
Value | (Overrides FieldComparator..::..Value(Int32).) |