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 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 "submatch.h"
26 : : #include "remote-database.h"
27 : : #include "xapian/weight.h"
28 : :
29 : : namespace Xapian {
30 : : class MatchSpy;
31 : : }
32 : :
33 : : /// Class for performing matching on a remote database.
34 [ + - ][ # # ]: 4404 : class RemoteSubMatch : public SubMatch {
35 : : /// Don't allow assignment.
36 : : void operator=(const RemoteSubMatch &);
37 : :
38 : : /// Don't allow copying.
39 : : RemoteSubMatch(const RemoteSubMatch &);
40 : :
41 : : /// The remote database.
42 : : RemoteDatabase *db;
43 : :
44 : : /** Is the sort order such the relevance decreases down the MSet?
45 : : *
46 : : * This is true for sort_by_relevance and sort_by_relevance_then_value.
47 : : */
48 : : bool decreasing_relevance;
49 : :
50 : : /// The factor to use to convert weights to percentages.
51 : : double percent_factor;
52 : :
53 : : /// The matchspies to use.
54 : : const vector<Xapian::MatchSpy *> & matchspies;
55 : :
56 : : public:
57 : : /// Constructor.
58 : : RemoteSubMatch(RemoteDatabase *db_,
59 : : bool decreasing_relevance_,
60 : : const vector<Xapian::MatchSpy *> & matchspies);
61 : :
62 : : /// Fetch and collate statistics.
63 : : bool prepare_match(bool nowait, Xapian::Weight::Internal & total_stats);
64 : :
65 : : /// Start the match.
66 : : void start_match(Xapian::doccount first,
67 : : Xapian::doccount maxitems,
68 : : Xapian::doccount check_at_least,
69 : : const Xapian::Weight::Internal & total_stats);
70 : :
71 : : /// Get PostList and term info.
72 : : PostList * get_postlist_and_term_info(MultiMatch *matcher,
73 : : std::map<std::string,
74 : : Xapian::MSet::Internal::TermFreqAndWeight> *termfreqandwts,
75 : : Xapian::termcount * total_subqs_ptr);
76 : :
77 : : /// Get percentage factor - only valid after get_postlist_and_term_info().
78 : 54 : double get_percent_factor() const { return percent_factor; }
79 : :
80 : : /// Short-cut for single remote match.
81 : 4248 : void get_mset(Xapian::MSet & mset) { db->get_mset(mset, matchspies); }
82 : : };
83 : :
84 : : #endif /* XAPIAN_INCLUDED_REMOTESUBMATCH_H */
|