|
xapian-core
2.0.0
|
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... | |
| MSetIterator & | operator++ () |
| Advance the iterator to the next position. More... | |
| MSetIterator | operator++ (int) |
| Advance the iterator to the next position (postfix version). More... | |
| MSetIterator & | operator-- () |
| Move the iterator to the previous position. More... | |
| MSetIterator | operator-- (int) |
| Move the iterator to the previous position (postfix version). More... | |
| MSetIterator & | operator+= (difference_type n) |
| Move the iterator forwards by n positions. More... | |
| MSetIterator & | operator-= (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_type * | pointer |
| 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 |
Iterator over a Xapian::MSet.
|
private |
|
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.
|
private |
|
private |
|
private |
|
inlineprivate |
|
inline |
Create an unpositioned MSetIterator.
| 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.
| string Xapian::MSetIterator::get_collapse_key | ( | ) | const |
| 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().
| 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().
|
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().
|
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().
| string Xapian::MSetIterator::get_sort_key | ( | ) | const |
| 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().
| Xapian::docid Xapian::MSetIterator::operator* | ( | ) | const |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Return the number of positions between o and this iterator.
Definition at line 636 of file mset.h.
References off_from_end.
|
inline |
|
inline |
|
inline |
|
inline |
|
private |
The MSet we are iterating over.
Definition at line 543 of file mset.h.
Referenced by Xapian::iterator_rewind(), and Xapian::iterator_rewound().
|
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-().