LCOV - code coverage report
Current view: top level - matcher - multixorpostlist.h (source / functions) Hit Total Coverage
Test: Test Coverage for xapian-core 954b5873a738 Lines: 13 15 86.7 %
Date: 2019-06-30 05:20:33 Functions: 2 3 66.7 %
Branches: 6 10 60.0 %

           Branch data     Line data    Source code
       1                 :            : /** @file multixorpostlist.h
       2                 :            :  * @brief N-way XOR postlist
       3                 :            :  */
       4                 :            : /* Copyright (C) 2007,2009,2010,2011,2012,2017 Olly Betts
       5                 :            :  * Copyright (C) 2009 Lemur Consulting Ltd
       6                 :            :  *
       7                 :            :  * This program is free software; you can redistribute it and/or
       8                 :            :  * modify it under the terms of the GNU General Public License as
       9                 :            :  * published by the Free Software Foundation; either version 2 of the
      10                 :            :  * License, or (at your option) any later version.
      11                 :            :  *
      12                 :            :  * This program is distributed in the hope that it will be useful,
      13                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      14                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      15                 :            :  * GNU General Public License for more details.
      16                 :            :  *
      17                 :            :  * You should have received a copy of the GNU General Public License
      18                 :            :  * along with this program; if not, write to the Free Software
      19                 :            :  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
      20                 :            :  */
      21                 :            : 
      22                 :            : #ifndef XAPIAN_INCLUDED_MULTIXORPOSTLIST_H
      23                 :            : #define XAPIAN_INCLUDED_MULTIXORPOSTLIST_H
      24                 :            : 
      25                 :            : #include "api/postlist.h"
      26                 :            : #include <algorithm>
      27                 :            : 
      28                 :            : #include "postlisttree.h"
      29                 :            : 
      30                 :            : /// N-way XOR postlist.
      31                 :            : class MultiXorPostList : public PostList {
      32                 :            :     /// Don't allow assignment.
      33                 :            :     void operator=(const MultiXorPostList &);
      34                 :            : 
      35                 :            :     /// Don't allow copying.
      36                 :            :     MultiXorPostList(const MultiXorPostList &);
      37                 :            : 
      38                 :            :     /// The current docid, or zero if we haven't started or are at_end.
      39                 :            :     Xapian::docid did;
      40                 :            : 
      41                 :            :     /// The number of sub-postlists.
      42                 :            :     size_t n_kids;
      43                 :            : 
      44                 :            :     /// Array of pointers to sub-postlists.
      45                 :            :     PostList ** plist;
      46                 :            : 
      47                 :            :     /// The number of documents in the database.
      48                 :            :     Xapian::doccount db_size;
      49                 :            : 
      50                 :            :     /// Pointer to the matcher object, so we can report pruning.
      51                 :            :     PostListTree *matcher;
      52                 :            : 
      53                 :            :     /// Erase a sub-postlist.
      54                 :        166 :     void erase_sublist(size_t i) {
      55         [ +  - ]:        166 :         delete plist[i];
      56                 :        166 :         --n_kids;
      57         [ +  + ]:        331 :         for (size_t j = i; j < n_kids; ++j) {
      58                 :        165 :             plist[j] = plist[j + 1];
      59                 :            :         }
      60                 :        166 :         matcher->force_recalc();
      61                 :        166 :     }
      62                 :            : 
      63                 :            :   public:
      64                 :            :     /** Construct from 2 random-access iterators to a container of PostList*,
      65                 :            :      *  a pointer to the matcher, and the document collection size.
      66                 :            :      */
      67                 :            :     template<class RandomItor>
      68                 :        118 :     MultiXorPostList(RandomItor pl_begin, RandomItor pl_end,
      69                 :            :                      PostListTree * matcher_, Xapian::doccount db_size_)
      70                 :        118 :         : did(0), n_kids(pl_end - pl_begin), plist(NULL),
      71                 :        118 :           db_size(db_size_), matcher(matcher_)
      72                 :            :     {
      73 [ +  - ][ +  - ]:        118 :         plist = new PostList * [n_kids];
      74         [ +  - ]:        118 :         std::copy(pl_begin, pl_end, plist);
      75                 :        118 :     }
      76                 :            : 
      77                 :            :     ~MultiXorPostList();
      78                 :            : 
      79                 :            :     Xapian::doccount get_termfreq_min() const;
      80                 :            : 
      81                 :            :     Xapian::doccount get_termfreq_max() const;
      82                 :            : 
      83                 :            :     Xapian::doccount get_termfreq_est() const;
      84                 :            : 
      85                 :            :     TermFreqs get_termfreq_est_using_stats(
      86                 :            :         const Xapian::Weight::Internal & stats) const;
      87                 :            : 
      88                 :            :     Xapian::docid get_docid() const;
      89                 :            : 
      90                 :            :     double get_weight(Xapian::termcount doclen,
      91                 :            :                       Xapian::termcount unique_terms) const;
      92                 :            : 
      93                 :            :     bool at_end() const;
      94                 :            : 
      95                 :            :     double recalc_maxweight();
      96                 :            : 
      97                 :          0 :     PositionList * read_position_list() {
      98                 :          0 :         return NULL;
      99                 :            :     }
     100                 :            : 
     101                 :            :     PostList* next(double w_min);
     102                 :            : 
     103                 :            :     PostList* skip_to(Xapian::docid, double w_min);
     104                 :            : 
     105                 :            :     std::string get_description() const;
     106                 :            : 
     107                 :            :     /** get_wdf() for MultiXorPostlists returns the sum of the wdfs of the
     108                 :            :      *  sub postlists which match the current docid.
     109                 :            :      *
     110                 :            :      *  The wdf isn't really meaningful in many situations, but if the lists
     111                 :            :      *  are being combined as a synonym we want the sum of the wdfs, so we do
     112                 :            :      *  that in general.
     113                 :            :      */
     114                 :            :     Xapian::termcount get_wdf() const;
     115                 :            : 
     116                 :            :     Xapian::termcount count_matching_subqs() const;
     117                 :            : };
     118                 :            : 
     119                 :            : #endif // XAPIAN_INCLUDED_MULTIXORPOSTLIST_H

Generated by: LCOV version 1.11