Ticket #473: querypostingsource.patch
File querypostingsource.patch, 9.1 KB (added by , 15 years ago) |
---|
-
xapian-core/include/xapian/querypostingsource.h
1 /** @file querypostingsource.h 2 * @brief A posting source based on a query. 3 */ 4 /* Copyright (C) 2008 Lemur Consulting Ltd 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (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_QUERYPOSTINGSOURCE_H 22 #define XAPIAN_INCLUDED_QUERYPOSTINGSOURCE_H 23 24 #include <xapian/postingsource.h> 25 26 #include <string> 27 28 namespace Xapian { 29 30 class Database; 31 class Query; 32 class RSet; 33 class Weight; 34 35 /// A posting source which returns all documents matching a query. 36 class XAPIAN_VISIBILITY_DEFAULT QueryPostingSource : public PostingSource { 37 public: 38 // Declaration of Internal has to be public, so that the friend 39 // declaration in Query::Internal works. 40 class Internal; 41 private: 42 43 Internal * internal; 44 public: 45 /** Construct a QueryPostingSource from a given query. 46 * 47 * @param q The query to construct the posting source from. 48 */ 49 QueryPostingSource(Xapian::Database db, 50 const Xapian::Query & q, 51 const Xapian::RSet & rset, 52 const Xapian::Weight * wt_factory); 53 54 ~QueryPostingSource(); 55 56 Xapian::doccount get_termfreq_min() const; 57 Xapian::doccount get_termfreq_est() const; 58 Xapian::doccount get_termfreq_max() const; 59 60 Xapian::weight get_maxweight() const; 61 Xapian::weight get_weight() const; 62 63 void next(Xapian::weight min_wt); 64 void skip_to(Xapian::docid did, Xapian::weight min_wt); 65 bool check(Xapian::docid did, Xapian::weight min_wt); 66 67 bool at_end() const; 68 69 Xapian::docid get_docid() const; 70 71 void reset(); 72 73 std::string get_description() const; 74 }; 75 76 } 77 78 #endif // XAPIAN_INCLUDED_QUERYPOSTINGSOURCE_H -
xapian-core/include/xapian/query.h
Property changes on: xapian-core/include/xapian/querypostingsource.h ___________________________________________________________________ Name: svn:eol-style + native
29 29 #include <vector> 30 30 31 31 #include <xapian/base.h> 32 #include <xapian/querypostingsource.h> 32 33 #include <xapian/types.h> 33 34 #include <xapian/termiterator.h> 34 35 #include <xapian/visibility.h> … … 278 279 friend class ::MultiMatch; 279 280 friend class ::QueryOptimiser; 280 281 friend struct ::SortPosName; 282 friend class Xapian::QueryPostingSource::Internal; 281 283 friend class Query; 282 284 public: 283 285 static const int OP_LEAF = -1; -
xapian-core/include/xapian/enquire.h
27 27 #include <string> 28 28 29 29 #include <xapian/base.h> 30 #include <xapian/querypostingsource.h> 30 31 #include <xapian/sorter.h> 31 32 #include <xapian/types.h> 32 33 #include <xapian/termiterator.h> … … 1016 1017 friend class Enquire; // So Enquire can clone us 1017 1018 friend class ::RemoteServer; // So RemoteServer can clone us - FIXME 1018 1019 friend class ::ScaleWeight; 1020 friend class QueryPostingSource::Internal; 1019 1021 public: 1020 1022 class Internal; 1021 1023 protected: -
xapian-core/include/Makefile.mk
25 25 include/xapian/postingsource.h\ 26 26 include/xapian/query.h\ 27 27 include/xapian/queryparser.h\ 28 include/xapian/querypostingsource.h\ 28 29 include/xapian/replication.h\ 29 30 include/xapian/sorter.h\ 30 31 include/xapian/stem.h\ -
xapian-core/include/xapian.h
48 48 #include <xapian/postingsource.h> 49 49 #include <xapian/query.h> 50 50 #include <xapian/queryparser.h> 51 #include <xapian/querypostingsource.h> 51 52 #include <xapian/sorter.h> 52 53 #include <xapian/valuesetmatchdecider.h> 53 54 -
xapian-core/api/Makefile.mk
24 24 api/omtermlistiterator.cc\ 25 25 api/postingsource.cc\ 26 26 api/postlist.cc\ 27 api/querypostingsource.cc\ 27 28 api/replication.cc\ 28 29 api/sortable-serialise.cc\ 29 30 api/sorter.cc\ -
xapian-core/api/querypostingsource.cc
1 /** @file querypostingsource.cc 2 * @brief A posting source based on a query. 3 */ 4 /* Copyright (C) 2008 Lemur Consulting Ltd 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 #include <config.h> 22 23 #include "xapian/database.h" 24 #include "xapian/enquire.h" 25 #include "xapian/error.h" 26 #include "xapian/querypostingsource.h" 27 28 #include "matcher/localmatch.h" 29 30 namespace Xapian { 31 32 class QueryPostingSource::Internal 33 { 34 public: 35 Database db; 36 Query q; 37 RSet rset; 38 const Weight * wt_factory; 39 40 termcount qlen; 41 42 LocalSubMatch * matcher; 43 44 Internal(Database db_, const Query & q_, const RSet & rset_, 45 const Weight * wt_factory_); 46 ~Internal(); 47 48 void reset(); 49 bool at_end() const; 50 }; 51 52 QueryPostingSource::Internal::Internal(Database db_, const Query & q_, 53 const RSet & rset_, 54 const Weight * wt_factory_) 55 : db(db_), 56 q(q_), 57 rset(rset_), 58 wt_factory(NULL), 59 qlen(q_.get_length()), 60 matcher(NULL) 61 { 62 if (wt_factory_ == NULL) { 63 wt_factory = new BM25Weight(); 64 } else { 65 wt_factory = wt_factory_->clone(); 66 } 67 if (db.internal.size() != 1) { 68 throw InvalidOperationError("QueryPostingSource needs to be passed a single database"); 69 } 70 q.internal->validate_query(); 71 } 72 73 QueryPostingSource::Internal::~Internal() 74 { 75 delete matcher; 76 delete wt_factory; 77 } 78 79 void 80 QueryPostingSource::Internal::reset() 81 { 82 delete matcher; 83 84 if (q.internal.get() == 0) { 85 matcher = NULL; 86 return; 87 } 88 89 matcher = new LocalSubMatch(db.internal[0].get(), 90 q.internal.get(), 91 qlen, rset, 92 wt_factory); 93 } 94 95 96 QueryPostingSource::QueryPostingSource(Database db, 97 const Query & q, 98 const RSet & rset, 99 const Weight * wt_factory) 100 : internal(new Internal(db, q, rset, wt_factory)) 101 { 102 } 103 104 QueryPostingSource::~QueryPostingSource() 105 { 106 delete internal; 107 } 108 109 doccount 110 QueryPostingSource::get_termfreq_min() const 111 { 112 } 113 114 doccount 115 QueryPostingSource::get_termfreq_est() const 116 { 117 } 118 119 doccount 120 QueryPostingSource::get_termfreq_max() const 121 { 122 } 123 124 weight 125 QueryPostingSource::get_maxweight() const 126 { 127 } 128 129 weight 130 QueryPostingSource::get_weight() const 131 { 132 } 133 134 void 135 QueryPostingSource::next(weight min_wt) 136 { 137 } 138 139 void 140 QueryPostingSource::skip_to(docid min_docid, 141 weight min_wt) 142 { 143 } 144 145 bool 146 QueryPostingSource::check(docid min_docid, 147 weight min_wt) 148 { 149 } 150 151 bool 152 QueryPostingSource::at_end() const 153 { 154 return internal->at_end(); 155 } 156 157 docid 158 QueryPostingSource::get_docid() const 159 { 160 } 161 162 void 163 QueryPostingSource::reset() 164 { 165 internal->reset(); 166 } 167 168 std::string 169 QueryPostingSource::get_description() const 170 { 171 return "Xapian::QueryPostingSource(" + 172 internal->db.get_description() + ", " + 173 internal->q.get_description() + ")"; 174 } 175 176 }