LCOV - code coverage report
Current view: top level - matcher - remotesubmatch.h (source / functions) Hit Total Coverage
Test: Test Coverage for xapian-core 7028d852e609 Lines: 7 7 100.0 %
Date: 2019-02-17 14:59:59 Functions: 4 4 100.0 %
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /** @file remotesubmatch.h
       2                 :            :  *  @brief SubMatch class for a remote database.
       3                 :            :  */
       4                 :            : /* Copyright (C) 2006,2007,2009,2011,2014,2015,2018 Olly Betts
       5                 :            :  * Copyright (C) 2007,2008 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_REMOTESUBMATCH_H
      23                 :            : #define XAPIAN_INCLUDED_REMOTESUBMATCH_H
      24                 :            : 
      25                 :            : #include "backends/remote/remote-database.h"
      26                 :            : #include "xapian/weight.h"
      27                 :            : 
      28                 :            : namespace Xapian {
      29                 :            :     class MatchSpy;
      30                 :            : }
      31                 :            : 
      32                 :            : /// Class for performing matching on a remote database.
      33                 :            : class RemoteSubMatch {
      34                 :            :     /// Don't allow assignment.
      35                 :            :     RemoteSubMatch& operator=(const RemoteSubMatch &) = delete;
      36                 :            : 
      37                 :            :     /// Don't allow copying.
      38                 :            :     RemoteSubMatch(const RemoteSubMatch &) = delete;
      39                 :            : 
      40                 :            :     /// The remote database.
      41                 :            :     const RemoteDatabase *db;
      42                 :            : 
      43                 :            :     /// Index of this subdatabase.
      44                 :            :     size_t shard;
      45                 :            : 
      46                 :            :   public:
      47                 :            :     /// Constructor.
      48                 :      10362 :     RemoteSubMatch(const RemoteDatabase *db_, size_t shard_)
      49                 :      10362 :         : db(db_), shard(shard_) {}
      50                 :            : 
      51                 :         84 :     int get_read_fd() const {
      52                 :         84 :         return db->get_read_fd();
      53                 :            :     }
      54                 :            : 
      55                 :            :     /** Fetch and collate statistics.
      56                 :            :      *
      57                 :            :      *  Before we can calculate term weights we need to fetch statistics from
      58                 :            :      *  each database involved and collate them.
      59                 :            :      *
      60                 :            :      *  @param total_stats A stats object to which the statistics should be
      61                 :            :      *                  added.
      62                 :            :      */
      63                 :            :     void prepare_match(Xapian::Weight::Internal& total_stats);
      64                 :            : 
      65                 :            :     /** Start the match.
      66                 :            :      *
      67                 :            :      *  @param first          The first item in the result set to return.
      68                 :            :      *  @param maxitems       The maximum number of items to return.
      69                 :            :      *  @param check_at_least The minimum number of items to check.
      70                 :            :      *  @param total_stats    The total statistics for the collection.
      71                 :            :      */
      72                 :            :     void start_match(Xapian::doccount first,
      73                 :            :                      Xapian::doccount maxitems,
      74                 :            :                      Xapian::doccount check_at_least,
      75                 :            :                      Xapian::Weight::Internal& total_stats);
      76                 :            : 
      77                 :            :     typedef Xapian::Internal::opt_intrusive_ptr<Xapian::MatchSpy> opt_ptr_spy;
      78                 :            : 
      79                 :            :     /** Get MSet.
      80                 :            :      *
      81                 :            :      *  @param matchspies   The matchspies to use.
      82                 :            :      */
      83                 :      10362 :     Xapian::MSet get_mset(const std::vector<opt_ptr_spy>& matchspies) {
      84                 :      10362 :         return db->get_mset(matchspies);
      85                 :            :     }
      86                 :            : 
      87                 :            :     /// Return the index of the corresponding Database shard.
      88                 :         84 :     size_t get_shard() const { return shard; }
      89                 :            : };
      90                 :            : 
      91                 :            : #endif /* XAPIAN_INCLUDED_REMOTESUBMATCH_H */

Generated by: LCOV version 1.11