Remove unused forward class declaration
[xapian.git] / xapian-core / matcher / queryoptimiser.h
blob00bf66ef58e8f212288b1bd1683f0c78712e58f8
1 /** @file queryoptimiser.h
2 * @brief Details passed around while building PostList tree from Query tree
3 */
4 /* Copyright (C) 2007,2008,2009,2010,2011,2013,2014,2015,2016 Olly Betts
5 * Copyright (C) 2008 Lemur Consulting Ltd
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (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_QUERYOPTIMISER_H
23 #define XAPIAN_INCLUDED_QUERYOPTIMISER_H
25 #include "backends/databaseinternal.h"
26 #include "localsubmatch.h"
27 #include "api/postlist.h"
29 class LeafPostList;
30 class PostListTree;
32 class QueryOptimiser {
33 /// Prevent assignment.
34 void operator=(const QueryOptimiser &);
36 /// Prevent copying.
37 QueryOptimiser(const QueryOptimiser &);
39 LocalSubMatch & localsubmatch;
41 /** How many weighted leaf subqueries there are.
43 * Used for scaling percentages when the highest weighted document doesn't
44 * "match all terms".
46 Xapian::termcount total_subqs;
48 LeafPostList * hint;
50 bool hint_owned;
52 public:
53 bool need_positions;
55 bool in_synonym;
57 bool full_db_has_positions;
59 const Xapian::Database::Internal & db;
61 Xapian::doccount db_size;
63 PostListTree * matcher;
65 QueryOptimiser(const Xapian::Database::Internal & db_,
66 LocalSubMatch & localsubmatch_,
67 PostListTree * matcher_,
68 bool full_db_has_positions_)
69 : localsubmatch(localsubmatch_), total_subqs(0),
70 hint(0), hint_owned(false),
71 need_positions(false), in_synonym(false),
72 full_db_has_positions(full_db_has_positions_),
73 db(db_), db_size(db.get_doccount()),
74 matcher(matcher_) { }
76 ~QueryOptimiser() {
77 if (hint_owned) delete hint;
80 void inc_total_subqs() { ++total_subqs; }
82 Xapian::termcount get_total_subqs() const { return total_subqs; }
84 void set_total_subqs(Xapian::termcount n) { total_subqs = n; }
86 PostList * open_post_list(const std::string& term,
87 Xapian::termcount wqf,
88 double factor) {
89 return localsubmatch.open_post_list(term, wqf, factor, need_positions,
90 in_synonym, this, false);
93 PostList * open_lazy_post_list(const std::string& term,
94 Xapian::termcount wqf,
95 double factor) {
96 return localsubmatch.open_post_list(term, wqf, factor, false,
97 in_synonym, this, true);
100 PostList * make_synonym_postlist(PostList * pl, double factor) {
101 return localsubmatch.make_synonym_postlist(pl, factor);
104 const LeafPostList * get_hint_postlist() const { return hint; }
106 void set_hint_postlist(LeafPostList * new_hint) {
107 if (hint_owned) {
108 hint_owned = false;
109 delete hint;
111 hint = new_hint;
114 void take_hint_ownership() { hint_owned = true; }
117 #endif // XAPIAN_INCLUDED_QUERYOPTIMISER_H