1 /** @file submatch.h 2 * @brief base class for sub-matchers 3 */ 4 /* Copyright (C) 2006,2007,2009 Olly Betts 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_SUBMATCH_H 22 #define XAPIAN_INCLUDED_SUBMATCH_H 23 24 #include <xapian/base.h> 25 #include <xapian/types.h> 26 27 #include "omenquireinternal.h" 28 #include "postlist.h" 29 #include "xapian/weight.h" 30 31 class SubMatch : public Xapian::Internal::RefCntBase { 32 public: 33 /** Virtual destructor. 34 * 35 * Required because we have virtual methods and delete derived objects 36 * via a pointer to this base class. 37 */ ~SubMatch()38 virtual ~SubMatch() { } 39 40 /** Fetch and collate statistics. 41 * 42 * Before we can calculate term weights we need to fetch statistics from 43 * each database involved and collate them. 44 * 45 * @param nowait A RemoteSubMatch may not be able to report statistics 46 * when first asked. If nowait is true, it will return 47 * false in this situation allowing the matcher to ask 48 * other database. If nowait is false, then this method 49 * will block until statistics are available. 50 * 51 * @param total_stats A stats object to which the statistics should be 52 * added. 53 * 54 * @return If nowait is true and results aren't available yet 55 * then false will be returned and this method must be 56 * called again before the match can proceed. If results 57 * are available or nowait is false, then this method 58 * returns true. 59 */ 60 virtual bool prepare_match(bool nowait, 61 Xapian::Weight::Internal & total_stats) = 0; 62 63 /** Start the match. 64 * 65 * @param first The first item in the result set to return. 66 * @param maxitems The maximum number of items to return. 67 * @param check_at_least The minimum number of items to check. 68 * @param total_stats The total statistics for the collection. 69 */ 70 virtual void start_match(Xapian::doccount first, 71 Xapian::doccount maxitems, 72 Xapian::doccount check_at_least, 73 const Xapian::Weight::Internal & total_stats) = 0; 74 75 /// Get PostList and term info. 76 virtual PostList * get_postlist_and_term_info(MultiMatch *matcher, 77 std::map<std::string, 78 Xapian::MSet::Internal::TermFreqAndWeight> *termfreqandwts, 79 Xapian::termcount * total_subqs_ptr) 80 = 0; 81 }; 82 83 #endif /* XAPIAN_INCLUDED_SUBMATCH_H */ 84