Branch data Line data Source code
1 : : /** @file enquireinternal.h
2 : : * @brief Xapian::Enquire internals
3 : : */
4 : : /* Copyright 2017 Olly Betts
5 : : *
6 : : * This program is free software; you can redistribute it and/or
7 : : * modify it under the terms of the GNU General Public License as
8 : : * published by the Free Software Foundation; either version 2 of the
9 : : * License, or (at your option) any later version.
10 : : *
11 : : * This program is distributed in the hope that it will be useful,
12 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 : : * GNU General Public License for more details.
15 : : *
16 : : * You should have received a copy of the GNU General Public License
17 : : * along with this program; if not, write to the Free Software
18 : : * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 : : */
20 : :
21 : : #ifndef XAPIAN_INCLUDED_ENQUIREINTERNAL_H
22 : : #define XAPIAN_INCLUDED_ENQUIREINTERNAL_H
23 : :
24 : : #include "backends/databaseinternal.h"
25 : : #include "xapian/constants.h"
26 : : #include "xapian/database.h"
27 : : #include "xapian/enquire.h"
28 : : #include "xapian/intrusive_ptr.h"
29 : : #include "xapian/keymaker.h"
30 : : #include "xapian/matchspy.h"
31 : : #include "xapian/mset.h" // Only needed to forward declare MSet::Internal.
32 : : #include "xapian/query.h"
33 : :
34 : : #include <memory>
35 : : #include <string>
36 : : #include <vector>
37 : :
38 : : namespace Xapian {
39 : :
40 : : class ESet;
41 : : class RSet;
42 : : class Weight;
43 : :
44 : 40952 : class Enquire::Internal : public Xapian::Internal::intrusive_base {
45 : : friend class Enquire;
46 : : friend class MSet::Internal;
47 : :
48 : : public:
49 : : typedef enum { REL, VAL, VAL_REL, REL_VAL, DOCID } sort_setting;
50 : :
51 : : private:
52 : : Xapian::Database db;
53 : :
54 : : Xapian::Query query;
55 : :
56 : : mutable Xapian::termcount query_length = 0;
57 : :
58 : : mutable std::unique_ptr<Xapian::Weight> weight;
59 : :
60 : : docid_order order = Xapian::Enquire::ASCENDING;
61 : :
62 : : sort_setting sort_by = REL;
63 : :
64 : : Xapian::Internal::opt_intrusive_ptr<Xapian::KeyMaker> sort_functor;
65 : :
66 : : Xapian::valueno sort_key = Xapian::BAD_VALUENO;
67 : :
68 : : bool sort_val_reverse = false;
69 : :
70 : : Xapian::valueno collapse_key = Xapian::BAD_VALUENO;
71 : :
72 : : Xapian::doccount collapse_max = 0;
73 : :
74 : : int percent_threshold = 0;
75 : :
76 : : double weight_threshold = 0.0;
77 : :
78 : : std::vector<Xapian::Internal::opt_intrusive_ptr<MatchSpy>> matchspies;
79 : :
80 : : double time_limit = 0.0;
81 : :
82 : : enum { EXPAND_TRAD, EXPAND_BO1 } eweight = EXPAND_TRAD;
83 : :
84 : : double expand_k = 1.0;
85 : :
86 : : public:
87 : : explicit
88 : : Internal(const Database& db_);
89 : :
90 : : MSet get_mset(doccount first,
91 : : doccount maxitems,
92 : : doccount checkatleast,
93 : : const RSet* rset,
94 : : const MatchDecider* mdecider) const;
95 : :
96 : : TermIterator get_matching_terms_begin(docid did) const;
97 : :
98 : : ESet get_eset(termcount maxitems,
99 : : const RSet& rset,
100 : : int flags,
101 : : const ExpandDecider* edecider_,
102 : : double min_weight) const;
103 : :
104 : 14 : doccount get_termfreq(const std::string& term) const {
105 : 14 : return db.get_termfreq(term);
106 : : }
107 : :
108 : 200039 : Document get_document(docid did) const {
109 : : // This is called by MSetIterator, so we know the document exists.
110 : 200039 : return db.get_document(did, Xapian::DOC_ASSUME_VALID);
111 : : }
112 : :
113 : 42 : void request_document(docid did) const {
114 : 42 : db.internal->request_document(did);
115 : 42 : }
116 : : };
117 : :
118 : : }
119 : :
120 : : #endif // XAPIAN_INCLUDED_ENQUIREINTERNAL_H
|