Reimplement the matcher
[xapian.git] / xapian-core / matcher / remotesubmatch.h
blob1492df12b76a212481f2453d3ec18672a5d41afa
1 /** @file remotesubmatch.h
2 * @brief SubMatch class for a remote database.
3 */
4 /* Copyright (C) 2006,2007,2009,2011,2014,2015 Olly Betts
5 * Copyright (C) 2007,2008 Lemur Consulting Ltd
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.
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.
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
22 #ifndef XAPIAN_INCLUDED_REMOTESUBMATCH_H
23 #define XAPIAN_INCLUDED_REMOTESUBMATCH_H
25 #include "backends/remote/remote-database.h"
26 #include "xapian/weight.h"
28 namespace Xapian {
29 class MatchSpy;
32 /// Class for performing matching on a remote database.
33 class RemoteSubMatch {
34 /// Don't allow assignment.
35 RemoteSubMatch& operator=(const RemoteSubMatch &) = delete;
37 /// Don't allow copying.
38 RemoteSubMatch(const RemoteSubMatch &) = delete;
40 /// The remote database.
41 const RemoteDatabase *db;
43 typedef Xapian::Internal::opt_intrusive_ptr<Xapian::MatchSpy> opt_ptr_spy;
45 /// The matchspies to use.
46 const std::vector<opt_ptr_spy>& matchspies;
48 public:
49 /// Constructor.
50 RemoteSubMatch(const RemoteDatabase *db_,
51 const std::vector<opt_ptr_spy>& matchspies);
53 /** Fetch and collate statistics.
55 * Before we can calculate term weights we need to fetch statistics from
56 * each database involved and collate them.
58 * @param block A RemoteSubMatch may not be able to report statistics
59 * when first asked. If block is false, it will return
60 * false in this situation allowing the matcher to prepare
61 * other submatches. If block is true, then this method
62 * will block until statistics are available.
64 * @param total_stats A stats object to which the statistics should be
65 * added.
67 * @return If block is false and results aren't available yet
68 * then false will be returned and this method must be
69 * called again before the match can proceed. If results
70 * are available or block is true, then this method
71 * returns true.
73 bool prepare_match(bool block, Xapian::Weight::Internal& total_stats);
75 /** Start the match.
77 * @param first The first item in the result set to return.
78 * @param maxitems The maximum number of items to return.
79 * @param check_at_least The minimum number of items to check.
80 * @param total_stats The total statistics for the collection.
82 void start_match(Xapian::doccount first,
83 Xapian::doccount maxitems,
84 Xapian::doccount check_at_least,
85 Xapian::Weight::Internal& total_stats);
87 /// Get MSet.
88 Xapian::MSet get_mset() { return db->get_mset(matchspies); }
91 #endif /* XAPIAN_INCLUDED_REMOTESUBMATCH_H */