xapian-core  2.0.0
matcher.h
Go to the documentation of this file.
1 
4 /* Copyright (C) 2017,2018,2019 Olly Betts
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, see
18  * <https://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef XAPIAN_INCLUDED_MATCHER_H
22 #define XAPIAN_INCLUDED_MATCHER_H
23 
24 #ifndef PACKAGE
25 # error config.h must be included first in each C++ source file
26 #endif
27 
28 #include "api/enquireinternal.h"
29 #include "localsubmatch.h"
30 #include "remotesubmatch.h"
31 #include "weight/weightinternal.h"
32 
33 #include "xapian/database.h"
34 
35 #include <memory>
36 #include <vector>
37 
38 namespace Xapian {
39  class KeyMaker;
40  class MatchDecider;
41  class MSet;
42  class Query;
43  class Weight;
44 }
45 
46 class Matcher {
48 
50 
56  std::vector<std::unique_ptr<LocalSubMatch>> locals;
57 
58 #ifdef XAPIAN_HAS_REMOTE_BACKEND
78  std::vector<std::unique_ptr<RemoteSubMatch>> remotes;
79 
80 # ifndef HAVE_POLL
86  std::size_t first_nonselectable;
87 # endif
88 #endif
89 
90  Matcher(const Matcher&) = delete;
91 
92  Matcher& operator=(const Matcher&) = delete;
93 
95  Xapian::doccount maxitems,
96  Xapian::doccount check_at_least,
97  const Xapian::Weight& wtscheme,
98  const Xapian::MatchDecider* mdecider,
99  const Xapian::KeyMaker* sorter,
100  Xapian::valueno collapse_key,
101  Xapian::doccount collapse_max,
102  int percent_threshold,
103  double percent_threshold_factor,
104  double weight_threshold,
106  Xapian::valueno sort_key,
108  bool sort_val_reverse,
109  double time_limit,
110  const std::vector<opt_ptr_spy>& matchspies);
111 
113  template<typename Action> void for_all_remotes(Action action);
114 
115  public:
140  const Xapian::Query& query,
141  Xapian::termcount query_length,
142  const Xapian::RSet* rset,
144  const Xapian::Weight& wtscheme,
145  bool have_mdecider,
146  Xapian::valueno collapse_key,
147  Xapian::doccount collapse_max,
148  int percent_threshold,
149  double weight_threshold,
151  Xapian::valueno sort_key,
153  bool sort_val_reverse,
154  double time_limit,
155  const std::vector<opt_ptr_spy>& matchspies);
156 
194  Xapian::doccount maxitems,
195  Xapian::doccount check_at_least,
197  const Xapian::Weight& wtscheme,
198  const Xapian::MatchDecider* mdecider,
199  const Xapian::KeyMaker* sorter,
200  Xapian::valueno collapse_key,
201  Xapian::doccount collapse_max,
202  int percent_threshold,
203  double weight_threshold,
205  Xapian::valueno sort_key,
207  bool sort_val_reverse,
208  double time_limit,
209  const std::vector<opt_ptr_spy>& matchspies);
210 };
211 
212 #endif // XAPIAN_INCLUDED_MATCHER_H
static Xapian::Query query(Xapian::Query::op op, const string &t1=string(), const string &t2=string(), const string &t3=string(), const string &t4=string(), const string &t5=string(), const string &t6=string(), const string &t7=string(), const string &t8=string(), const string &t9=string(), const string &t10=string())
Definition: api_anydb.cc:62
Xapian::MSet get_mset(Xapian::doccount first, Xapian::doccount maxitems, Xapian::doccount check_at_least, Xapian::Weight::Internal &stats, const Xapian::Weight &wtscheme, const Xapian::MatchDecider *mdecider, const Xapian::KeyMaker *sorter, Xapian::valueno collapse_key, Xapian::doccount collapse_max, int percent_threshold, double weight_threshold, Xapian::Enquire::docid_order order, Xapian::valueno sort_key, Xapian::Enquire::Internal::sort_setting sort_by, bool sort_val_reverse, double time_limit, const std::vector< opt_ptr_spy > &matchspies)
Run the match and produce an MSet object.
Definition: matcher.cc:577
Xapian::Internal::opt_intrusive_ptr< Xapian::MatchSpy > opt_ptr_spy
Definition: matcher.h:47
Matcher(const Xapian::Database &db_, const Xapian::Query &query, Xapian::termcount query_length, const Xapian::RSet *rset, Xapian::Weight::Internal &stats, const Xapian::Weight &wtscheme, bool have_mdecider, Xapian::valueno collapse_key, Xapian::doccount collapse_max, int percent_threshold, double weight_threshold, Xapian::Enquire::docid_order order, Xapian::valueno sort_key, Xapian::Enquire::Internal::sort_setting sort_by, bool sort_val_reverse, double time_limit, const std::vector< opt_ptr_spy > &matchspies)
Constructor.
std::vector< std::unique_ptr< LocalSubMatch > > locals
LocalSubMatch objects for local databases.
Definition: matcher.h:56
Xapian::Database db
Definition: matcher.h:49
std::size_t first_nonselectable
Partition point in remotes.
Definition: matcher.h:86
Xapian::MSet get_local_mset(Xapian::doccount first, Xapian::doccount maxitems, Xapian::doccount check_at_least, const Xapian::Weight &wtscheme, const Xapian::MatchDecider *mdecider, const Xapian::KeyMaker *sorter, Xapian::valueno collapse_key, Xapian::doccount collapse_max, int percent_threshold, double percent_threshold_factor, double weight_threshold, Xapian::Enquire::docid_order order, Xapian::valueno sort_key, Xapian::Enquire::Internal::sort_setting sort_by, bool sort_val_reverse, double time_limit, const std::vector< opt_ptr_spy > &matchspies)
Definition: matcher.cc:341
Matcher & operator=(const Matcher &)=delete
std::vector< std::unique_ptr< RemoteSubMatch > > remotes
RemoteSubMatch objects for remote databases.
Definition: matcher.h:78
void for_all_remotes(Action action)
Perform action on remotes as they become ready using poll() or select().
Definition: matcher.cc:80
Matcher(const Matcher &)=delete
An indexed database of documents.
Definition: database.h:75
docid_order
Ordering of docids.
Definition: enquire.h:130
Virtual base class for key making functors.
Definition: keymaker.h:44
Class representing a list of search results.
Definition: mset.h:46
Abstract base class for match deciders.
Definition: matchdecider.h:37
Class representing a query.
Definition: query.h:45
Class representing a set of documents judged as relevant.
Definition: rset.h:39
Class to hold statistics for a given collection.
Abstract base class for weighting schemes.
Definition: weight.h:38
An indexed database of documents.
Xapian::Enquire internals.
SubMatch class for a local database.
The Xapian namespace contains public interfaces for the Xapian library.
Definition: compactor.cc:82
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
Definition: types.h:64
unsigned valueno
The number for a value slot in a document.
Definition: types.h:90
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
Definition: types.h:37
SubMatch class for a remote database.
Xapian::Weight::Internal class, holding database and term statistics.