LCOV - code coverage report
Current view: top level - matcher - valuegepostlist.cc (source / functions) Hit Total Coverage
Test: Test Coverage for xapian-core r Lines: 24 33 72.7 %
Date: 2011-08-21 Functions: 3 4 75.0 %
Branches: 16 20 80.0 %

           Branch data     Line data    Source code
       1                 :            : /** @file valuegepostlist.cc
       2                 :            :  * @brief Return document ids matching a range test on a specified doc value.
       3                 :            :  */
       4                 :            : /* Copyright 2007,2008 Olly Betts
       5                 :            :  * Copyright 2008 Lemur Consulting Ltd
       6                 :            :  * Copyright 2010 Richard Boulton
       7                 :            :  *
       8                 :            :  * This program is free software; you can redistribute it and/or modify
       9                 :            :  * it under the terms of the GNU General Public License as published by
      10                 :            :  * the Free Software Foundation; either version 2 of the License, or
      11                 :            :  * (at your option) any later version.
      12                 :            :  *
      13                 :            :  * This program is distributed in the hope that it will be useful,
      14                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      15                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      16                 :            :  * GNU General Public License for more details.
      17                 :            :  *
      18                 :            :  * You should have received a copy of the GNU General Public License
      19                 :            :  * along with this program; if not, write to the Free Software
      20                 :            :  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
      21                 :            :  */
      22                 :            : 
      23                 :            : #include <config.h>
      24                 :            : 
      25                 :            : #include "valuegepostlist.h"
      26                 :            : 
      27                 :            : #include "omassert.h"
      28                 :            : #include "str.h"
      29                 :            : 
      30                 :            : using namespace std;
      31                 :            : 
      32                 :            : PostList *
      33                 :       1744 : ValueGePostList::next(Xapian::weight)
      34                 :            : {
      35                 :            :     Assert(db);
      36         [ +  + ]:       1744 :     if (!valuelist) valuelist = db->open_value_list(valno);
      37                 :       1744 :     valuelist->next();
      38 [ +  + ][ +  + ]:       4168 :     while (!valuelist->at_end()) {
      39                 :       2424 :         const string & v = valuelist->get_value();
      40         [ +  + ]:       2424 :         if (v >= begin) return NULL;
      41                 :        838 :         valuelist->next();
      42                 :            :     }
      43                 :        158 :     db = NULL;
      44                 :       1744 :     return NULL;
      45                 :            : }
      46                 :            : 
      47                 :            : PostList *
      48                 :         16 : ValueGePostList::skip_to(Xapian::docid did, Xapian::weight)
      49                 :            : {
      50                 :            :     Assert(db);
      51         [ -  + ]:         16 :     if (!valuelist) valuelist = db->open_value_list(valno);
      52                 :         16 :     valuelist->skip_to(did);
      53 [ +  + ][ +  - ]:         45 :     while (!valuelist->at_end()) {
      54                 :         29 :         const string & v = valuelist->get_value();
      55         [ +  + ]:         29 :         if (v >= begin) return NULL;
      56                 :         13 :         valuelist->next();
      57                 :            :     }
      58                 :          0 :     db = NULL;
      59                 :         16 :     return NULL;
      60                 :            : }
      61                 :            : 
      62                 :            : PostList *
      63                 :         13 : ValueGePostList::check(Xapian::docid did, Xapian::weight, bool &valid)
      64                 :            : {
      65                 :            :     Assert(db);
      66                 :            :     AssertRelParanoid(did, <=, db->get_lastdocid());
      67         [ +  - ]:         13 :     if (!valuelist) valuelist = db->open_value_list(valno);
      68                 :         13 :     valid = valuelist->check(did);
      69         [ -  + ]:         13 :     if (!valid) {
      70                 :          0 :         return NULL;
      71                 :            :     }
      72                 :         13 :     const string & v = valuelist->get_value();
      73                 :         13 :     valid = (v >= begin);
      74                 :         13 :     return NULL;
      75                 :            : }
      76                 :            : 
      77                 :            : string
      78                 :          0 : ValueGePostList::get_description() const
      79                 :            : {
      80                 :          0 :     string desc = "ValueGePostList(";
      81                 :          0 :     desc += str(valno);
      82                 :          0 :     desc += ", ";
      83                 :          0 :     desc += begin;
      84                 :          0 :     desc += ")";
      85                 :          0 :     return desc;
      86                 :            : }

Generated by: LCOV version 1.8