LCOV - code coverage report
Current view: top level - matcher - valuegepostlist.cc (source / functions) Hit Total Coverage
Test: Test Coverage for xapian-core 954b5873a738 Lines: 27 35 77.1 %
Date: 2019-06-30 05:20:33 Functions: 3 4 75.0 %
Branches: 23 42 54.8 %

           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,2011,2013 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                 :            : #include "unicode/description_append.h"
      30                 :            : 
      31                 :            : using namespace std;
      32                 :            : 
      33                 :            : PostList *
      34                 :      12113 : ValueGePostList::next(double)
      35                 :            : {
      36                 :            :     Assert(db);
      37         [ +  + ]:      12113 :     if (!valuelist) valuelist = db->open_value_list(slot);
      38                 :      12113 :     valuelist->next();
      39         [ +  + ]:      22929 :     while (!valuelist->at_end()) {
      40                 :      22369 :         const string & v = valuelist->get_value();
      41 [ +  - ][ +  + ]:      22369 :         if (v >= begin) return NULL;
      42 [ +  - ][ +  + ]:      22369 :         valuelist->next();
      43                 :      10816 :     }
      44                 :        560 :     db = NULL;
      45                 :      12113 :     return NULL;
      46                 :            : }
      47                 :            : 
      48                 :            : PostList *
      49                 :         14 : ValueGePostList::skip_to(Xapian::docid did, double)
      50                 :            : {
      51                 :            :     Assert(db);
      52         [ -  + ]:         14 :     if (!valuelist) valuelist = db->open_value_list(slot);
      53                 :         14 :     valuelist->skip_to(did);
      54         [ +  - ]:         26 :     while (!valuelist->at_end()) {
      55                 :         26 :         const string & v = valuelist->get_value();
      56 [ +  - ][ +  + ]:         26 :         if (v >= begin) return NULL;
      57 [ +  - ][ +  + ]:         26 :         valuelist->next();
      58                 :         12 :     }
      59                 :          0 :     db = NULL;
      60                 :         14 :     return NULL;
      61                 :            : }
      62                 :            : 
      63                 :            : PostList *
      64                 :         80 : ValueGePostList::check(Xapian::docid did, double, bool &valid)
      65                 :            : {
      66                 :            :     Assert(db);
      67                 :            :     AssertRelParanoid(did, <=, db->get_lastdocid());
      68         [ +  + ]:         80 :     if (!valuelist) valuelist = db->open_value_list(slot);
      69                 :         80 :     valid = valuelist->check(did);
      70         [ +  + ]:         80 :     if (!valid) {
      71                 :         21 :         return NULL;
      72                 :            :     }
      73                 :         59 :     const string & v = valuelist->get_value();
      74         [ +  - ]:         59 :     valid = (v >= begin);
      75                 :         80 :     return NULL;
      76                 :            : }
      77                 :            : 
      78                 :            : string
      79                 :          0 : ValueGePostList::get_description() const
      80                 :            : {
      81         [ #  # ]:          0 :     string desc = "ValueGePostList(";
      82 [ #  # ][ #  # ]:          0 :     desc += str(slot);
      83         [ #  # ]:          0 :     desc += ", ";
      84         [ #  # ]:          0 :     description_append(desc, begin);
      85         [ #  # ]:          0 :     desc += ")";
      86                 :          0 :     return desc;
      87                 :            : }

Generated by: LCOV version 1.11