Branch data Line data Source code
1 : : /** @file localsubmatch.h
2 : : * @brief SubMatch class for a local database.
3 : : */
4 : : /* Copyright (C) 2006,2007,2009,2010 Olly Betts
5 : : * Copyright (C) 2007 Lemur Consulting Ltd
6 : : *
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.
11 : : *
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.
16 : : *
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
20 : : */
21 : :
22 : : #ifndef XAPIAN_INCLUDED_LOCALSUBMATCH_H
23 : : #define XAPIAN_INCLUDED_LOCALSUBMATCH_H
24 : :
25 : : #include "database.h"
26 : : #include "debuglog.h"
27 : : #include "omqueryinternal.h"
28 : : #include "submatch.h"
29 : : #include "xapian/enquire.h"
30 : : #include "xapian/weight.h"
31 : :
32 : : #include <map>
33 : :
34 [ + - ][ # # ]: 246355 : class LocalSubMatch : public SubMatch {
35 : : /// Don't allow assignment.
36 : : void operator=(const LocalSubMatch &);
37 : :
38 : : /// Don't allow copying.
39 : : LocalSubMatch(const LocalSubMatch &);
40 : :
41 : : /// The statistics for the collection.
42 : : const Xapian::Weight::Internal * stats;
43 : :
44 : : /// The original query before any rearrangement.
45 : : const Xapian::Query::Internal * query;
46 : :
47 : : /// The query length (used by some weighting schemes).
48 : : Xapian::termcount qlen;
49 : :
50 : : /// The (sub-)Database we're searching.
51 : : const Xapian::Database::Internal *db;
52 : :
53 : : /** The RSet (used to calculate R and r).
54 : : *
55 : : * R and r are used in probabilistic weighting formulae.
56 : : */
57 : : Xapian::RSet rset;
58 : :
59 : : /// Weight object (used as a factory by calling create on it).
60 : : const Xapian::Weight * wt_factory;
61 : :
62 : : /// The termfreqs and weights of terms used in orig_query, or NULL.
63 : : std::map<std::string,
64 : : Xapian::MSet::Internal::TermFreqAndWeight> * term_info;
65 : :
66 : : public:
67 : : /// Constructor.
68 : 246355 : LocalSubMatch(const Xapian::Database::Internal *db_,
69 : : const Xapian::Query::Internal * query_,
70 : : Xapian::termcount qlen_,
71 : : const Xapian::RSet & rset_,
72 : : const Xapian::Weight *wt_factory_)
73 : : : stats(NULL), query(query_), qlen(qlen_), db(db_), rset(rset_),
74 : 246355 : wt_factory(wt_factory_), term_info(NULL)
75 : : {
76 : : LOGCALL_CTOR(MATCH, "LocalSubMatch", db_ | query_ | qlen_ | rset_ | wt_factory_);
77 : 246355 : }
78 : :
79 : : /// Fetch and collate statistics.
80 : : bool prepare_match(bool nowait, Xapian::Weight::Internal & total_stats);
81 : :
82 : : /// Start the match.
83 : : void start_match(Xapian::doccount first,
84 : : Xapian::doccount maxitems,
85 : : Xapian::doccount check_at_least,
86 : : const Xapian::Weight::Internal & total_stats);
87 : :
88 : : /// Get PostList and term info.
89 : : PostList * get_postlist_and_term_info(MultiMatch *matcher,
90 : : std::map<std::string,
91 : : Xapian::MSet::Internal::TermFreqAndWeight> *termfreqandwts,
92 : : Xapian::termcount * total_subqs_ptr);
93 : :
94 : : /** Convert a postlist into a synonym postlist.
95 : : */
96 : : PostList * make_synonym_postlist(PostList * or_pl, MultiMatch * matcher,
97 : : double factor);
98 : :
99 : : /** Convert an OP_LEAF query to a PostList.
100 : : *
101 : : * This is called by QueryOptimiser when it reaches an OP_LEAF query.
102 : : */
103 : : PostList * postlist_from_op_leaf_query(const Xapian::Query::Internal *query,
104 : : double factor);
105 : : };
106 : :
107 : : #endif /* XAPIAN_INCLUDED_LOCALSUBMATCH_H */
|