2 * @brief SubMatch class for a local database.
4 /* Copyright (C) 2006,2007,2009,2010,2011,2013,2014,2015,2016,2018 Olly Betts
5 * Copyright (C) 2007 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_LOCALSUBMATCH_H
23 #define XAPIAN_INCLUDED_LOCALSUBMATCH_H
25 #include "backends/database.h"
27 #include "api/leafpostlist.h"
28 #include "api/queryinternal.h"
30 #include "xapian/enquire.h"
31 #include "xapian/weight.h"
37 class LocalSubMatch
: public SubMatch
{
38 /// Don't allow assignment.
39 void operator=(const LocalSubMatch
&);
41 /// Don't allow copying.
42 LocalSubMatch(const LocalSubMatch
&);
44 /// The statistics for the collection.
45 Xapian::Weight::Internal
* stats
;
50 /// The query length (used by some weighting schemes).
51 Xapian::termcount qlen
;
53 /// The (sub-)Database we're searching.
54 const Xapian::Database::Internal
*db
;
56 /** The RSet (used to calculate R and r).
58 * R and r are used in probabilistic weighting formulae.
62 /// Weight object (used as a factory by calling create on it).
63 const Xapian::Weight
* wt_factory
;
65 /// 0-based index for the subdatabase.
66 Xapian::doccount shard_index
;
70 LocalSubMatch(const Xapian::Database::Internal
*db_
,
71 const Xapian::Query
& query_
,
72 Xapian::termcount qlen_
,
73 const Xapian::RSet
& rset_
,
74 const Xapian::Weight
* wt_factory_
,
75 Xapian::doccount shard_index_
)
76 : stats(NULL
), query(query_
), qlen(qlen_
), db(db_
), rset(rset_
),
77 wt_factory(wt_factory_
),
78 shard_index(shard_index_
)
80 LOGCALL_CTOR(MATCH
, "LocalSubMatch", db_
| query_
| qlen_
| rset_
| wt_factory_
);
83 /// Fetch and collate statistics.
84 bool prepare_match(bool nowait
, Xapian::Weight::Internal
& total_stats
);
87 void start_match(Xapian::doccount first
,
88 Xapian::doccount maxitems
,
89 Xapian::doccount check_at_least
,
90 Xapian::Weight::Internal
& total_stats
);
93 PostList
* get_postlist(MultiMatch
*matcher
,
94 Xapian::termcount
* total_subqs_ptr
,
95 Xapian::Weight::Internal
& total_stats
);
97 /** Convert a postlist into a synonym postlist.
99 PostList
* make_synonym_postlist(PostList
* or_pl
, MultiMatch
* matcher
,
103 LeafPostList
* open_post_list(const std::string
& term
,
104 Xapian::termcount wqf
,
108 QueryOptimiser
* qopt
,
112 #endif /* XAPIAN_INCLUDED_LOCALSUBMATCH_H */