1 /** @file documenttermlist.cc
2 * @brief Iteration over terms in a document
4 /* Copyright 2017 Olly Betts
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #include "documenttermlist.h"
25 #include "backends/inmemory/inmemory_positionlist.h"
28 #include "xapian/error.h"
33 DocumentTermList::get_approx_size() const
35 // DocumentTermList is only used in a TermIterator wrapper and that never
42 DocumentTermList::get_termname() const
49 DocumentTermList::get_wdf() const
52 return it
->second
.get_wdf();
56 DocumentTermList::get_termfreq() const
58 throw Xapian::InvalidOperationError("get_termfreq() not valid for a TermIterator from a Document which is not associated with a database");
61 const Xapian::VecCOW
<Xapian::termpos
>*
62 DocumentTermList::get_vec_termpos() const
64 return it
->second
.get_positions();
68 DocumentTermList::positionlist_begin() const
70 return new InMemoryPositionList(*it
->second
.get_positions());
74 DocumentTermList::positionlist_count() const
76 return it
->second
.get_positions()->size();
80 DocumentTermList::next()
82 if (it
== doc
->terms
->end()) {
83 it
= doc
->terms
->begin();
87 while (it
!= doc
->terms
->end() && it
->second
.is_deleted()) {
94 DocumentTermList::skip_to(const string
& term
)
96 it
= doc
->terms
->lower_bound(term
);
97 while (it
!= doc
->terms
->end() && it
->second
.is_deleted()) {
104 DocumentTermList::at_end() const
106 return it
== doc
->terms
->end();