xapian-core  2.0.0
Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
Xapian::MSetIterator Class Reference

Iterator over a Xapian::MSet. More...

#include <mset.h>

+ Collaboration diagram for Xapian::MSetIterator:

Public Member Functions

 MSetIterator ()
 Create an unpositioned MSetIterator. More...
 
Xapian::docid operator* () const
 Get the numeric document id for the current position. More...
 
MSetIteratoroperator++ ()
 Advance the iterator to the next position. More...
 
MSetIterator operator++ (int)
 Advance the iterator to the next position (postfix version). More...
 
MSetIteratoroperator-- ()
 Move the iterator to the previous position. More...
 
MSetIterator operator-- (int)
 Move the iterator to the previous position (postfix version). More...
 
MSetIteratoroperator+= (difference_type n)
 Move the iterator forwards by n positions. More...
 
MSetIteratoroperator-= (difference_type n)
 Move the iterator back by n positions. More...
 
MSetIterator operator+ (difference_type n) const
 Return the iterator incremented by n positions. More...
 
MSetIterator operator- (difference_type n) const
 Return the iterator decremented by n positions. More...
 
difference_type operator- (const MSetIterator &o) const
 Return the number of positions between o and this iterator. More...
 
Xapian::doccount get_rank () const
 Return the MSet rank for the current position. More...
 
Xapian::Document get_document () const
 Get the Document object for the current position. More...
 
double get_weight () const
 Get the weight for the current position. More...
 
std::string get_collapse_key () const
 Return the collapse key for the current position. More...
 
Xapian::doccount get_collapse_count () const
 Return a count of the number of collapses done onto the current key. More...
 
std::string get_sort_key () const
 Return the sort key for the current position. More...
 
int get_percent () const
 Convert the weight of the current iterator position to a percentage. More...
 
std::string get_description () const
 Return a string describing this object. More...
 

Private Types

typedef std::random_access_iterator_tag iterator_category
 
typedef Xapian::docid value_type
 
typedef Xapian::termcount_diff difference_type
 
typedef value_typepointer
 
typedef value_type reference
 

Private Member Functions

 MSetIterator (const Xapian::MSet &mset_, Xapian::doccount off_from_end_)
 

Private Attributes

Xapian::MSet mset
 
Xapian::MSet::size_type off_from_end
 

Friends

class MSet
 

Detailed Description

Iterator over a Xapian::MSet.

Definition at line 535 of file mset.h.

Member Typedef Documentation

◆ difference_type

Definition at line 600 of file mset.h.

◆ iterator_category

typedef std::random_access_iterator_tag Xapian::MSetIterator::iterator_category
private

MSetIterator is what the C++ STL calls an random_access_iterator.

The following typedefs allow std::iterator_traits<> to work so that this iterator can be used with the STL.

These are deliberately hidden from the Doxygen-generated docs, as the machinery here isn't interesting to API users. They just need to know that Xapian iterator classes are compatible with the STL.

Definition at line 596 of file mset.h.

◆ pointer

Definition at line 602 of file mset.h.

◆ reference

Definition at line 604 of file mset.h.

◆ value_type

Definition at line 598 of file mset.h.

Constructor & Destructor Documentation

◆ MSetIterator() [1/2]

Xapian::MSetIterator::MSetIterator ( const Xapian::MSet mset_,
Xapian::doccount  off_from_end_ 
)
inlineprivate

Definition at line 538 of file mset.h.

◆ MSetIterator() [2/2]

Xapian::MSetIterator::MSetIterator ( )
inline

Create an unpositioned MSetIterator.

Definition at line 553 of file mset.h.

Member Function Documentation

◆ get_collapse_count()

Xapian::doccount Xapian::MSetIterator::get_collapse_count ( ) const

Return a count of the number of collapses done onto the current key.

This starts at 0, and is incremented each time an item is eliminated because its key is the same as that of the current item (as returned by get_collapse_key()).

Note that this is NOT necessarily one less than the total number of matching documents with this collapse key due to various optimisations implemented in the matcher - for example, it can skip documents completely if it can prove their weight wouldn't be enough to make the result set.

You can say is that if get_collapse_count() > 0 then there are >= get_collapse_count() other documents with the current collapse key. But if get_collapse_count() == 0 then there may or may not be other such documents.

Definition at line 73 of file msetiterator.cc.

References Assert, AssertRel, LOGCALL, and RETURN.

◆ get_collapse_key()

string Xapian::MSetIterator::get_collapse_key ( ) const

Return the collapse key for the current position.

If collapsing isn't in use, an empty string will be returned.

Definition at line 64 of file msetiterator.cc.

References Assert, AssertRel, LOGCALL, and RETURN.

◆ get_description()

std::string Xapian::MSetIterator::get_description ( ) const

Return a string describing this object.

Definition at line 91 of file msetiterator.cc.

References Xapian::Internal::str().

Referenced by DEFINE_TESTCASE().

◆ get_document()

Xapian::Document Xapian::MSetIterator::get_document ( ) const

Get the Document object for the current position.

Definition at line 45 of file msetiterator.cc.

