2 * @brief class for performing a match
4 /* Copyright 1999,2000,2001 BrightStation PLC
5 * Copyright 2002,2003,2004,2005,2006,2007,2009,2011,2013,2014,2015,2016 Olly Betts
6 * Copyright 2009 Lemur Consulting Ltd
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of the
11 * License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
24 #ifndef OM_HGUARD_MULTIMATCH_H
25 #define OM_HGUARD_MULTIMATCH_H
31 #include "xapian/query.h"
32 #include "xapian/weight.h"
37 /// Vector of the items.
38 std::vector
<Xapian::Internal::intrusive_ptr
<SubMatch
> > leaves
;
40 const Xapian::Database db
;
44 Xapian::doccount collapse_max
;
46 Xapian::valueno collapse_key
;
52 Xapian::Enquire::docid_order order
;
54 Xapian::valueno sort_key
;
56 Xapian::Enquire::Internal::sort_setting sort_by
;
58 bool sort_value_forward
;
63 const Xapian::Weight
* weight
;
65 /** Internal flag to note that w_max needs to be recalculated
66 * while query is running.
68 bool recalculate_w_max
;
70 /** Is each sub-database remote? */
71 vector
<bool> is_remote
;
73 /// The matchspies to use.
74 const vector
<Xapian::Internal::opt_intrusive_ptr
<Xapian::MatchSpy
>> & matchspies
;
76 /** get the maxweight that the postlist pl may return, calling
77 * recalc_maxweight if recalculate_w_max is set, and unsetting it.
78 * Must only be called on the top of the postlist tree.
80 double getorrecalc_maxweight(PostList
*pl
);
82 /// Copying is not permitted.
83 MultiMatch(const MultiMatch
&);
85 /// Assignment is not permitted.
86 void operator=(const MultiMatch
&);
89 /** MultiMatch constructor.
91 * @param db_ The database to use.
92 * @param query The query
93 * @param qlen The query length
94 * @param omrset The relevance set (or NULL for no RSet)
95 * @param time_limit_ Seconds to reduce check_at_least after (or <= 0
97 * @param stats The stats object to add our stats to.
98 * @param wtscheme Weighting scheme
99 * @param matchspies_ Any the MatchSpy objects in use.
100 * @param have_sorter Is there a sorter in use?
101 * @param have_mdecider Is there a Xapian::MatchDecider in use?
103 MultiMatch(const Xapian::Database
&db_
,
104 const Xapian::Query
& query
,
105 Xapian::termcount qlen
,
106 const Xapian::RSet
* omrset
,
107 Xapian::doccount collapse_max_
,
108 Xapian::valueno collapse_key_
,
110 double weight_cutoff_
,
111 Xapian::Enquire::docid_order order_
,
112 Xapian::valueno sort_key_
,
113 Xapian::Enquire::Internal::sort_setting sort_by_
,
114 bool sort_value_forward_
,
116 Xapian::Weight::Internal
& stats
,
117 const Xapian::Weight
*wtscheme
,
118 const vector
<Xapian::Internal::opt_intrusive_ptr
<Xapian::MatchSpy
>> & matchspies_
,
119 bool have_sorter
, bool have_mdecider
);
121 /** Run the match and generate an MSet object.
123 * @param sorter Xapian::KeyMaker functor (or NULL for no KeyMaker)
125 void get_mset(Xapian::doccount first
,
126 Xapian::doccount maxitems
,
127 Xapian::doccount check_at_least
,
129 Xapian::Weight::Internal
& stats
,
130 const Xapian::MatchDecider
* mdecider
,
131 const Xapian::KeyMaker
* sorter
);
133 /** Called by postlists to indicate that they've rearranged themselves
134 * and the maxweight now possible is smaller.
136 void recalc_maxweight() {
137 recalculate_w_max
= true;
140 bool full_db_has_positions() const {
141 return db
.has_positions();
145 #endif /* OM_HGUARD_MULTIMATCH_H */