LCOV - code coverage report
Current view: top level - api - leafpostlist.cc (source / functions) Hit Total Coverage
Test: Test Coverage for xapian-core r Lines: 28 29 96.6 %
Date: 2011-08-21 Functions: 10 12 83.3 %
Branches: 10 20 50.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 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                 :     483210 : LeafPostList::~LeafPostList()
      33                 :            : {
      34 [ #  # ][ #  # ]:     483210 :     delete weight;
                 [ +  + ]
      35 [ #  # ][ #  # ]:     483210 : }
                 [ -  + ]
      36                 :            : 
      37                 :            : Xapian::doccount
      38                 :     472826 : LeafPostList::get_termfreq_min() const
      39                 :            : {
      40                 :     472826 :     return get_termfreq();
      41                 :            : }
      42                 :            : 
      43                 :            : Xapian::doccount
      44                 :     477368 : LeafPostList::get_termfreq_max() const
      45                 :            : {
      46                 :     477368 :     return get_termfreq();
      47                 :            : }
      48                 :            : 
      49                 :            : Xapian::doccount
      50                 :     960488 : LeafPostList::get_termfreq_est() const
      51                 :            : {
      52                 :     960488 :     return get_termfreq();
      53                 :            : }
      54                 :            : 
      55                 :            : void
      56                 :     473840 : 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                 :     473840 :     weight = weight_;
      61                 :     473840 :     need_doclength = weight->get_sumpart_needs_doclength_();
      62                 :     473840 : }
      63                 :            : 
      64                 :            : Xapian::weight
      65                 :    3962661 : LeafPostList::get_maxweight() const
      66                 :            : {
      67         [ +  + ]:    3962661 :     return weight ? weight->get_maxpart() : 0;
      68                 :            : }
      69                 :            : 
      70                 :            : Xapian::weight
      71                 :   66007306 : LeafPostList::get_weight() const
      72                 :            : {
      73         [ +  + ]:   66007306 :     if (!weight) return 0;
      74                 :   65997664 :     Xapian::termcount doclen = 0;
      75                 :            :     // Fetching the document length is work we can avoid if the weighting
      76                 :            :     // scheme doesn't use it.
      77         [ +  + ]:   65997664 :     if (need_doclength) doclen = get_doclength();
      78                 :   66007306 :     return weight->get_sumpart(get_wdf(), doclen);
      79                 :            : }
      80                 :            : 
      81                 :            : Xapian::weight
      82                 :     895137 : LeafPostList::recalc_maxweight()
      83                 :            : {
      84                 :     895137 :     return LeafPostList::get_maxweight();
      85                 :            : }
      86                 :            : 
      87                 :            : TermFreqs
      88                 :       1680 : LeafPostList::get_termfreq_est_using_stats(
      89                 :            :         const Xapian::Weight::Internal & stats) const
      90                 :            : {
      91                 :            :     LOGCALL(MATCH, TermFreqs, "LeafPostList::get_termfreq_est_using_stats", stats);
      92         [ -  + ]:       1680 :     if (term.empty()) {
      93                 :          0 :         RETURN(TermFreqs(stats.collection_size, stats.rset_size));
      94                 :            :     }
      95                 :       1680 :     map<string, TermFreqs>::const_iterator i = stats.termfreqs.find(term);
      96                 :            :     Assert(i != stats.termfreqs.end());
      97                 :       1680 :     RETURN(i->second);
      98                 :            : }
      99                 :            : 
     100                 :            : Xapian::termcount
     101                 :    1407850 : LeafPostList::count_matching_subqs() const
     102                 :            : {
     103                 :    1407850 :     return 1;
     104                 :            : }

Generated by: LCOV version 1.8