LCOV - code coverage report
Current view: top level - api - leafpostlist.cc (source / functions) Hit Total Coverage
Test: Test Coverage for xapian-core Lines: 32 32 100.0 %
Date: 2014-07-03 12:16:27 Functions: 11 11 100.0 %
Branches: 18 24 75.0 %

           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         [ +  - ]:     340653 : LeafPostList::~LeafPostList()
      33                 :            : {
      34 [ +  + ][ +  - ]:     340653 :     delete weight;
      35         [ -  + ]:     340653 : }
      36                 :            : 
      37                 :            : Xapian::doccount
      38                 :     332172 : LeafPostList::get_termfreq_min() const
      39                 :            : {
      40                 :     332172 :     return get_termfreq();
      41                 :            : }
      42                 :            : 
      43                 :            : Xapian::doccount
      44                 :     335250 : LeafPostList::get_termfreq_max() const
      45                 :            : {
      46                 :     335250 :     return get_termfreq();
      47                 :            : }
      48                 :            : 
      49                 :            : Xapian::doccount
      50                 :     673451 : LeafPostList::get_termfreq_est() const
      51                 :            : {
      52                 :     673451 :     return get_termfreq();
      53                 :            : }
      54                 :            : 
      55                 :            : void
      56                 :     332737 : 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                 :     332737 :     weight = weight_;
      61                 :     332737 :     need_doclength = weight->get_sumpart_needs_doclength_();
      62                 :     332737 : }
      63                 :            : 
      64                 :            : double
      65                 :    2920958 : LeafPostList::get_maxweight() const
      66                 :            : {
      67         [ +  + ]:    2920958 :     return weight ? weight->get_maxpart() : 0;
      68                 :            : }
      69                 :            : 
      70                 :            : double
      71                 :   47152356 : LeafPostList::get_weight() const
      72                 :            : {
      73         [ +  + ]:   47152356 :     if (!weight) return 0;
      74                 :   47145498 :     Xapian::termcount doclen = 0;
      75                 :            :     // Fetching the document length is work we can avoid if the weighting
      76                 :            :     // scheme doesn't use it.
      77         [ +  + ]:   47145498 :     if (need_doclength) doclen = get_doclength();
      78                 :   47145498 :     double sumpart = weight->get_sumpart(get_wdf(), doclen);
      79                 :            :     AssertRel(sumpart, <=, weight->get_maxpart());
      80                 :   47152356 :     return sumpart;
      81                 :            : }
      82                 :            : 
      83                 :            : double
      84                 :     621345 : LeafPostList::recalc_maxweight()
      85                 :            : {
      86                 :     621345 :     return LeafPostList::get_maxweight();
      87                 :            : }
      88                 :            : 
      89                 :            : TermFreqs
      90                 :       1204 : LeafPostList::get_termfreq_est_using_stats(
      91                 :            :         const Xapian::Weight::Internal & stats) const
      92                 :            : {
      93                 :            :     LOGCALL(MATCH, TermFreqs, "LeafPostList::get_termfreq_est_using_stats", stats);
      94 [ +  - ][ +  + ]:       1204 :     if (term.empty()) {
      95                 :         38 :         RETURN(TermFreqs(stats.collection_size,
      96                 :            :                          stats.rset_size,
      97                 :            :                          stats.total_term_count));
      98                 :            :     }
      99         [ +  - ]:       1166 :     map<string, TermFreqs>::const_iterator i = stats.termfreqs.find(term);
     100                 :            :     Assert(i != stats.termfreqs.end());
     101         [ +  - ]:       1204 :     RETURN(i->second);
     102                 :            : }
     103                 :            : 
     104                 :            : Xapian::termcount
     105                 :    1015817 : LeafPostList::count_matching_subqs() const
     106                 :            : {
     107         [ +  + ]:    1015817 :     return weight ? 1 : 0;
     108                 :            : }
     109                 :            : 
     110                 :            : LeafPostList *
     111                 :      94675 : LeafPostList::open_nearby_postlist(const std::string &) const
     112                 :            : {
     113                 :      94675 :     return NULL;
     114                 :            : }

Generated by: LCOV version 1.11 pre (CVS 1.76)

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