LCOV - code coverage report
Current view: top level - matcher - andmaybepostlist.h (source / functions) Hit Total Coverage
Test: Test Coverage for xapian-core fcfb185a9dd5 Lines: 8 8 100.0 %
Date: 2019-04-18 16:33:14 Functions: 4 4 100.0 %
Branches: 3 4 75.0 %

           Branch data     Line data    Source code
       1                 :            : /** @file andmaybepostlist.h
       2                 :            :  * @brief PostList class implementing Query::OP_AND_MAYBE
       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_ANDMAYBEPOSTLIST_H
      22                 :            : #define XAPIAN_INCLUDED_ANDMAYBEPOSTLIST_H
      23                 :            : 
      24                 :            : #include "postlisttree.h"
      25                 :            : #include "wrapperpostlist.h"
      26                 :            : 
      27                 :            : /// PostList class implementing Query::OP_AND_MAYBE
      28                 :            : class AndMaybePostList : public WrapperPostList {
      29                 :            :     /// Right-hand side of OP_MAYBE.
      30                 :            :     PostList* r;
      31                 :            : 
      32                 :            :     /// Current docid from WrapperPostList's pl.
      33                 :            :     Xapian::docid pl_did = 0;
      34                 :            : 
      35                 :            :     /// Current docid from @a r (or 0).
      36                 :            :     Xapian::docid r_did = 0;
      37                 :            : 
      38                 :            :     /// Current max weight from WrapperPostList's pl.
      39                 :            :     double pl_max;
      40                 :            : 
      41                 :            :     /// Current max weight from @a r.
      42                 :            :     double r_max;
      43                 :            : 
      44                 :            :     /** Total number of documents in the database.
      45                 :            :      *
      46                 :            :      *  Only used if we decay to AND.
      47                 :            :      */
      48                 :            :     Xapian::doccount db_size;
      49                 :            : 
      50                 :            :     PostListTree* pltree;
      51                 :            : 
      52                 :            :     /// Does @a r match at the current position?
      53                 :       2124 :     bool maybe_matches() const { return pl_did == r_did; }
      54                 :            : 
      55                 :            :     PostList* decay_to_and(Xapian::docid did,
      56                 :            :                            double w_min,
      57                 :            :                            bool* valid_ptr = NULL);
      58                 :            : 
      59                 :            :   public:
      60                 :         44 :     AndMaybePostList(PostList* left, PostList* right,
      61                 :            :                      PostListTree* pltree_, Xapian::doccount db_size_)
      62                 :         44 :         : WrapperPostList(left), r(right), db_size(db_size_), pltree(pltree_)
      63                 :         44 :     {}
      64                 :            : 
      65                 :            :     /** Construct as decay product from OrPostList.
      66                 :            :      *
      67                 :            :      *  The first operation after such construction must be check() or
      68                 :            :      *  skip_to().
      69                 :            :      */
      70                 :        117 :     AndMaybePostList(PostList* left,
      71                 :            :                      PostList* right,
      72                 :            :                      double lmax,
      73                 :            :                      double rmax,
      74                 :            :                      PostListTree* pltree_,
      75                 :            :                      Xapian::doccount db_size_)
      76                 :            :         : WrapperPostList(left), r(right), pl_max(lmax), r_max(rmax),
      77                 :        117 :           db_size(db_size_), pltree(pltree_)
      78                 :            :     {
      79                 :        117 :     }
      80                 :            : 
      81 [ +  + ][ -  + ]:        644 :     ~AndMaybePostList() { delete r; }
      82                 :            : 
      83                 :            :     Xapian::docid get_docid() const;
      84                 :            : 
      85                 :            :     double get_weight(Xapian::termcount doclen,
      86                 :            :                       Xapian::termcount unique_terms) const;
      87                 :            : 
      88                 :            :     double recalc_maxweight();
      89                 :            : 
      90                 :            :     PostList* next(double w_min);
      91                 :            : 
      92                 :            :     PostList* skip_to(Xapian::docid did, double w_min);
      93                 :            : 
      94                 :            :     PostList* check(Xapian::docid did, double w_min, bool& valid);
      95                 :            : 
      96                 :            :     std::string get_description() const;
      97                 :            : 
      98                 :            :     Xapian::termcount get_wdf() const;
      99                 :            : 
     100                 :            :     Xapian::termcount count_matching_subqs() const;
     101                 :            : 
     102                 :            :     void gather_position_lists(OrPositionList* orposlist);
     103                 :            : };
     104                 :            : 
     105                 :            : #endif // XAPIAN_INCLUDED_ANDMAYBEPOSTLIST_H

Generated by: LCOV version 1.11