xapian-core  2.0.0
documenttermlist.cc
Go to the documentation of this file.
1 
4 /* Copyright 2017,2024 Olly Betts
5  *
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.
10  *
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.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, see
18  * <https://www.gnu.org/licenses/>.
19  */
20 
21 #include <config.h>
22 
23 #include "documenttermlist.h"
24 
26 #include "omassert.h"
27 
28 #include "xapian/error.h"
29 
30 using namespace std;
31 
34 {
35  // DocumentTermList is only used in a TermIterator wrapper and that never
36  // calls this method.
37  Assert(false);
38  return 0;
39 }
40 
43 {
44  Assert(it != doc->terms->end());
45  return it->second.get_wdf();
46 }
47 
50 {
51  throw Xapian::InvalidOperationError("get_termfreq() not valid for a TermIterator from a Document which is not associated with a database");
52 }
53 
56 {
57  return it->second.get_positions();
58 }
59 
62 {
63  return new InMemoryPositionList(*it->second.get_positions());
64 }
65 
68 {
69  return it->second.count_positions();
70 }
71 
72 TermList*
74 {
75  if (it == doc->terms->end()) {
76  it = doc->terms->begin();
77  } else {
78  ++it;
79  }
80  while (it != doc->terms->end() && it->second.is_deleted()) {
81  ++it;
82  }
83  if (it == doc->terms->end()) {
84  return this;
85  }
86  current_term = it->first;
87  return NULL;
88 }
89 
90 TermList*
92 {
93  it = doc->terms->lower_bound(term);
94  while (it != doc->terms->end() && it->second.is_deleted()) {
95  ++it;
96  }
97  if (it == doc->terms->end()) {
98  return this;
99  }
100  current_term = it->first;
101  return NULL;
102 }
const Xapian::VecCOW< Xapian::termpos > * get_vec_termpos() const
Get pointer to VecCOW<termpos> if that's the internal representation.
Xapian::doccount get_termfreq() const
Return the term frequency for the term at the current position.
TermList * skip_to(std::string_view term)
Skip forward to the specified term.
Xapian::termcount positionlist_count() const
Return the length of the position list for the current position.
PositionList * positionlist_begin() const
Return PositionList for the current position.
TermList * next()
Advance the current position to the next term in the termlist.
Xapian::termcount get_approx_size() const
Return approximate size of this termlist.
Xapian::termcount get_wdf() const
Return the wdf for the term at the current position.
PositionList from an InMemory DB or a Document object.
InvalidOperationError indicates the API was used in an invalid way.
Definition: error.h:271
Abstract base class for iterating term positions in a document.
Definition: positionlist.h:32
Abstract base class for termlists.
Definition: termlist.h:42
Suitable for "simple" type T.
Definition: smallvector.h:62
string term
Iteration over terms in a document.
Hierarchy of classes which Xapian can throw as exceptions.
PositionList from an InMemory DB or a Document object.
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
Definition: types.h:64
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
Definition: types.h:37
Various assertion macros.
#define Assert(COND)
Definition: omassert.h:122