Stop forward declaring global QueryOptimiser in API header
[xapian.git] / xapian-core / matcher / localsubmatch.h
blob54baf0ff3c5fe7965c25864cd891907306c7b51c
1 /** @file localsubmatch.h
2 * @brief SubMatch class for a local database.
3 */
4 /* Copyright (C) 2006,2007,2009,2010,2011,2013,2014,2015,2016 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/databaseinternal.h"
26 #include "api/leafpostlist.h"
27 #include "api/queryinternal.h"
28 #include "xapian/enquire.h"
29 #include "xapian/weight.h"
31 #include <map>
33 class LeafPostList;
34 class PostListTree;
36 class LocalSubMatch {
37 /// Don't allow assignment.
38 LocalSubMatch& operator=(const LocalSubMatch &) = delete;
40 /// Don't allow copying.
41 LocalSubMatch(const LocalSubMatch &) = delete;
43 /// The statistics for the collection.
44 Xapian::Weight::Internal* total_stats;
46 /// The original query before any rearrangement.
47 Xapian::Query query;
49 /// The query length (used by some weighting schemes).
50 Xapian::termcount qlen;
52 /// The (sub-)Database we're searching.
53 const Xapian::Database::Internal* db;
55 /// Weight object (used as a factory by calling create on it).
56 const Xapian::Weight* wt_factory;
58 /// Do any of the subdatabases have positional information?
59 bool full_db_has_positions;
61 public:
62 /// Constructor.
63 LocalSubMatch(const Xapian::Database::Internal* db_,
64 const Xapian::Query& query_,
65 Xapian::termcount qlen_,
66 const Xapian::Weight* wt_factory_,
67 bool full_db_has_positions_)
68 : total_stats(NULL), query(query_), qlen(qlen_), db(db_),
69 wt_factory(wt_factory_),
70 full_db_has_positions(full_db_has_positions_)
73 /** Fetch and collate statistics.
75 * Before we can calculate term weights we need to fetch statistics from
76 * each database involved and collate them.
78 * @param rset The RSet for this shard.
79 * @param stats Weight::Internal object to add the statistics to.
81 void prepare_match(const Xapian::RSet& rset,
82 Xapian::Weight::Internal& stats)
84 stats.accumulate_stats(*db, rset);
87 /** Set the collated statistics.
89 * These will be used when generating the PostList tree.
91 void start_match(Xapian::Weight::Internal& total_stats_)
93 total_stats = &total_stats_;
96 /// Get PostList.
97 PostList * get_postlist(PostListTree* matcher,
98 Xapian::termcount* total_subqs_ptr);
100 /** Convert a postlist into a synonym postlist.
102 PostList * make_synonym_postlist(PostList* or_pl, double factor);
104 PostList * open_post_list(const std::string& term,
105 Xapian::termcount wqf,
106 double factor,
107 bool need_positions,
108 bool in_synonym,
109 Xapian::Internal::QueryOptimiser* qopt,
110 bool lazy_weight);
113 #endif /* XAPIAN_INCLUDED_LOCALSUBMATCH_H */