00001
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef XAPIAN_INCLUDED_QUERYOPTIMISER_H
00023 #define XAPIAN_INCLUDED_QUERYOPTIMISER_H
00024
00025 #include "xapian/query.h"
00026
00027 #include "database.h"
00028 #include "localsubmatch.h"
00029 #include "omenquireinternal.h"
00030 #include "postlist.h"
00031
00032 #include <list>
00033 #include <vector>
00034
00035 class MultiMatch;
00036 struct PosFilter;
00037
00038 class QueryOptimiser {
00039 const Xapian::Database::Internal & db;
00040
00041 Xapian::doccount db_size;
00042
00043 LocalSubMatch & localsubmatch;
00044
00045 MultiMatch * matcher;
00046
00052 Xapian::termcount total_subqs;
00053
00061 PostList * do_subquery(const Xapian::Query::Internal * query,
00062 double factor);
00063
00072 PostList * do_and_like(const Xapian::Query::Internal *query, double factor);
00073
00084 void do_and_like(const Xapian::Query::Internal *query, double factor,
00085 std::vector<PostList *> & and_plists,
00086 std::list<PosFilter> & pos_filters);
00087
00096 PostList * do_or_like(const Xapian::Query::Internal *query, double factor);
00097
00105 PostList * do_synonym(const Xapian::Query::Internal *query, double factor);
00106
00107 public:
00108 QueryOptimiser(const Xapian::Database::Internal & db_,
00109 LocalSubMatch & localsubmatch_,
00110 MultiMatch * matcher_)
00111 : db(db_), db_size(db.get_doccount()), localsubmatch(localsubmatch_),
00112 matcher(matcher_), total_subqs(0) { }
00113
00114 PostList * optimise_query(const Xapian::Query::Internal * query) {
00115 return do_subquery(query, 1.0);
00116 }
00117
00118 Xapian::termcount get_total_subqueries() const { return total_subqs; }
00119 };
00120
00121 #endif // XAPIAN_INCLUDED_QUERYOPTIMISER_H