Update NEWS from git log
[xapian.git] / xapian-core / matcher / remotesubmatch.h
blobb945b7041c9b16e5514fb146d7bbfa5e1e41004f
1 /** @file
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 "submatch.h"
26 #include "backends/remote/remote-database.h"
27 #include "xapian/weight.h"
29 namespace Xapian {
30 class MatchSpy;
33 /// Class for performing matching on a remote database.
34 class RemoteSubMatch : public SubMatch {
35 /// Don't allow assignment.
36 void operator=(const RemoteSubMatch &);
38 /// Don't allow copying.
39 RemoteSubMatch(const RemoteSubMatch &);
41 /// The remote database.
42 RemoteDatabase *db;
44 /** Is the sort order such the relevance decreases down the MSet?
46 * This is true for sort_by_relevance and sort_by_relevance_then_value.
48 bool decreasing_relevance;
50 /// uncollapsed_upper_bound from the remote MSet.
51 Xapian::doccount uncollapsed_upper_bound;
53 /// The factor to use to convert weights to percentages.
54 double percent_factor;
56 /// The matchspies to use.
57 const vector<Xapian::Internal::opt_intrusive_ptr<Xapian::MatchSpy>> & matchspies;
59 public:
60 /// Constructor.
61 RemoteSubMatch(RemoteDatabase *db_,
62 bool decreasing_relevance_,
63 const vector<Xapian::Internal::opt_intrusive_ptr<Xapian::MatchSpy>> & matchspies);
65 /// Fetch and collate statistics.
66 bool prepare_match(bool nowait, Xapian::Weight::Internal & total_stats);
68 /// Start the match.
69 void start_match(Xapian::doccount first,
70 Xapian::doccount maxitems,
71 Xapian::doccount check_at_least,
72 Xapian::Weight::Internal & total_stats);
74 /// Get PostList.
75 PostList * get_postlist(MultiMatch * matcher,
76 Xapian::termcount* total_subqs_ptr,
77 Xapian::Weight::Internal& total_stats);
79 /// Get uncollapsed_upper_bound from the remote MSet.
80 Xapian::doccount get_uncollapsed_upper_bound() const {
81 return uncollapsed_upper_bound;
84 /// Get percentage factor - only valid after get_postlist().
85 double get_percent_factor() const { return percent_factor; }
87 /// Short-cut for single remote match.
88 void get_mset(Xapian::MSet & mset) { db->get_mset(mset, matchspies); }
91 #endif /* XAPIAN_INCLUDED_REMOTESUBMATCH_H */