C# 클래스 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.

파일 보기 프로젝트 열기: synhershko/lucene.net 1 사용 예제들

공개 메소드들

메소드 설명
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.

보호된 메소드들

메소드 설명
BinarySearch ( System a, System key ) : int
BinarySearch ( System a, System key, int low, int high ) : int

메소드 상세

BinarySearch() 보호된 정적인 메소드

protected static BinarySearch ( System a, System key ) : int
a System
key System
리턴 int

BinarySearch() 보호된 정적인 메소드

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

Compare() 공개 추상적인 메소드

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 ///
리턴 int

CompareBottom() 공개 추상적인 메소드

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 ///
리턴 int

Copy() 공개 추상적인 메소드

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 ///
리턴 void

SetBottom() 공개 추상적인 메소드

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 ///
리턴 void

SetNextReader() 공개 추상적인 메소드

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 ///
리턴 void

SetScorer() 공개 메소드

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. ///
리턴 void

this() 공개 추상적인 메소드

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