C# Class Lucene.Net.Search.FieldComparator

Expert: a FieldComparator compares hits so as to determine their sort order when collecting the top results with 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 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 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:

Compare Compare a hit at 'slot a' with hit 'slot b'. SetBottom This method is called by 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). CompareBottom Compare a new hit (docID) against the "weakest" (bottom) entry in the queue. Copy Installs a new hit into the priority queue. The FieldValueHitQueue calls this method when a new hit is competitive. 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 FieldCache. Value Return the sort value stored in the specified slot. This is only called at the end of the search, in order to populate FieldDoc.fields when returning the top results. NOTE: This API is experimental and might change in incompatible ways in the next release.

Mostra file Open project: synhershko/lucene.net Class Usage Examples

Public Methods

Method Description
Compare ( int slot1, int slot2 ) : int

Compare hit at slot1 with hit at slot2.

CompareBottom ( int doc ) : int

Compare the bottom of the queue with doc. This will only invoked after setBottom has been called. This should return the same result as Compare(int,int) } as if bottom were slot1 and the new document were slot 2.

For a search that hits many results, this method will be the hotspot (invoked by far the most frequently).

Copy ( int slot, int doc ) : void

This method is called when a new hit is competitive. You should copy any state associated with this document that will be required for future comparisons, into the specified slot.

SetBottom ( int slot ) : void

Set the bottom slot, ie the "weakest" (sorted last) entry in the queue. When CompareBottom is called, you should compare against this slot. This will always be called before CompareBottom.

SetNextReader ( Lucene.Net.Index.IndexReader reader, int docBase ) : void

Set a new Reader. All doc correspond to the current Reader.

SetScorer ( Lucene.Net.Search.Scorer scorer ) : void

Sets the Scorer to use in case a document's score is needed.

this ( int slot ) : IComparable

Return the actual value in the slot.

Protected Methods

Method Description
BinarySearch ( System a, System key ) : int
BinarySearch ( System a, System key, int low, int high ) : int

Method Details

BinarySearch() protected static method

protected static BinarySearch ( System a, System key ) : int
a System
key System
return int

BinarySearch() protected static method

protected static BinarySearch ( System a, System key, int low, int high ) : int
a System
key System
low int
high int
return int

Compare() public abstract method

Compare hit at slot1 with hit at slot2.
public abstract Compare ( int slot1, int slot2 ) : int
slot1 int first slot to compare ///
slot2 int second slot to compare ///
return int

CompareBottom() public abstract method

Compare the bottom of the queue with doc. This will only invoked after setBottom has been called. This should return the same result as Compare(int,int) } as if bottom were slot1 and the new document were slot 2.

For a search that hits many results, this method will be the hotspot (invoked by far the most frequently).

public abstract CompareBottom ( int doc ) : int
doc int that was hit ///
return int

Copy() public abstract method

This method is called when a new hit is competitive. You should copy any state associated with this document that will be required for future comparisons, into the specified slot.
public abstract Copy ( int slot, int doc ) : void
slot int which slot to copy the hit to ///
doc int docID relative to current reader ///
return void

SetBottom() public abstract method

Set the bottom slot, ie the "weakest" (sorted last) entry in the queue. When CompareBottom is called, you should compare against this slot. This will always be called before CompareBottom.
public abstract SetBottom ( int slot ) : void
slot int the currently weakest (sorted last) slot in the queue ///
return void

SetNextReader() public abstract method

Set a new Reader. All doc correspond to the current Reader.
public abstract SetNextReader ( Lucene.Net.Index.IndexReader reader, int docBase ) : void
reader Lucene.Net.Index.IndexReader current reader ///
docBase int docBase of this reader ///
return void

SetScorer() public method

Sets the Scorer to use in case a document's score is needed.
public SetScorer ( Lucene.Net.Search.Scorer scorer ) : void
scorer Lucene.Net.Search.Scorer Scorer instance that you should use to /// obtain the current hit's score, if necessary. ///
return void

this() public abstract method

Return the actual value in the slot.
public abstract this ( int slot ) : IComparable
slot int the value ///
return IComparable