References Assert, AssertRel, LOGCALL, and RETURN.

Referenced by DEFINE_TESTCASE().

◆ get_percent()

int Xapian::MSetIterator::get_percent ( ) const
inline

Convert the weight of the current iterator position to a percentage.

If the weighting scheme gives everything zero weight (like Xapian::BoolWeight does) then all results will score 100%.

Otherwise the percentage is calculated as a linear scaling of the relevance weight, with the scale factor determined by the matching document with the highest weight. This result scores 100% if it matches all the weighted query terms, and proportionally less if it only matches some.

The returned percentage is an integer. If the calculated percentage before rounding is non-zero but less than 1% it is rounded up to 1% so that a result scoring 0% means it has zero weight.

Similarly, percentages over 99% but less than 100% are always rounded down, so a result scoring 100% means it matches all weighted query terms.

Note that these generally aren't percentages of anything meaningful (unless you use a custom weighting formula where they are!) but like the weights they are based on, higher values should indicate more relevant results.

Definition at line 711 of file mset.h.

References Xapian::MSet::convert_to_percent().

Referenced by DEFINE_TESTCASE().

◆ get_rank()

Xapian::doccount Xapian::MSetIterator::get_rank ( ) const
inline

Return the MSet rank for the current position.

The rank of mset[0] is mset.get_firstitem().

Definition at line 644 of file mset.h.

References Xapian::MSet::get_firstitem(), and Xapian::MSet::size().

◆ get_sort_key()

string Xapian::MSetIterator::get_sort_key ( ) const

Return the sort key for the current position.

If sorting didn't use a key then an empty string will be returned.

Since
Added in Xapian 1.4.6.

Definition at line 82 of file msetiterator.cc.

References Assert, AssertRel, LOGCALL, and RETURN.

◆ get_weight()

double Xapian::MSetIterator::get_weight ( ) const

Get the weight for the current position.

Definition at line 55 of file msetiterator.cc.

References Assert, AssertRel, LOGCALL, and RETURN.

Referenced by Xapian::MSet::convert_to_percent(), DEFINE_TESTCASE(), mset_range_is_same(), mset_range_is_same_weights(), and print_mset_weights().

◆ operator*()

Xapian::docid Xapian::MSetIterator::operator* ( ) const

Get the numeric document id for the current position.

Definition at line 36 of file msetiterator.cc.

References Assert, AssertRel, LOGCALL, and RETURN.

◆ operator+()

MSetIterator Xapian::MSetIterator::operator+ ( difference_type  n) const
inline

Return the iterator incremented by n positions.

If n is negative, decrements by (-n) positions.

Definition at line 623 of file mset.h.

◆ operator++() [1/2]

MSetIterator& Xapian::MSetIterator::operator++ ( )
inline

Advance the iterator to the next position.

Definition at line 559 of file mset.h.

◆ operator++() [2/2]

MSetIterator Xapian::MSetIterator::operator++ ( int  )
inline

Advance the iterator to the next position (postfix version).

Definition at line 565 of file mset.h.

◆ operator+=()

MSetIterator& Xapian::MSetIterator::operator+= ( difference_type  n)
inline

Move the iterator forwards by n positions.

Definition at line 608 of file mset.h.

◆ operator-() [1/2]

difference_type Xapian::MSetIterator::operator- ( const MSetIterator o) const
inline

Return the number of positions between o and this iterator.

Definition at line 636 of file mset.h.

References off_from_end.

◆ operator-() [2/2]

MSetIterator Xapian::MSetIterator::operator- ( difference_type  n) const
inline

Return the iterator decremented by n positions.

If n is negative, increments by (-n) positions.

Definition at line 631 of file mset.h.

◆ operator--() [1/2]

MSetIterator& Xapian::MSetIterator::operator-- ( )
inline

Move the iterator to the previous position.

Definition at line 572 of file mset.h.

◆ operator--() [2/2]

MSetIterator Xapian::MSetIterator::operator-- ( int  )
inline

Move the iterator to the previous position (postfix version).

Definition at line 578 of file mset.h.

◆ operator-=()

MSetIterator& Xapian::MSetIterator::operator-= ( difference_type  n)
inline

Move the iterator back by n positions.

Definition at line 614 of file mset.h.

Friends And Related Function Documentation

◆ MSet

friend class MSet
friend

Definition at line 536 of file mset.h.

Member Data Documentation

◆ mset

Xapian::MSet Xapian::MSetIterator::mset
private

The MSet we are iterating over.

Definition at line 543 of file mset.h.

Referenced by Xapian::iterator_rewind(), and Xapian::iterator_rewound().

◆ off_from_end

Xapian::MSet::size_type Xapian::MSetIterator::off_from_end
private

The current position of the iterator.

We store the offset from the end of mset, since that means MSet::end() just needs to set this member to 0.

Definition at line 550 of file mset.h.

Referenced by Xapian::MSet::fetch(), Xapian::iterator_rewind(), Xapian::iterator_rewound(), Xapian::iterator_valid(), and operator-().


The documentation for this class was generated from the following files: