LCOV - code coverage report
Current view: top level - matcher - localsubmatch.h (source / functions) Hit Total Coverage
Test: Test Coverage for xapian-core c2b6f1024d3a Lines: 10 10 100.0 %
Date: 2019-05-16 09:13:18 Functions: 4 4 100.0 %
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /** @file localsubmatch.h
       2                 :            :  *  @brief SubMatch class for a local database.
       3                 :            :  */
       4                 :            : /* Copyright (C) 2006,2007,2009,2010,2011,2013,2014,2015,2016,2017,2018 Olly Betts
       5                 :            :  * Copyright (C) 2007 Lemur Consulting Ltd
       6                 :            :  *
       7                 :            :  * This program is free software; you can redistribute it and/or modify
       8                 :            :  * it under the terms of the GNU General Public License as published by
       9                 :            :  * the Free Software Foundation; either version 2 of the License, or
      10                 :            :  * (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_LOCALSUBMATCH_H
      23                 :            : #define XAPIAN_INCLUDED_LOCALSUBMATCH_H
      24                 :            : 
      25                 :            : #include "backends/databaseinternal.h"
      26                 :            : #include "api/leafpostlist.h"
      27                 :            : #include "api/queryinternal.h"
      28                 :            : #include "xapian/enquire.h"
      29                 :            : #include "xapian/weight.h"
      30                 :            : 
      31                 :            : #include <map>
      32                 :            : 
      33                 :            : class LeafPostList;
      34                 :            : class PostListTree;
      35                 :            : 
      36                 :     356526 : class LocalSubMatch {
      37                 :            :     /// Don't allow assignment.
      38                 :            :     LocalSubMatch& operator=(const LocalSubMatch &) = delete;
      39                 :            : 
      40                 :            :     /// Don't allow copying.
      41                 :            :     LocalSubMatch(const LocalSubMatch &) = delete;
      42                 :            : 
      43                 :            :     /// The statistics for the collection.
      44                 :            :     Xapian::Weight::Internal* total_stats;
      45                 :            : 
      46                 :            :     /// The original query before any rearrangement.
      47                 :            :     Xapian::Query query;
      48                 :            : 
      49                 :            :     /// The query length (used by some weighting schemes).
      50                 :            :     Xapian::termcount qlen;
      51                 :            : 
      52                 :            :     /// The (sub-)Database we're searching.
      53                 :            :     const Xapian::Database::Internal* db;
      54                 :            : 
      55                 :            :     /// Weight object (used as a factory by calling create on it).
      56                 :            :     const Xapian::Weight& wt_factory;
      57                 :            : 
      58                 :            :     /// Do any of the subdatabases have positional information?
      59                 :            :     bool full_db_has_positions;
      60                 :            : 
      61                 :            :   public:
      62                 :            :     /// Constructor.
      63                 :     178263 :     LocalSubMatch(const Xapian::Database::Internal* db_,
      64                 :            :                   const Xapian::Query& query_,
      65                 :            :                   Xapian::termcount qlen_,
      66                 :            :                   const Xapian::Weight& wt_factory_,
      67                 :            :                   bool full_db_has_positions_)
      68                 :            :         : total_stats(NULL), query(query_), qlen(qlen_), db(db_),
      69                 :            :           wt_factory(wt_factory_),
      70                 :     178263 :           full_db_has_positions(full_db_has_positions_)
      71                 :     178263 :     {}
      72                 :            : 
      73                 :            :     /** Fetch and collate statistics.
      74                 :            :      *
      75                 :            :      *  Before we can calculate term weights we need to fetch statistics from
      76                 :            :      *  each database involved and collate them.
      77                 :            :      *
      78                 :            :      *  @param rset     The RSet for this shard.
      79                 :            :      *  @param stats    Weight::Internal object to add the statistics to.
      80                 :            :      */
      81                 :     178263 :     void prepare_match(const Xapian::RSet& rset,
      82                 :            :                        Xapian::Weight::Internal& stats)
      83                 :            :     {
      84                 :     178263 :         stats.accumulate_stats(*db, rset);
      85                 :     178262 :     }
      86                 :            : 
      87                 :            :     /** Set the collated statistics.
      88                 :            :      *
      89                 :            :      *  These will be used when generating the PostList tree.
      90                 :            :      */
      91                 :     178262 :     void start_match(Xapian::Weight::Internal& total_stats_)
      92                 :            :     {
      93                 :     178262 :         total_stats = &total_stats_;
      94                 :     178262 :     }
      95                 :            : 
      96                 :            :     /// Get PostList.
      97                 :            :     PostList * get_postlist(PostListTree* matcher,
      98                 :            :                             Xapian::termcount* total_subqs_ptr);
      99                 :            : 
     100                 :            :     /** Convert a postlist into a synonym postlist.
     101                 :            :      */
     102                 :            :     PostList * make_synonym_postlist(PostListTree* pltree,
     103                 :            :                                      PostList* or_pl,
     104                 :            :                                      double factor,
     105                 :            :                                      bool wdf_disjoint);
     106                 :            : 
     107                 :            :     PostList * open_post_list(const std::string& term,
     108                 :            :                               Xapian::termcount wqf,
     109                 :            :                               double factor,
     110                 :            :                               bool need_positions,
     111                 :            :                               bool in_synonym,
     112                 :            :                               Xapian::Internal::QueryOptimiser* qopt,
     113                 :            :                               bool lazy_weight);
     114                 :            : };
     115                 :            : 
     116                 :            : #endif /* XAPIAN_INCLUDED_LOCALSUBMATCH_H */

Generated by: LCOV version 1.11