summaryrefslogtreecommitdiff
path: root/rep/ept/textsearch/textsearch.cc.gcov.html
blob: b1cdfba3c0b0e635f8f6d050f1f8e12dd099af12 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  <title>LCOV - lcov.info - ept/textsearch/textsearch.cc</title>
  <link rel="stylesheet" type="text/css" href="../../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LTP GCOV extension - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
        <tr>
          <td class="headerItem" width="20%">Current&nbsp;view:</td>
          <td class="headerValue" width="80%" colspan=4><a href="../../index.html">directory</a> - <a href="index.html">ept/textsearch</a> - textsearch.cc</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Test:</td>
          <td class="headerValue" width="80%" colspan=4>lcov.info</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Date:</td>
          <td class="headerValue" width="20%">2008-08-14</td>
          <td width="20%"></td>
          <td class="headerItem" width="20%">Instrumented&nbsp;lines:</td>
          <td class="headerValue" width="20%">115</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Code&nbsp;covered:</td>
          <td class="headerValue" width="20%">72.2 %</td>
          <td width="20%"></td>
          <td class="headerItem" width="20%">Executed&nbsp;lines:</td>
          <td class="headerValue" width="20%">83</td>
        </tr>
        </table>
      </td>
    </tr>
    <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td><pre class="source">
<span class="lineNum">       1 </span>                : 
<span class="lineNum">       2 </span>                : /** @file
<span class="lineNum">       3 </span>                :  * @author Enrico Zini &lt;enrico@enricozini.org&gt;
<span class="lineNum">       4 </span>                :  * Fast full-text search
<span class="lineNum">       5 </span>                :  */
<span class="lineNum">       6 </span>                : 
<span class="lineNum">       7 </span>                : /*
<span class="lineNum">       8 </span>                :  * Copyright (C) 2007  Enrico Zini &lt;enrico@debian.org&gt;
<span class="lineNum">       9 </span>                :  *
<span class="lineNum">      10 </span>                :  * This program is free software; you can redistribute it and/or modify
<span class="lineNum">      11 </span>                :  * it under the terms of the GNU General Public License as published by
<span class="lineNum">      12 </span>                :  * the Free Software Foundation; either version 2 of the License, or
<span class="lineNum">      13 </span>                :  * (at your option) any later version.
<span class="lineNum">      14 </span>                :  *
<span class="lineNum">      15 </span>                :  * This program is distributed in the hope that it will be useful,
<span class="lineNum">      16 </span>                :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
<span class="lineNum">      17 </span>                :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
<span class="lineNum">      18 </span>                :  * GNU General Public License for more details.
<span class="lineNum">      19 </span>                :  *
<span class="lineNum">      20 </span>                :  * You should have received a copy of the GNU General Public License
<span class="lineNum">      21 </span>                :  * along with this program; if not, write to the Free Software
<span class="lineNum">      22 </span>                :  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
<span class="lineNum">      23 </span>                :  */
<span class="lineNum">      24 </span>                : 
<span class="lineNum">      25 </span>                : #include &lt;ept/textsearch/textsearch.h&gt;
<span class="lineNum">      26 </span>                : #include &lt;ept/textsearch/maint/path.h&gt;
<span class="lineNum">      27 </span>                : #include &lt;ept/apt/apt.h&gt;
<span class="lineNum">      28 </span>                : #include &lt;ept/apt/packagerecord.h&gt;
<span class="lineNum">      29 </span>                : //#include &lt;ept/debtags/debtags.h&gt;
<span class="lineNum">      30 </span>                : 
<span class="lineNum">      31 </span>                : #include &lt;wibble/regexp.h&gt;
<span class="lineNum">      32 </span>                : #include &lt;cctype&gt;
<span class="lineNum">      33 </span>                : #include &lt;cmath&gt;
<span class="lineNum">      34 </span>                : 
<span class="lineNum">      35 </span>                : #include &lt;xapian/queryparser.h&gt;
<span class="lineNum">      36 </span>                : 
<span class="lineNum">      37 </span>                : #include &lt;algorithm&gt;
<span class="lineNum">      38 </span>                : 
<span class="lineNum">      39 </span>                : #include &lt;iostream&gt;
<span class="lineNum">      40 </span>                : 
<span class="lineNum">      41 </span>                : using namespace std;
<span class="lineNum">      42 </span>                : using namespace ept::apt;
<span class="lineNum">      43 </span>                : using namespace ept::debtags;
<span class="lineNum">      44 </span>                : 
<span class="lineNum">      45 </span>                : namespace ept {
<span class="lineNum">      46 </span>                : namespace textsearch {
<span class="lineNum">      47 </span>                : 
<span class="lineNum">      48 </span>                : size_t max_index = 0;
<span class="lineNum">      49 </span>                : 
<span class="lineNum">      50 </span><span class="lineCov">             11 : TextSearch::TextSearch()</span>
<span class="lineNum">      51 </span><span class="lineCov">             11 :         : m_timestamp(0), m_stem(&quot;en&quot;)</span>
<span class="lineNum">      52 </span>                : {
<span class="lineNum">      53 </span><span class="lineCov">             22 :         m_timestamp = Path::indexTimestamp();</span>
<span class="lineNum">      54 </span><span class="lineCov">             11 :         if (m_timestamp)</span>
<span class="lineNum">      55 </span><span class="lineCov">              9 :                 m_db.add_database(Xapian::Database(Path::index()));</span>
<span class="lineNum">      56 </span><span class="lineCov">             11 : }</span>
<span class="lineNum">      57 </span>                : 
<span class="lineNum">      58 </span><span class="lineCov">              7 : std::string TextSearch::toLower(const std::string&amp; str)</span>
<span class="lineNum">      59 </span>                : {
<span class="lineNum">      60 </span><span class="lineCov">              7 :         std::string res;</span>
<span class="lineNum">      61 </span><span class="lineCov">              7 :         res.reserve(str.size());</span>
<span class="lineNum">      62 </span><span class="lineCov">             44 :         for (std::string::const_iterator i = str.begin(); i != str.end(); ++i)</span>
<span class="lineNum">      63 </span><span class="lineCov">             37 :                 res += tolower(*i);</span>
<span class="lineNum">      64 </span><span class="lineNoCov">              0 :         return res;</span>
<span class="lineNum">      65 </span>                : }
<span class="lineNum">      66 </span>                : 
<span class="lineNum">      67 </span><span class="lineCov">              3 : bool TextSearch::needsRebuild(apt::Apt&amp; apt)</span>
<span class="lineNum">      68 </span>                : {
<span class="lineNum">      69 </span><span class="lineCov">              3 :         return apt.timestamp() &gt; m_timestamp;</span>
<span class="lineNum">      70 </span>                : }
<span class="lineNum">      71 </span>                : 
<span class="lineNum">      72 </span><span class="lineNoCov">              0 : void TextSearch::normalize_and_add(Xapian::Document&amp; doc, const std::string&amp; term, int&amp; pos) const</span>
<span class="lineNum">      73 </span>                : {
<span class="lineNum">      74 </span><span class="lineNoCov">              0 :         string t = TextSearch::toLower(term);</span>
<span class="lineNum">      75 </span><span class="lineNoCov">              0 :         string s = m_stem(t);</span>
<span class="lineNum">      76 </span><span class="lineNoCov">              0 :         doc.add_term(t);</span>
<span class="lineNum">      77 </span><span class="lineNoCov">              0 :         if (s != t)</span>
<span class="lineNum">      78 </span><span class="lineNoCov">              0 :                 doc.add_term(s);</span>
<span class="lineNum">      79 </span><span class="lineNoCov">              0 : }</span>
<span class="lineNum">      80 </span>                : 
<span class="lineNum">      81 </span><span class="lineCov">             10 : bool TextSearch::rebuildIfNeeded(apt::Apt&amp; apt, const std::vector&lt;const TextSearch::ExtraIndexer*&gt;&amp; extraIndexers)</span>
<span class="lineNum">      82 </span>                : {
<span class="lineNum">      83 </span>                :         // Check if a rebuild is needed, and keep a copy of the APT timestamp for
<span class="lineNum">      84 </span>                :         // saving later
<span class="lineNum">      85 </span><span class="lineCov">             10 :         time_t aptts = apt.timestamp();</span>
<span class="lineNum">      86 </span><span class="lineCov">             10 :         if (aptts &lt;= m_timestamp)</span>
<span class="lineNum">      87 </span><span class="lineCov">              4 :                 return false;</span>
<span class="lineNum">      88 </span>                : 
<span class="lineNum">      89 </span>                :         // Reindex
<span class="lineNum">      90 </span><span class="lineCov">              6 :         Xapian::WritableDatabase database(Xapian::Flint::open(Path::index(), Xapian::DB_CREATE_OR_OPEN));</span>
<span class="lineNum">      91 </span><span class="lineCov">              6 :         Xapian::TermGenerator termgen;</span>
<span class="lineNum">      92 </span><span class="lineCov">              6 :         termgen.set_stemmer(m_stem);</span>
<span class="lineNum">      93 </span>                :         //database.begin_transaction();
<span class="lineNum">      94 </span><span class="lineCov">              6 :         PackageRecord rec;</span>
<span class="lineNum">      95 </span><span class="lineCov">              6 :         size_t count = 0;</span>
<span class="lineNum">      96 </span><span class="lineCov">           2610 :         for (Apt::record_iterator i = apt.recordBegin();</span>
<span class="lineNum">      97 </span>                :                         i != apt.recordEnd(); ++i, ++count)
<span class="lineNum">      98 </span>                :         {
<span class="lineNum">      99 </span>                :                 // If we are testing, we can set a limit to how many packages we index,
<span class="lineNum">     100 </span>                :                 // to avoid it taking too much time
<span class="lineNum">     101 </span><span class="lineCov">           2604 :                 if (max_index != 0 &amp;&amp; count &gt; max_index)</span>
<span class="lineNum">     102 </span><span class="lineNoCov">              0 :                         break;</span>
<span class="lineNum">     103 </span>                : 
<span class="lineNum">     104 </span><span class="lineCov">           2604 :                 rec.scan(*i);</span>
<span class="lineNum">     105 </span>                : 
<span class="lineNum">     106 </span><span class="lineCov">           2604 :                 Xapian::Document doc;</span>
<span class="lineNum">     107 </span><span class="lineCov">           2604 :                 doc.set_data(rec.package());</span>
<span class="lineNum">     108 </span>                : 
<span class="lineNum">     109 </span><span class="lineCov">           2604 :                 string pkgid = &quot;XP&quot; + rec.package();</span>
<span class="lineNum">     110 </span>                :                 //std::cerr &lt;&lt; &quot;Add &quot; &lt;&lt; pkgid &lt;&lt; &quot;: &quot; &lt;&lt; idx &lt;&lt; std::endl;
<span class="lineNum">     111 </span><span class="lineCov">           2604 :                 doc.add_term(pkgid);</span>
<span class="lineNum">     112 </span>                : 
<span class="lineNum">     113 </span>                :                 // Index tags as well
<span class="lineNum">     114 </span><span class="lineCov">           2604 :                 set&lt;string&gt; tags = rec.tag();</span>
<span class="lineNum">     115 </span><span class="lineCov">           2604 :                 for (set&lt;string&gt;::const_iterator ti = tags.begin();</span>
<span class="lineNum">     116 </span>                :                                 ti != tags.end(); ++ti)
<span class="lineNum">     117 </span><span class="lineNoCov">              0 :                         doc.add_term(&quot;XT&quot;+*ti);</span>
<span class="lineNum">     118 </span>                : 
<span class="lineNum">     119 </span><span class="lineCov">           2604 :                 termgen.set_document(doc);</span>
<span class="lineNum">     120 </span><span class="lineCov">           2604 :                 termgen.index_text_without_positions(rec.package());</span>
<span class="lineNum">     121 </span><span class="lineCov">           5208 :                 termgen.index_text_without_positions(rec.description());</span>
<span class="lineNum">     122 </span>                : 
<span class="lineNum">     123 </span>                :                 // Add the values
<span class="lineNum">     124 </span><span class="lineCov">           5208 :                 doc.add_value(VAL_APT_INSTALLED_SIZE, Xapian::sortable_serialise(rec.installedSize()));</span>
<span class="lineNum">     125 </span><span class="lineCov">           2604 :                 doc.add_value(VAL_APT_PACKAGE_SIZE, Xapian::sortable_serialise(rec.packageSize()));</span>
<span class="lineNum">     126 </span>                : 
<span class="lineNum">     127 </span><span class="lineCov">           2604 :                 if (m_timestamp)</span>
<span class="lineNum">     128 </span><span class="lineCov">           2170 :                         database.replace_document(pkgid, doc);</span>
<span class="lineNum">     129 </span>                :                 else
<span class="lineNum">     130 </span><span class="lineCov">            434 :                         database.add_document(doc);</span>
<span class="lineNum">     131 </span><span class="lineCov">              6 :         }</span>
<span class="lineNum">     132 </span>                : 
<span class="lineNum">     133 </span>                :         //database.commit_transaction();
<span class="lineNum">     134 </span>                : 
<span class="lineNum">     135 </span><span class="lineCov">              6 :         if (!m_timestamp)</span>
<span class="lineNum">     136 </span><span class="lineCov">              1 :                 m_db.add_database(Xapian::Database(Path::index()));</span>
<span class="lineNum">     137 </span>                :         else
<span class="lineNum">     138 </span><span class="lineCov">              5 :                 m_db.reopen();</span>
<span class="lineNum">     139 </span>                : 
<span class="lineNum">     140 </span><span class="lineCov">              6 :         m_timestamp = aptts;</span>
<span class="lineNum">     141 </span>                : 
<span class="lineNum">     142 </span><span class="lineCov">              6 :         Path::setTimestamp(aptts);</span>
<span class="lineNum">     143 </span>                : 
<span class="lineNum">     144 </span><span class="lineCov">              6 :         return true;</span>
<span class="lineNum">     145 </span>                : }
<span class="lineNum">     146 </span>                : 
<span class="lineNum">     147 </span><span class="lineCov">              2 : Xapian::Query TextSearch::makeORQuery(const std::string&amp; keywords) const</span>
<span class="lineNum">     148 </span>                : {
<span class="lineNum">     149 </span><span class="lineCov">              2 :         wibble::Tokenizer tok(keywords, &quot;[A-Za-z0-9_-]+&quot;, REG_EXTENDED);</span>
<span class="lineNum">     150 </span><span class="lineCov">              4 :         return makeORQuery(tok.begin(), tok.end());</span>
<span class="lineNum">     151 </span>                : }
<span class="lineNum">     152 </span>                : 
<span class="lineNum">     153 </span><span class="lineCov">              1 : Xapian::Query TextSearch::makePartialORQuery(const std::string&amp; keywords) const</span>
<span class="lineNum">     154 </span>                : {
<span class="lineNum">     155 </span><span class="lineCov">              1 :         wibble::Tokenizer tok(keywords, &quot;[A-Za-z0-9_-]+&quot;, REG_EXTENDED);</span>
<span class="lineNum">     156 </span><span class="lineCov">              1 :         vector&lt;string&gt; tokens;</span>
<span class="lineNum">     157 </span>                :         // FIXME: make the Tokenizer iterators properly iterable
<span class="lineNum">     158 </span><span class="lineCov">              2 :         for (wibble::Tokenizer::const_iterator i = tok.begin();</span>
<span class="lineNum">     159 </span>                :                         i != tok.end(); ++i)
<span class="lineNum">     160 </span><span class="lineCov">              1 :                 tokens.push_back(*i);</span>
<span class="lineNum">     161 </span>                :         // Add all the terms starting with 'last'
<span class="lineNum">     162 </span><span class="lineCov">              1 :         if (!tokens.empty())</span>
<span class="lineNum">     163 </span>                :         {
<span class="lineNum">     164 </span><span class="lineCov">              1 :                 string&amp; last = *tokens.rbegin();</span>
<span class="lineNum">     165 </span><span class="lineCov">              1 :                 if (last.size() == 1)</span>
<span class="lineNum">     166 </span>                :                         // Ignore one-letter partial terms: they make the query uselessly
<span class="lineNum">     167 </span>                :                         // large and slow, and it's worth just to wait for more characters
<span class="lineNum">     168 </span>                :                         // to come
<span class="lineNum">     169 </span><span class="lineNoCov">              0 :                         tokens.resize(tokens.size() - 1);</span>
<span class="lineNum">     170 </span>                :                 else
<span class="lineNum">     171 </span><span class="lineCov">              1 :                         copy(m_db.allterms_begin(last), m_db.allterms_end(last), back_inserter(tokens));</span>
<span class="lineNum">     172 </span>                :                 /*
<span class="lineNum">     173 </span>                :                 for (Xapian::TermIterator t = m_db.allterms_begin(last);
<span class="lineNum">     174 </span>                :                                 t != m_db.allterms_end(last); ++t)
<span class="lineNum">     175 </span>                :                         tokens.push_back(*t);
<span class="lineNum">     176 </span>                :                 */
<span class="lineNum">     177 </span>                :         }
<span class="lineNum">     178 </span><span class="lineCov">              1 :         return makeORQuery(tokens.begin(), tokens.end());</span>
<span class="lineNum">     179 </span>                : }
<span class="lineNum">     180 </span>                : 
<span class="lineNum">     181 </span><span class="lineCov">             10 : Xapian::docid TextSearch::docidByName(const std::string&amp; pkgname) const</span>
<span class="lineNum">     182 </span>                : {
<span class="lineNum">     183 </span><span class="lineCov">             10 :         Xapian::PostingIterator i = m_db.postlist_begin(&quot;XP&quot;+pkgname);</span>
<span class="lineNum">     184 </span><span class="lineCov">             10 :         if (i == m_db.postlist_end(&quot;XP&quot;+pkgname))</span>
<span class="lineNum">     185 </span><span class="lineCov">              5 :                 return 0;</span>
<span class="lineNum">     186 </span>                :         else
<span class="lineNum">     187 </span><span class="lineCov">              5 :                 return *i;</span>
<span class="lineNum">     188 </span>                : }
<span class="lineNum">     189 </span>                : 
<span class="lineNum">     190 </span>                : struct TagFilter : public Xapian::ExpandDecider
<span class="lineNum">     191 </span><span class="lineCov">              4 : {</span>
<span class="lineNum">     192 </span><span class="lineNoCov">              0 :         virtual bool operator()(const std::string &amp;term) const { return term[0] == 'T'; }</span>
<span class="lineNum">     193 </span>                : };
<span class="lineNum">     194 </span>                : 
<span class="lineNum">     195 </span><span class="lineCov">              2 : static TagFilter tagFilter;</span>
<span class="lineNum">     196 </span>                : 
<span class="lineNum">     197 </span><span class="lineNoCov">              0 : vector&lt;string&gt; TextSearch::expand(Xapian::Enquire&amp; enq) const</span>
<span class="lineNum">     198 </span>                : {
<span class="lineNum">     199 </span><span class="lineNoCov">              0 :         Xapian::RSet rset;</span>
<span class="lineNum">     200 </span>                :         // Get the top 5 results as 'good ones' to compute the search expansion
<span class="lineNum">     201 </span><span class="lineNoCov">              0 :         Xapian::MSet mset = enq.get_mset(0, 5);</span>
<span class="lineNum">     202 </span><span class="lineNoCov">              0 :         for (Xapian::MSet::iterator i = mset.begin(); i != mset.end(); ++i)</span>
<span class="lineNum">     203 </span><span class="lineNoCov">              0 :                 rset.add_document(i);</span>
<span class="lineNum">     204 </span>                :         // Get the expanded set, only expanding the query with tag names
<span class="lineNum">     205 </span><span class="lineNoCov">              0 :         Xapian::ESet eset = enq.get_eset(5, rset, &amp;tagFilter);</span>
<span class="lineNum">     206 </span><span class="lineNoCov">              0 :         vector&lt;string&gt; res;</span>
<span class="lineNum">     207 </span><span class="lineNoCov">              0 :         for (Xapian::ESetIterator i = eset.begin(); i != eset.end(); ++i)</span>
<span class="lineNum">     208 </span><span class="lineNoCov">              0 :                 res.push_back(*i);</span>
<span class="lineNum">     209 </span><span class="lineNoCov">              0 :         return res;</span>
<span class="lineNum">     210 </span>                : }
<span class="lineNum">     211 </span>                : 
<span class="lineNum">     212 </span><span class="lineNoCov">              0 : Xapian::Query TextSearch::makeRelatedQuery(const std::string&amp; pkgname) const</span>
<span class="lineNum">     213 </span>                : {
<span class="lineNum">     214 </span><span class="lineNoCov">              0 :         Xapian::Enquire enquire(db());</span>
<span class="lineNum">     215 </span>                :         
<span class="lineNum">     216 </span>                :         // Retrieve the document for the given package
<span class="lineNum">     217 </span><span class="lineNoCov">              0 :         enquire.set_query(Xapian::Query(&quot;XP&quot;+pkgname));</span>
<span class="lineNum">     218 </span><span class="lineNoCov">              0 :         Xapian::MSet matches = enquire.get_mset(0, 1);</span>
<span class="lineNum">     219 </span><span class="lineNoCov">              0 :         Xapian::MSetIterator mi = matches.begin();</span>
<span class="lineNum">     220 </span><span class="lineNoCov">              0 :         if (mi == matches.end()) return Xapian::Query();</span>
<span class="lineNum">     221 </span><span class="lineNoCov">              0 :         Xapian::Document doc = mi.get_document();</span>
<span class="lineNum">     222 </span>                : 
<span class="lineNum">     223 </span>                :         // Return the query to get the list of similar documents
<span class="lineNum">     224 </span><span class="lineNoCov">              0 :         return Xapian::Query(Xapian::Query::OP_OR, doc.termlist_begin(), doc.termlist_end());</span>
<span class="lineNum">     225 </span>                : }
<span class="lineNum">     226 </span>                : 
<span class="lineNum">     227 </span><span class="lineCov">              4 : double TextSearch::getDoubleValue(const std::string&amp; pkgname, Xapian::valueno val_id) const</span>
<span class="lineNum">     228 </span>                : {
<span class="lineNum">     229 </span><span class="lineCov">              4 :         Xapian::docid id = docidByName(pkgname);</span>
<span class="lineNum">     230 </span><span class="lineCov">              4 :         if (id == 0)</span>
<span class="lineNum">     231 </span><span class="lineCov">              2 :                 return 0.0;</span>
<span class="lineNum">     232 </span><span class="lineCov">              2 :         Xapian::Document doc = db().get_document(id);</span>
<span class="lineNum">     233 </span><span class="lineCov">              2 :         string val = doc.get_value(val_id);</span>
<span class="lineNum">     234 </span><span class="lineCov">              2 :         if (val.empty())</span>
<span class="lineNum">     235 </span><span class="lineNoCov">              0 :                 return 0.0;</span>
<span class="lineNum">     236 </span>                :         else
<span class="lineNum">     237 </span><span class="lineCov">              2 :                 return Xapian::sortable_unserialise(val);</span>
<span class="lineNum">     238 </span>                : }
<span class="lineNum">     239 </span>                : 
<span class="lineNum">     240 </span><span class="lineCov">              4 : int TextSearch::getIntValue(const std::string&amp; pkgname, Xapian::valueno val_id) const</span>
<span class="lineNum">     241 </span>                : {
<span class="lineNum">     242 </span><span class="lineCov">              4 :         Xapian::docid id = docidByName(pkgname);</span>
<span class="lineNum">     243 </span><span class="lineCov">              4 :         if (id == 0)</span>
<span class="lineNum">     244 </span><span class="lineCov">              2 :                 return 0;</span>
<span class="lineNum">     245 </span><span class="lineCov">              2 :         Xapian::Document doc = db().get_document(id);</span>
<span class="lineNum">     246 </span><span class="lineCov">              2 :         string val = doc.get_value(val_id);</span>
<span class="lineNum">     247 </span><span class="lineCov">              2 :         if (val.empty())</span>
<span class="lineNum">     248 </span><span class="lineNoCov">              0 :                 return 0;</span>
<span class="lineNum">     249 </span>                :         else
<span class="lineNum">     250 </span><span class="lineCov">              2 :                 return (int)nearbyint(Xapian::sortable_unserialise(val));</span>
<span class="lineNum">     251 </span>                : }
<span class="lineNum">     252 </span>                : 
<span class="lineNum">     253 </span>                : }
<span class="lineNum">     254 </span><span class="lineCov">              6 : }</span>
<span class="lineNum">     255 </span>                : 
<span class="lineNum">     256 </span>                : // vim:set ts=4 sw=4:
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
  <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
  <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LTP GCOV extension version 1.6</a></td></tr>
  </table>
  <br>

</body>
</html>