LCOV - code coverage report
Current view: top level - matcher - selectpostlist.h (source / functions) Hit Total Coverage
Test: Test Coverage for xapian-core 954b5873a738 Lines: 3 3 100.0 %
Date: 2019-06-30 05:20:33 Functions: 2 2 100.0 %
Branches: 1 2 50.0 %

           Branch data     Line data    Source code
       1                 :            : /** @file selectpostlist.h
       2                 :            :  * @brief Base class for classes which filter another PostList
       3                 :            :  */
       4                 :            : /* Copyright 2017 Olly Betts
       5                 :            :  *
       6                 :            :  * This program is free software; you can redistribute it and/or
       7                 :            :  * modify it under the terms of the GNU General Public License as
       8                 :            :  * published by the Free Software Foundation; either version 2 of the
       9                 :            :  * License, or (at your option) any later version.
      10                 :            :  *
      11                 :            :  * This program is distributed in the hope that it will be useful,
      12                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      13                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14                 :            :  * GNU General Public License for more details.
      15                 :            :  *
      16                 :            :  * You should have received a copy of the GNU General Public License
      17                 :            :  * along with this program; if not, write to the Free Software
      18                 :            :  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
      19                 :            :  */
      20                 :            : 
      21                 :            : #ifndef XAPIAN_INCLUDED_SELECTPOSTLIST_H
      22                 :            : #define XAPIAN_INCLUDED_SELECTPOSTLIST_H
      23                 :            : 
      24                 :            : #include "wrapperpostlist.h"
      25                 :            : 
      26                 :            : #include <cmath>
      27                 :            : 
      28                 :            : class PostListTree;
      29                 :            : 
      30                 :            : /// Base class for classes which filter another PostList
      31         [ -  + ]:       1580 : class SelectPostList : public WrapperPostList {
      32                 :            :     /// Used to avoid calculating the weight twice for a given document.
      33                 :            :     double cached_weight = -HUGE_VAL;
      34                 :            : 
      35                 :            :     PostListTree* pltree;
      36                 :            : 
      37                 :            :     /// Check if the current document is suitable.
      38                 :            :     bool vet(double w_min);
      39                 :            : 
      40                 :            :   protected:
      41                 :            :     /// Check if the current document should be selected.
      42                 :            :     virtual bool test_doc() = 0;
      43                 :            : 
      44                 :            :   public:
      45                 :        790 :     SelectPostList(PostList* pl_,
      46                 :            :                    PostListTree* pltree_)
      47                 :        790 :         : WrapperPostList(pl_), pltree(pltree_) {}
      48                 :            : 
      49                 :            :     double get_weight(Xapian::termcount doclen,
      50                 :            :                       Xapian::termcount unique_terms) const;
      51                 :            : 
      52                 :            :     bool at_end() const;
      53                 :            : 
      54                 :            :     PostList* next(double w_min);
      55                 :            : 
      56                 :            :     PostList* skip_to(Xapian::docid did, double w_min);
      57                 :            : 
      58                 :            :     PostList* check(Xapian::docid did, double w_min, bool& valid);
      59                 :            : 
      60                 :            :     Xapian::doccount get_termfreq_min() const;
      61                 :            : };
      62                 :            : 
      63                 :            : #endif // XAPIAN_INCLUDED_SELECTPOSTLIST_H

Generated by: LCOV version 1.11