7#ifndef FIELDCOMPARATOR_H
8#define FIELDCOMPARATOR_H
53 virtual int32_t
compare(int32_t slot1, int32_t slot2) = 0;
75 virtual void copy(int32_t slot, int32_t doc) = 0;
90 virtual ComparableValue
value(int32_t slot) = 0;
93template <
typename TYPE>
112 virtual int32_t
compare(int32_t slot1, int32_t slot2) {
120 virtual void copy(int32_t slot, int32_t doc) {
128 virtual ComparableValue
value(int32_t slot) {
129 return ComparableValue(
values[slot]);
161 virtual void copy(int32_t slot, int32_t doc);
177 virtual int32_t
compare(int32_t slot1, int32_t slot2);
194 virtual int32_t
compare(int32_t slot1, int32_t slot2);
211 virtual int32_t
compare(int32_t slot1, int32_t slot2);
230 virtual int32_t
compare(int32_t slot1, int32_t slot2);
232 virtual void copy(int32_t slot, int32_t doc);
253 virtual int32_t
compare(int32_t slot1, int32_t slot2);
255 virtual void copy(int32_t slot, int32_t doc);
258 virtual ComparableValue
value(int32_t slot);
290 virtual int32_t
compare(int32_t slot1, int32_t slot2);
292 virtual void copy(int32_t slot, int32_t doc);
295 virtual ComparableValue
value(int32_t slot);
321 virtual int32_t
compare(int32_t slot1, int32_t slot2);
323 virtual void copy(int32_t slot, int32_t doc);
326 virtual ComparableValue
value(int32_t slot);
#define LUCENE_CLASS(Name)
Definition LuceneObject.h:24
Parses field's values as byte (using FieldCache#getBytes and sorts by ascending value.
Definition FieldComparator.h:134
virtual void setNextReader(const IndexReaderPtr &reader, int32_t docBase)
Set a new Reader. All doc correspond to the current Reader.
ByteComparator(int32_t numHits, const String &field, const ParserPtr &parser)
virtual ~ByteComparator()
ByteParserPtr parser
Definition FieldComparator.h:142
Utility template class to handle collections that can be safely copied and shared.
Definition Collection.h:17
static this_type newInstance(int32_t size=0)
Definition Collection.h:33
Sorts by ascending docID.
Definition FieldComparator.h:149
virtual void copy(int32_t slot, int32_t doc)
This method is called when a new hit is competitive. You should copy any state associated with this d...
virtual void setNextReader(const IndexReaderPtr &reader, int32_t docBase)
Set a new Reader. All doc correspond to the current Reader.
int32_t docBase
Definition FieldComparator.h:157
DocComparator(int32_t numHits)
virtual int32_t compareBottom(int32_t doc)
Compare the bottom of the queue with doc. This will only invoked after setBottom has been called....
Parses field's values as double (using FieldCache#getDoubles and sorts by ascending value.
Definition FieldComparator.h:166
DoubleComparator(int32_t numHits, const String &field, const ParserPtr &parser)
virtual int32_t compare(int32_t slot1, int32_t slot2)
Compare hit at slot1 with hit at slot2.
virtual ~DoubleComparator()
DoubleParserPtr parser
Definition FieldComparator.h:174
virtual int32_t compareBottom(int32_t doc)
Compare the bottom of the queue with doc. This will only invoked after setBottom has been called....
virtual void setNextReader(const IndexReaderPtr &reader, int32_t docBase)
Set a new Reader. All doc correspond to the current Reader.
A FieldComparator compares hits so as to determine their sort order when collecting the top results w...
Definition FieldComparator.h:42
virtual ~FieldComparator()
virtual void setScorer(const ScorerPtr &scorer)
Sets the Scorer to use in case a document's score is needed.
virtual int32_t compareBottom(int32_t doc)=0
Compare the bottom of the queue with doc. This will only invoked after setBottom has been called....
virtual void copy(int32_t slot, int32_t doc)=0
This method is called when a new hit is competitive. You should copy any state associated with this d...
virtual void setBottom(int32_t slot)=0
Set the bottom slot, ie the "weakest" (sorted last) entry in the queue. When compareBottom is called,...
virtual ComparableValue value(int32_t slot)=0
Return the actual value in the slot.
virtual void setNextReader(const IndexReaderPtr &reader, int32_t docBase)=0
Set a new Reader. All doc correspond to the current Reader.
virtual int32_t compare(int32_t slot1, int32_t slot2)=0
Compare hit at slot1 with hit at slot2.
Parses field's values as int (using FieldCache#getInts and sorts by ascending value.
Definition FieldComparator.h:183
IntParserPtr parser
Definition FieldComparator.h:191
IntComparator(int32_t numHits, const String &field, const ParserPtr &parser)
virtual void setNextReader(const IndexReaderPtr &reader, int32_t docBase)
Set a new Reader. All doc correspond to the current Reader.
virtual int32_t compare(int32_t slot1, int32_t slot2)
Compare hit at slot1 with hit at slot2.
virtual int32_t compareBottom(int32_t doc)
Compare the bottom of the queue with doc. This will only invoked after setBottom has been called....
Parses field's values as long (using FieldCache#getLongs and sorts by ascending value.
Definition FieldComparator.h:200
LongParserPtr parser
Definition FieldComparator.h:208
virtual ~LongComparator()
virtual int32_t compareBottom(int32_t doc)
Compare the bottom of the queue with doc. This will only invoked after setBottom has been called....
virtual int32_t compare(int32_t slot1, int32_t slot2)
Compare hit at slot1 with hit at slot2.
LongComparator(int32_t numHits, const String &field, const ParserPtr &parser)
virtual void setNextReader(const IndexReaderPtr &reader, int32_t docBase)
Set a new Reader. All doc correspond to the current Reader.
Base class for all Lucene classes.
Definition LuceneObject.h:31
Definition FieldComparator.h:94
Collection< TYPE > values
Definition FieldComparator.h:106
virtual int32_t compare(int32_t slot1, int32_t slot2)
Compare hit at slot1 with hit at slot2.
Definition FieldComparator.h:112
NumericComparator(int32_t numHits, const String &field=EmptyString)
Definition FieldComparator.h:96
virtual ~NumericComparator()
Definition FieldComparator.h:102
virtual void copy(int32_t slot, int32_t doc)
This method is called when a new hit is competitive. You should copy any state associated with this d...
Definition FieldComparator.h:120
virtual void setBottom(int32_t slot)
Set the bottom slot, ie the "weakest" (sorted last) entry in the queue. When compareBottom is called,...
Definition FieldComparator.h:124
Collection< TYPE > currentReaderValues
Definition FieldComparator.h:107
virtual ComparableValue value(int32_t slot)
Return the actual value in the slot.
Definition FieldComparator.h:128
virtual int32_t compareBottom(int32_t doc)
Compare the bottom of the queue with doc. This will only invoked after setBottom has been called....
Definition FieldComparator.h:116
TYPE bottom
Definition FieldComparator.h:109
String field
Definition FieldComparator.h:108
Sorts by descending relevance. NOTE: if you are sorting only by descending relevance and then seconda...
Definition FieldComparator.h:219
virtual void setNextReader(const IndexReaderPtr &reader, int32_t docBase)
Set a new Reader. All doc correspond to the current Reader.
ScorerPtr scorer
Definition FieldComparator.h:227
virtual void setScorer(const ScorerPtr &scorer)
Sets the Scorer to use in case a document's score is needed.
virtual void copy(int32_t slot, int32_t doc)
This method is called when a new hit is competitive. You should copy any state associated with this d...
RelevanceComparator(int32_t numHits)
virtual int32_t compareBottom(int32_t doc)
Compare the bottom of the queue with doc. This will only invoked after setBottom has been called....
virtual ~RelevanceComparator()
virtual int32_t compare(int32_t slot1, int32_t slot2)
Compare hit at slot1 with hit at slot2.
Sorts by a field's value using the Collator for a given Locale.
Definition FieldComparator.h:238
virtual void setNextReader(const IndexReaderPtr &reader, int32_t docBase)
Set a new Reader. All doc correspond to the current Reader.
virtual void setBottom(int32_t slot)
Set the bottom slot, ie the "weakest" (sorted last) entry in the queue. When compareBottom is called,...
virtual int32_t compareBottom(int32_t doc)
Compare the bottom of the queue with doc. This will only invoked after setBottom has been called....
String bottom
Definition FieldComparator.h:250
virtual ComparableValue value(int32_t slot)
Return the actual value in the slot.
String field
Definition FieldComparator.h:248
CollatorPtr collator
Definition FieldComparator.h:249
virtual ~StringComparatorLocale()
Collection< String > values
Definition FieldComparator.h:246
Collection< String > currentReaderValues
Definition FieldComparator.h:247
virtual int32_t compare(int32_t slot1, int32_t slot2)
Compare hit at slot1 with hit at slot2.
virtual void copy(int32_t slot, int32_t doc)
This method is called when a new hit is competitive. You should copy any state associated with this d...
StringComparatorLocale(int32_t numHits, const String &field, const std::locale &locale)
Sorts by field's natural String sort order, using ordinals. This is functionally equivalent to String...
Definition FieldComparator.h:266
virtual int32_t compare(int32_t slot1, int32_t slot2)
Compare hit at slot1 with hit at slot2.
int32_t binarySearch(Collection< String > lookup, const String &key, int32_t low, int32_t high)
int32_t sortPos
Definition FieldComparator.h:287
virtual void copy(int32_t slot, int32_t doc)
This method is called when a new hit is competitive. You should copy any state associated with this d...
virtual int32_t getBottomSlot()
virtual Collection< String > getValues()
virtual void setNextReader(const IndexReaderPtr &reader, int32_t docBase)
Set a new Reader. All doc correspond to the current Reader.
bool reversed
Definition FieldComparator.h:286
Collection< int32_t > order
Definition FieldComparator.h:280
Collection< String > lookup
Definition FieldComparator.h:279
String field
Definition FieldComparator.h:281
void convert(int32_t slot)
String bottomValue
Definition FieldComparator.h:285
virtual ~StringOrdValComparator()
StringOrdValComparator(int32_t numHits, const String &field, int32_t sortPos, bool reversed)
virtual void setBottom(int32_t slot)
Set the bottom slot, ie the "weakest" (sorted last) entry in the queue. When compareBottom is called,...
Collection< String > values
Definition FieldComparator.h:275
int32_t bottomSlot
Definition FieldComparator.h:283
virtual ComparableValue value(int32_t slot)
Return the actual value in the slot.
int32_t bottomOrd
Definition FieldComparator.h:284
virtual int32_t compareBottom(int32_t doc)
Compare the bottom of the queue with doc. This will only invoked after setBottom has been called....
Collection< int32_t > ords
Definition FieldComparator.h:274
Collection< int32_t > readerGen
Definition FieldComparator.h:276
virtual String getField()
int32_t currentReaderGen
Definition FieldComparator.h:278
Sorts by field's natural String sort order. All comparisons are done using String....
Definition FieldComparator.h:307
virtual void setBottom(int32_t slot)
Set the bottom slot, ie the "weakest" (sorted last) entry in the queue. When compareBottom is called,...
String bottom
Definition FieldComparator.h:318
virtual ComparableValue value(int32_t slot)
Return the actual value in the slot.
virtual int32_t compare(int32_t slot1, int32_t slot2)
Compare hit at slot1 with hit at slot2.
virtual void setNextReader(const IndexReaderPtr &reader, int32_t docBase)
Set a new Reader. All doc correspond to the current Reader.
virtual ~StringValComparator()
Collection< String > currentReaderValues
Definition FieldComparator.h:316
virtual int32_t compareBottom(int32_t doc)
Compare the bottom of the queue with doc. This will only invoked after setBottom has been called....
virtual void copy(int32_t slot, int32_t doc)
This method is called when a new hit is competitive. You should copy any state associated with this d...
StringValComparator(int32_t numHits, const String &field)
Collection< String > values
Definition FieldComparator.h:315
String field
Definition FieldComparator.h:317
Definition AbstractAllTermDocs.h:12
boost::shared_ptr< LongParser > LongParserPtr
Definition LuceneTypes.h:378
boost::shared_ptr< ByteParser > ByteParserPtr
Definition LuceneTypes.h:289
boost::shared_ptr< IntParser > IntParserPtr
Definition LuceneTypes.h:376
boost::shared_ptr< DoubleParser > DoubleParserPtr
Definition LuceneTypes.h:328
boost::shared_ptr< Parser > ParserPtr
Definition LuceneTypes.h:401
boost::shared_ptr< Collator > CollatorPtr
Definition LuceneTypes.h:525
boost::shared_ptr< IndexReader > IndexReaderPtr
Definition LuceneTypes.h:157
boost::shared_ptr< Scorer > ScorerPtr
Definition LuceneTypes.h:429