LCOV - code coverage report
Current view: top level - api - leafpostlist.cc (source / functions) Hit Total Coverage
Test: Test Coverage for xapian-core 9fa1b37 Lines: 36 36 100.0 %
Date: 2015-06-29 22:19:29 Functions: 11 11 100.0 %
Branches: 16 18 88.9 %

           Branch data     Line data    Source code
       1                 :            : /** @file leafpostlist.cc
       2                 :            :  * @brief Abstract base class for leaf postlists.
       3                 :            :  */
       4                 :            : /* Copyright (C) 2007,2009,2011,2013,2014 Olly Betts
       5                 :            :  * Copyright (C) 2009 Lemur Consulting Ltd
       6                 :            :  *
       7                 :            :  * This program is free software; you can redistribute it and/or
       8                 :            :  * modify it under the terms of the GNU General Public License as
       9                 :            :  * published by the Free Software Foundation; either version 2 of the
      10                 :            :  * License, or (at your option) any later version.
      11                 :            :  *
      12                 :            :  * This program is distributed in the hope that it will be useful,
      13                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      14                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      15                 :            :  * GNU General Public License for more details.
      16                 :            :  *
      17                 :            :  * You should have received a copy of the GNU General Public License
      18                 :            :  * along with this program; if not, write to the Free Software
      19                 :            :  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
      20                 :            :  */
      21                 :            : 
      22                 :            : #include <config.h>
      23                 :            : 
      24                 :            : #include "xapian/weight.h"
      25                 :            : 
      26                 :            : #include "leafpostlist.h"
      27                 :            : #include "omassert.h"
      28                 :            : #include "debuglog.h"
      29                 :            : 
      30                 :            : using namespace std;
      31                 :            : 
      32                 :     683740 : LeafPostList::~LeafPostList()
      33                 :            : {
      34         [ +  + ]:     341870 :     delete weight;
      35         [ -  + ]:     341870 : }
      36                 :            : 
      37                 :            : Xapian::doccount
      38                 :     332465 : LeafPostList::get_termfreq_min() const
      39                 :            : {
      40                 :     332465 :     return get_termfreq();
      41                 :            : }
      42                 :            : 
      43                 :            : Xapian::doccount
      44                 :     337265 : LeafPostList::get_termfreq_max() const
      45                 :            : {
      46                 :     337265 :     return get_termfreq();
      47                 :            : }
      48                 :            : 
      49                 :            : Xapian::doccount
      50                 :     675396 : LeafPostList::get_termfreq_est() const
      51                 :            : {
      52                 :     675396 :     return get_termfreq();
      53                 :            : }
      54                 :            : 
      55                 :            : void
      56                 :     333302 : LeafPostList::set_termweight(const Xapian::Weight * weight_)
      57                 :            : {
      58                 :            :     // This method shouldn't be called more than once on the same object.
      59                 :            :     Assert(!weight);
      60                 :     333302 :     weight = weight_;
      61                 :     333302 :     need_doclength = weight->get_sumpart_needs_doclength_();
      62                 :     333302 :     need_unique_terms = weight->get_sumpart_needs_uniqueterms_();
      63                 :     333302 : }
      64                 :            : 
      65                 :            : double
      66                 :    2922678 : LeafPostList::get_maxweight() const
      67                 :            : {
      68         [ +  + ]:    2922678 :     return weight ? weight->get_maxpart() : 0;
      69                 :            : }
      70                 :            : 
      71                 :            : double
      72                 :   47158752 : LeafPostList::get_weight() const
      73                 :            : {
      74         [ +  + ]:   47158752 :     if (!weight) return 0;
      75                 :   47149644 :     Xapian::termcount doclen = 0, unique_terms = 0;
      76                 :            :     // Fetching the document length and number of unique terms is work we can
      77                 :            :     // avoid if the weighting scheme doesn't use them.
      78         [ +  + ]:   47149644 :     if (need_doclength)
      79                 :   47139053 :         doclen = get_doclength();
      80         [ +  + ]:   47149644 :     if (need_unique_terms)
      81                 :        780 :         unique_terms = get_unique_terms();
      82                 :   47149644 :     double sumpart = weight->get_sumpart(get_wdf(), doclen, unique_terms);
      83                 :            :     AssertRel(sumpart, <=, weight->get_maxpart());
      84                 :   47149644 :     return sumpart;
      85                 :            : }
      86                 :            : 
      87                 :            : double
      88                 :     622057 : LeafPostList::recalc_maxweight()
      89                 :            : {
      90                 :     622057 :     return LeafPostList::get_maxweight();
      91                 :            : }
      92                 :            : 
      93                 :            : TermFreqs
      94                 :       1285 : LeafPostList::get_termfreq_est_using_stats(
      95                 :            :         const Xapian::Weight::Internal & stats) const
      96                 :            : {
      97                 :            :     LOGCALL(MATCH, TermFreqs, "LeafPostList::get_termfreq_est_using_stats", stats);
      98         [ +  + ]:       1285 :     if (term.empty()) {
      99                 :         39 :         RETURN(TermFreqs(stats.collection_size,
     100                 :            :                          stats.rset_size,
     101                 :            :                          stats.total_term_count));
     102                 :            :     }
     103         [ +  - ]:       1246 :     map<string, TermFreqs>::const_iterator i = stats.termfreqs.find(term);
     104                 :            :     Assert(i != stats.termfreqs.end());
     105                 :       1285 :     RETURN(i->second);
     106                 :            : }
     107                 :            : 
     108                 :            : Xapian::termcount
     109                 :    1016075 : LeafPostList::count_matching_subqs() const
     110                 :            : {
     111         [ +  + ]:    1016075 :     return weight ? 1 : 0;
     112                 :            : }
     113                 :            : 
     114                 :            : LeafPostList *
     115                 :      94918 : LeafPostList::open_nearby_postlist(const std::string &) const
     116                 :            : {
     117                 :      94918 :     return NULL;
     118                 :            : }

Generated by: LCOV version 1.11

This service is running on a virtual machine hosted at GPLHost which is sponsored for free.