LCOV - code coverage report
Current view: top level - api - leafpostlist.cc (source / functions) Hit Total Coverage
Test: Test Coverage for xapian-core e18b6a92d5b9 Lines: 38 39 97.4 %
Date: 2017-05-24 19:16:08 Functions: 12 12 100.0 %
Branches: 15 18 83.3 %

           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 "matcher/orpositionlist.h"
      28                 :            : #include "omassert.h"
      29                 :            : #include "debuglog.h"
      30                 :            : 
      31                 :            : using namespace std;
      32                 :            : 
      33                 :     490496 : LeafPostList::~LeafPostList()
      34                 :            : {
      35         [ +  + ]:     245248 :     delete weight;
      36         [ -  + ]:     245248 : }
      37                 :            : 
      38                 :            : Xapian::doccount
      39                 :     238403 : LeafPostList::get_termfreq_min() const
      40                 :            : {
      41                 :     238403 :     return get_termfreq();
      42                 :            : }
      43                 :            : 
      44                 :            : Xapian::doccount
      45                 :     241769 : LeafPostList::get_termfreq_max() const
      46                 :            : {
      47                 :     241769 :     return get_termfreq();
      48                 :            : }
      49                 :            : 
      50                 :            : Xapian::doccount
      51                 :     485895 : LeafPostList::get_termfreq_est() const
      52                 :            : {
      53                 :     485895 :     return get_termfreq();
      54                 :            : }
      55                 :            : 
      56                 :            : void
      57                 :     238007 : LeafPostList::set_termweight(const Xapian::Weight * weight_)
      58                 :            : {
      59                 :            :     // This method shouldn't be called more than once on the same object.
      60                 :            :     Assert(!weight);
      61                 :     238007 :     weight = weight_;
      62                 :     238007 :     need_doclength = weight->get_sumpart_needs_doclength_();
      63                 :     238007 :     need_unique_terms = weight->get_sumpart_needs_uniqueterms_();
      64                 :     238007 : }
      65                 :            : 
      66                 :            : double
      67                 :    2716712 : LeafPostList::get_maxweight() const
      68                 :            : {
      69         [ +  + ]:    2716712 :     return weight ? weight->get_maxpart() : 0;
      70                 :            : }
      71                 :            : 
      72                 :            : double
      73                 :   37719421 : LeafPostList::get_weight() const
      74                 :            : {
      75         [ +  + ]:   37719421 :     if (!weight) return 0;
      76                 :   37712145 :     Xapian::termcount doclen = 0, unique_terms = 0;
      77                 :            :     // Fetching the document length and number of unique terms is work we can
      78                 :            :     // avoid if the weighting scheme doesn't use them.
      79         [ +  + ]:   37712145 :     if (need_doclength)
      80                 :   37704780 :         doclen = get_doclength();
      81         [ +  + ]:   37712145 :     if (need_unique_terms)
      82                 :        630 :         unique_terms = get_unique_terms();
      83                 :   37712145 :     double sumpart = weight->get_sumpart(get_wdf(), doclen, unique_terms);
      84                 :            :     AssertRel(sumpart, <=, weight->get_maxpart());
      85                 :   37712145 :     return sumpart;
      86                 :            : }
      87                 :            : 
      88                 :            : double
      89                 :     417633 : LeafPostList::recalc_maxweight()
      90                 :            : {
      91                 :     417633 :     return LeafPostList::get_maxweight();
      92                 :            : }
      93                 :            : 
      94                 :            : TermFreqs
      95                 :       1463 : LeafPostList::get_termfreq_est_using_stats(
      96                 :            :         const Xapian::Weight::Internal & stats) const
      97                 :            : {
      98                 :            :     LOGCALL(MATCH, TermFreqs, "LeafPostList::get_termfreq_est_using_stats", stats);
      99         [ -  + ]:       1463 :     if (term.empty()) {
     100                 :          0 :         RETURN(TermFreqs(stats.collection_size,
     101                 :            :                          stats.rset_size,
     102                 :            :                          stats.total_term_count));
     103                 :            :     }
     104         [ +  - ]:       1463 :     map<string, TermFreqs>::const_iterator i = stats.termfreqs.find(term);
     105                 :            :     Assert(i != stats.termfreqs.end());
     106                 :       1463 :     RETURN(i->second);
     107                 :            : }
     108                 :            : 
     109                 :            : Xapian::termcount
     110                 :     852464 : LeafPostList::count_matching_subqs() const
     111                 :            : {
     112         [ +  + ]:     852464 :     return weight ? 1 : 0;
     113                 :            : }
     114                 :            : 
     115                 :            : void
     116                 :        372 : LeafPostList::gather_position_lists(OrPositionList* orposlist)
     117                 :            : {
     118                 :        372 :     orposlist->add_poslist(read_position_list());
     119                 :        372 : }
     120                 :            : 
     121                 :            : LeafPostList *
     122                 :      23664 : LeafPostList::open_nearby_postlist(const std::string &) const
     123                 :            : {
     124                 :      23664 :     return NULL;
     125                 :            : }

Generated by: LCOV version 1.11