LCOV - code coverage report
Current view: top level - expand - ortermlist.h (source / functions) Hit Total Coverage
Test: Test Coverage for xapian-core 4ba52dacf4fb Lines: 6 6 100.0 %
Date: 2019-05-20 14:58:19 Functions: 3 3 100.0 %
Branches: 3 6 50.0 %

           Branch data     Line data    Source code
       1                 :            : /** @file ortermlist.h
       2                 :            :  * @brief Merge two TermList objects using an OR operation.
       3                 :            :  */
       4                 :            : /* Copyright (C) 2007,2010 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_ORTERMLIST_H
      22                 :            : #define XAPIAN_INCLUDED_ORTERMLIST_H
      23                 :            : 
      24                 :            : #include "api/termlist.h"
      25                 :            : 
      26                 :            : namespace Xapian {
      27                 :            : namespace Internal {
      28                 :            : class ExpandStats;
      29                 :            : }
      30                 :            : }
      31                 :            : 
      32                 :            : class OrTermList : public TermList {
      33                 :            :   protected:
      34                 :            :     /// The two TermList objects we're merging.
      35                 :            :     TermList *left, *right;
      36                 :            : 
      37                 :            :     /** The current term for left and right respectively.
      38                 :            :      *
      39                 :            :      *  Until next() is first called, these will be empty strings.  Once next()
      40                 :            :      *  has been called, they won't be empty (since the empty string isn't a
      41                 :            :      *  valid term).
      42                 :            :      */
      43                 :            :     std::string left_current, right_current;
      44                 :            : 
      45                 :            :     /// Check that next() has already been called.
      46                 :            :     void check_started() const;
      47                 :            : 
      48                 :            :   public:
      49                 :      10774 :     OrTermList(TermList * left_, TermList * right_)
      50 [ +  - ][ +  - ]:      10774 :         : left(left_), right(right_) { }
      51                 :            : 
      52                 :            :     ~OrTermList();
      53                 :            : 
      54                 :            :     Xapian::termcount get_approx_size() const;
      55                 :            : 
      56                 :            :     void accumulate_stats(Xapian::Internal::ExpandStats & stats) const;
      57                 :            : 
      58                 :            :     std::string get_termname() const;
      59                 :            : 
      60                 :            :     Xapian::termcount get_wdf() const;
      61                 :            : 
      62                 :            :     Xapian::doccount get_termfreq() const;
      63                 :            : 
      64                 :            :     TermList *next();
      65                 :            : 
      66                 :            :     TermList * skip_to(const std::string & term);
      67                 :            : 
      68                 :            :     bool at_end() const;
      69                 :            : 
      70                 :            :     Xapian::termcount positionlist_count() const;
      71                 :            : 
      72                 :            :     PositionList* positionlist_begin() const;
      73                 :            : };
      74                 :            : 
      75                 :            : /** A termlist which ORs two termlists together, adding term frequencies.
      76                 :            :  *
      77                 :            :  *  This termlist is just like OrTermList, but adds the term frequencies of
      78                 :            :  *  terms which appear in both sublists together, rather than asserting that the
      79                 :            :  *  frequencies are equal.  This is appropriate for spelling termlists.
      80                 :            :  */
      81         [ -  + ]:          4 : class FreqAdderOrTermList : public OrTermList {
      82                 :            :     public:
      83                 :          1 :         FreqAdderOrTermList(TermList * left_, TermList * right_)
      84                 :          1 :                 : OrTermList(left_, right_)
      85                 :          1 :         { }
      86                 :            : 
      87                 :            :         Xapian::doccount get_termfreq() const;
      88                 :            : };
      89                 :            : 
      90                 :            : #endif // XAPIAN_INCLUDED_ORTERMLIST_H

Generated by: LCOV version 1.11